From d75ed1cace0ec2f9c3788848bf31d5f9c10c32a2 Mon Sep 17 00:00:00 2001 From: Kellar Date: Thu, 10 Oct 2024 13:42:50 +0100 Subject: [PATCH 1/3] Deploy to sepolia --- .../DecentSablierStreamManagement.json | 100 +++++ .../4511b61209438ca20d2458493e70bb24.json | 351 ++++++++++++++++++ 2 files changed, 451 insertions(+) create mode 100644 deployments/sepolia/DecentSablierStreamManagement.json create mode 100644 deployments/sepolia/solcInputs/4511b61209438ca20d2458493e70bb24.json diff --git a/deployments/sepolia/DecentSablierStreamManagement.json b/deployments/sepolia/DecentSablierStreamManagement.json new file mode 100644 index 00000000..3779fae4 --- /dev/null +++ b/deployments/sepolia/DecentSablierStreamManagement.json @@ -0,0 +1,100 @@ +{ + "address": "0x5874bf327bA5b78b2371b13eB414B66179591d34", + "abi": [ + { + "inputs": [], + "name": "NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ISablierV2Lockup", + "name": "sablier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + } + ], + "name": "cancelStream", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ISablierV2Lockup", + "name": "sablier", + "type": "address" + }, + { + "internalType": "address", + "name": "recipientHatAccount", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "withdrawMaxFromStream", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x5df751f83f960a27ef212bed1f54e8bf08a87056e74af2878fcfef8082d9eec3", + "receipt": { + "to": null, + "from": "0xeb54d471CFadb8a9fD114C4628c89620b313432f", + "contractAddress": "0x5874bf327bA5b78b2371b13eB414B66179591d34", + "transactionIndex": 72, + "gasUsed": "384441", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x2d90032ee5f61b968f6e38065b8dab930b88bb292edc0059448acc5e02903a4a", + "transactionHash": "0x5df751f83f960a27ef212bed1f54e8bf08a87056e74af2878fcfef8082d9eec3", + "logs": [], + "blockNumber": 6850325, + "cumulativeGasUsed": "8716271", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4511b61209438ca20d2458493e70bb24", + "metadata": "{\"compiler\":{\"version\":\"0.8.28+commit.7893614a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"NAME\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISablierV2Lockup\",\"name\":\"sablier\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"streamId\",\"type\":\"uint256\"}],\"name\":\"cancelStream\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISablierV2Lockup\",\"name\":\"sablier\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipientHatAccount\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"streamId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"withdrawMaxFromStream\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/DecentSablierStreamManagement.sol\":\"DecentSablierStreamManagement\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only\\npragma solidity >=0.7.0 <0.9.0;\\n\\n/// @title Enum - Collection of enums\\n/// @author Richard Meissner - \\ncontract Enum {\\n enum Operation {Call, DelegateCall}\\n}\\n\",\"keccak256\":\"0x473e45b1a5cc47be494b0e123c9127f0c11c1e0992a321ae5a644c0bfdb2c14f\",\"license\":\"LGPL-3.0-only\"},\"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only\\n\\n/// @title Zodiac Avatar - A contract that manages modules that can execute transactions via this contract.\\npragma solidity >=0.7.0 <0.9.0;\\n\\nimport \\\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\\\";\\n\\ninterface IAvatar {\\n event EnabledModule(address module);\\n event DisabledModule(address module);\\n event ExecutionFromModuleSuccess(address indexed module);\\n event ExecutionFromModuleFailure(address indexed module);\\n\\n /// @dev Enables a module on the avatar.\\n /// @notice Can only be called by the avatar.\\n /// @notice Modules should be stored as a linked list.\\n /// @notice Must emit EnabledModule(address module) if successful.\\n /// @param module Module to be enabled.\\n function enableModule(address module) external;\\n\\n /// @dev Disables a module on the avatar.\\n /// @notice Can only be called by the avatar.\\n /// @notice Must emit DisabledModule(address module) if successful.\\n /// @param prevModule Address that pointed to the module to be removed in the linked list\\n /// @param module Module to be removed.\\n function disableModule(address prevModule, address module) external;\\n\\n /// @dev Allows a Module to execute a transaction.\\n /// @notice Can only be called by an enabled module.\\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\\n function execTransactionFromModule(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation\\n ) external returns (bool success);\\n\\n /// @dev Allows a Module to execute a transaction and return data\\n /// @notice Can only be called by an enabled module.\\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\\n function execTransactionFromModuleReturnData(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation\\n ) external returns (bool success, bytes memory returnData);\\n\\n /// @dev Returns if an module is enabled\\n /// @return True if the module is enabled\\n function isModuleEnabled(address module) external view returns (bool);\\n\\n /// @dev Returns array of modules.\\n /// @param start Start of the page.\\n /// @param pageSize Maximum number of modules that should be returned.\\n /// @return array Array of modules.\\n /// @return next Start of the next page.\\n function getModulesPaginated(address start, uint256 pageSize)\\n external\\n view\\n returns (address[] memory array, address next);\\n}\\n\",\"keccak256\":\"0xcd5508ffe596eef8fbccfd5fc4f10a34397773547ce64e212d48b5212865ec1f\",\"license\":\"LGPL-3.0-only\"},\"@openzeppelin/contracts/interfaces/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/introspection/IERC165.sol\\\";\\n\",\"keccak256\":\"0xd04b0f06e0666f29cf7cccc82894de541e19bb30a765b107b1e40bb7fe5f7d7a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xed6a749c5373af398105ce6ee3ac4763aa450ea7285d268c85d9eeca809cdb1f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Metadata is IERC721 {\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x75b829ff2f26c14355d1cba20e16fe7b29ca58eb5fef665ede48bc0f9c6c74b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\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[EIP 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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@prb/math/src/Common.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n// Common.sol\\n//\\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\\n// always operate with SD59x18 and UD60x18 numbers.\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CUSTOM ERRORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\\n\\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\\n\\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\\nerror PRBMath_MulDivSigned_InputTooSmall();\\n\\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CONSTANTS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @dev The maximum value a uint128 number can have.\\nuint128 constant MAX_UINT128 = type(uint128).max;\\n\\n/// @dev The maximum value a uint40 number can have.\\nuint40 constant MAX_UINT40 = type(uint40).max;\\n\\n/// @dev The unit number, which the decimal precision of the fixed-point types.\\nuint256 constant UNIT = 1e18;\\n\\n/// @dev The unit number inverted mod 2^256.\\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\\n\\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\\n/// bit in the binary representation of `UNIT`.\\nuint256 constant UNIT_LPOTD = 262144;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method.\\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(uint256 x) pure returns (uint256 result) {\\n unchecked {\\n // Start from 0.5 in the 192.64-bit fixed-point format.\\n result = 0x800000000000000000000000000000000000000000000000;\\n\\n // The following logic multiplies the result by $\\\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\\n //\\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\\n // we know that `x & 0xFF` is also 1.\\n if (x & 0xFF00000000000000 > 0) {\\n if (x & 0x8000000000000000 > 0) {\\n result = (result * 0x16A09E667F3BCC909) >> 64;\\n }\\n if (x & 0x4000000000000000 > 0) {\\n result = (result * 0x1306FE0A31B7152DF) >> 64;\\n }\\n if (x & 0x2000000000000000 > 0) {\\n result = (result * 0x1172B83C7D517ADCE) >> 64;\\n }\\n if (x & 0x1000000000000000 > 0) {\\n result = (result * 0x10B5586CF9890F62A) >> 64;\\n }\\n if (x & 0x800000000000000 > 0) {\\n result = (result * 0x1059B0D31585743AE) >> 64;\\n }\\n if (x & 0x400000000000000 > 0) {\\n result = (result * 0x102C9A3E778060EE7) >> 64;\\n }\\n if (x & 0x200000000000000 > 0) {\\n result = (result * 0x10163DA9FB33356D8) >> 64;\\n }\\n if (x & 0x100000000000000 > 0) {\\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\\n }\\n }\\n\\n if (x & 0xFF000000000000 > 0) {\\n if (x & 0x80000000000000 > 0) {\\n result = (result * 0x10058C86DA1C09EA2) >> 64;\\n }\\n if (x & 0x40000000000000 > 0) {\\n result = (result * 0x1002C605E2E8CEC50) >> 64;\\n }\\n if (x & 0x20000000000000 > 0) {\\n result = (result * 0x100162F3904051FA1) >> 64;\\n }\\n if (x & 0x10000000000000 > 0) {\\n result = (result * 0x1000B175EFFDC76BA) >> 64;\\n }\\n if (x & 0x8000000000000 > 0) {\\n result = (result * 0x100058BA01FB9F96D) >> 64;\\n }\\n if (x & 0x4000000000000 > 0) {\\n result = (result * 0x10002C5CC37DA9492) >> 64;\\n }\\n if (x & 0x2000000000000 > 0) {\\n result = (result * 0x1000162E525EE0547) >> 64;\\n }\\n if (x & 0x1000000000000 > 0) {\\n result = (result * 0x10000B17255775C04) >> 64;\\n }\\n }\\n\\n if (x & 0xFF0000000000 > 0) {\\n if (x & 0x800000000000 > 0) {\\n result = (result * 0x1000058B91B5BC9AE) >> 64;\\n }\\n if (x & 0x400000000000 > 0) {\\n result = (result * 0x100002C5C89D5EC6D) >> 64;\\n }\\n if (x & 0x200000000000 > 0) {\\n result = (result * 0x10000162E43F4F831) >> 64;\\n }\\n if (x & 0x100000000000 > 0) {\\n result = (result * 0x100000B1721BCFC9A) >> 64;\\n }\\n if (x & 0x80000000000 > 0) {\\n result = (result * 0x10000058B90CF1E6E) >> 64;\\n }\\n if (x & 0x40000000000 > 0) {\\n result = (result * 0x1000002C5C863B73F) >> 64;\\n }\\n if (x & 0x20000000000 > 0) {\\n result = (result * 0x100000162E430E5A2) >> 64;\\n }\\n if (x & 0x10000000000 > 0) {\\n result = (result * 0x1000000B172183551) >> 64;\\n }\\n }\\n\\n if (x & 0xFF00000000 > 0) {\\n if (x & 0x8000000000 > 0) {\\n result = (result * 0x100000058B90C0B49) >> 64;\\n }\\n if (x & 0x4000000000 > 0) {\\n result = (result * 0x10000002C5C8601CC) >> 64;\\n }\\n if (x & 0x2000000000 > 0) {\\n result = (result * 0x1000000162E42FFF0) >> 64;\\n }\\n if (x & 0x1000000000 > 0) {\\n result = (result * 0x10000000B17217FBB) >> 64;\\n }\\n if (x & 0x800000000 > 0) {\\n result = (result * 0x1000000058B90BFCE) >> 64;\\n }\\n if (x & 0x400000000 > 0) {\\n result = (result * 0x100000002C5C85FE3) >> 64;\\n }\\n if (x & 0x200000000 > 0) {\\n result = (result * 0x10000000162E42FF1) >> 64;\\n }\\n if (x & 0x100000000 > 0) {\\n result = (result * 0x100000000B17217F8) >> 64;\\n }\\n }\\n\\n if (x & 0xFF000000 > 0) {\\n if (x & 0x80000000 > 0) {\\n result = (result * 0x10000000058B90BFC) >> 64;\\n }\\n if (x & 0x40000000 > 0) {\\n result = (result * 0x1000000002C5C85FE) >> 64;\\n }\\n if (x & 0x20000000 > 0) {\\n result = (result * 0x100000000162E42FF) >> 64;\\n }\\n if (x & 0x10000000 > 0) {\\n result = (result * 0x1000000000B17217F) >> 64;\\n }\\n if (x & 0x8000000 > 0) {\\n result = (result * 0x100000000058B90C0) >> 64;\\n }\\n if (x & 0x4000000 > 0) {\\n result = (result * 0x10000000002C5C860) >> 64;\\n }\\n if (x & 0x2000000 > 0) {\\n result = (result * 0x1000000000162E430) >> 64;\\n }\\n if (x & 0x1000000 > 0) {\\n result = (result * 0x10000000000B17218) >> 64;\\n }\\n }\\n\\n if (x & 0xFF0000 > 0) {\\n if (x & 0x800000 > 0) {\\n result = (result * 0x1000000000058B90C) >> 64;\\n }\\n if (x & 0x400000 > 0) {\\n result = (result * 0x100000000002C5C86) >> 64;\\n }\\n if (x & 0x200000 > 0) {\\n result = (result * 0x10000000000162E43) >> 64;\\n }\\n if (x & 0x100000 > 0) {\\n result = (result * 0x100000000000B1721) >> 64;\\n }\\n if (x & 0x80000 > 0) {\\n result = (result * 0x10000000000058B91) >> 64;\\n }\\n if (x & 0x40000 > 0) {\\n result = (result * 0x1000000000002C5C8) >> 64;\\n }\\n if (x & 0x20000 > 0) {\\n result = (result * 0x100000000000162E4) >> 64;\\n }\\n if (x & 0x10000 > 0) {\\n result = (result * 0x1000000000000B172) >> 64;\\n }\\n }\\n\\n if (x & 0xFF00 > 0) {\\n if (x & 0x8000 > 0) {\\n result = (result * 0x100000000000058B9) >> 64;\\n }\\n if (x & 0x4000 > 0) {\\n result = (result * 0x10000000000002C5D) >> 64;\\n }\\n if (x & 0x2000 > 0) {\\n result = (result * 0x1000000000000162E) >> 64;\\n }\\n if (x & 0x1000 > 0) {\\n result = (result * 0x10000000000000B17) >> 64;\\n }\\n if (x & 0x800 > 0) {\\n result = (result * 0x1000000000000058C) >> 64;\\n }\\n if (x & 0x400 > 0) {\\n result = (result * 0x100000000000002C6) >> 64;\\n }\\n if (x & 0x200 > 0) {\\n result = (result * 0x10000000000000163) >> 64;\\n }\\n if (x & 0x100 > 0) {\\n result = (result * 0x100000000000000B1) >> 64;\\n }\\n }\\n\\n if (x & 0xFF > 0) {\\n if (x & 0x80 > 0) {\\n result = (result * 0x10000000000000059) >> 64;\\n }\\n if (x & 0x40 > 0) {\\n result = (result * 0x1000000000000002C) >> 64;\\n }\\n if (x & 0x20 > 0) {\\n result = (result * 0x10000000000000016) >> 64;\\n }\\n if (x & 0x10 > 0) {\\n result = (result * 0x1000000000000000B) >> 64;\\n }\\n if (x & 0x8 > 0) {\\n result = (result * 0x10000000000000006) >> 64;\\n }\\n if (x & 0x4 > 0) {\\n result = (result * 0x10000000000000003) >> 64;\\n }\\n if (x & 0x2 > 0) {\\n result = (result * 0x10000000000000001) >> 64;\\n }\\n if (x & 0x1 > 0) {\\n result = (result * 0x10000000000000001) >> 64;\\n }\\n }\\n\\n // In the code snippet below, two operations are executed simultaneously:\\n //\\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\\n //\\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\\n // integer part, $2^n$.\\n result *= UNIT;\\n result >>= (191 - (x >> 64));\\n }\\n}\\n\\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\\n///\\n/// @dev See the note on \\\"msb\\\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\\n///\\n/// Each step in this implementation is equivalent to this high-level code:\\n///\\n/// ```solidity\\n/// if (x >= 2 ** 128) {\\n/// x >>= 128;\\n/// result += 128;\\n/// }\\n/// ```\\n///\\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\\n///\\n/// The Yul instructions used below are:\\n///\\n/// - \\\"gt\\\" is \\\"greater than\\\"\\n/// - \\\"or\\\" is the OR bitwise operator\\n/// - \\\"shl\\\" is \\\"shift left\\\"\\n/// - \\\"shr\\\" is \\\"shift right\\\"\\n///\\n/// @param x The uint256 number for which to find the index of the most significant bit.\\n/// @return result The index of the most significant bit as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction msb(uint256 x) pure returns (uint256 result) {\\n // 2^128\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^64\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^32\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(5, gt(x, 0xFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^16\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(4, gt(x, 0xFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^8\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(3, gt(x, 0xFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^4\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(2, gt(x, 0xF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^2\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(1, gt(x, 0x3))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^1\\n // No need to shift x any more.\\n assembly (\\\"memory-safe\\\") {\\n let factor := gt(x, 0x1)\\n result := or(result, factor)\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f7denominator with 512-bit precision.\\n///\\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - The denominator must not be zero.\\n/// - The result must fit in uint256.\\n///\\n/// @param x The multiplicand as a uint256.\\n/// @param y The multiplier as a uint256.\\n/// @param denominator The divisor as a uint256.\\n/// @return result The result as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly (\\\"memory-safe\\\") {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n unchecked {\\n return prod0 / denominator;\\n }\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n if (prod1 >= denominator) {\\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\\n }\\n\\n ////////////////////////////////////////////////////////////////////////////\\n // 512 by 256 division\\n ////////////////////////////////////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly (\\\"memory-safe\\\") {\\n // Compute remainder using the mulmod Yul instruction.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512-bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n unchecked {\\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\\n uint256 lpotdod = denominator & (~denominator + 1);\\n uint256 flippedLpotdod;\\n\\n assembly (\\\"memory-safe\\\") {\\n // Factor powers of two out of denominator.\\n denominator := div(denominator, lpotdod)\\n\\n // Divide [prod1 prod0] by lpotdod.\\n prod0 := div(prod0, lpotdod)\\n\\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * flippedLpotdod;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\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 works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\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^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f71e18 with 512-bit precision.\\n///\\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\\n///\\n/// Notes:\\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\\n/// - The result is rounded toward zero.\\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\\n///\\n/// $$\\n/// \\\\begin{cases}\\n/// x * y = MAX\\\\_UINT256 * UNIT \\\\\\\\\\n/// (x * y) \\\\% UNIT \\\\geq \\\\frac{UNIT}{2}\\n/// \\\\end{cases}\\n/// $$\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {mulDiv}.\\n/// - The result must fit in uint256.\\n///\\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\\n uint256 prod0;\\n uint256 prod1;\\n assembly (\\\"memory-safe\\\") {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n if (prod1 == 0) {\\n unchecked {\\n return prod0 / UNIT;\\n }\\n }\\n\\n if (prod1 >= UNIT) {\\n revert PRBMath_MulDiv18_Overflow(x, y);\\n }\\n\\n uint256 remainder;\\n assembly (\\\"memory-safe\\\") {\\n remainder := mulmod(x, y, UNIT)\\n result :=\\n mul(\\n or(\\n div(sub(prod0, remainder), UNIT_LPOTD),\\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\\n ),\\n UNIT_INVERSE\\n )\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f7denominator with 512-bit precision.\\n///\\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {mulDiv}.\\n/// - None of the inputs can be `type(int256).min`.\\n/// - The result must fit in int256.\\n///\\n/// @param x The multiplicand as an int256.\\n/// @param y The multiplier as an int256.\\n/// @param denominator The divisor as an int256.\\n/// @return result The result as an int256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\\n revert PRBMath_MulDivSigned_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x, y and the denominator.\\n uint256 xAbs;\\n uint256 yAbs;\\n uint256 dAbs;\\n unchecked {\\n xAbs = x < 0 ? uint256(-x) : uint256(x);\\n yAbs = y < 0 ? uint256(-y) : uint256(y);\\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\\n }\\n\\n // Compute the absolute value of x*y\\u00f7denominator. The result must fit in int256.\\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\\n if (resultAbs > uint256(type(int256).max)) {\\n revert PRBMath_MulDivSigned_Overflow(x, y);\\n }\\n\\n // Get the signs of x, y and the denominator.\\n uint256 sx;\\n uint256 sy;\\n uint256 sd;\\n assembly (\\\"memory-safe\\\") {\\n // \\\"sgt\\\" is the \\\"signed greater than\\\" assembly instruction and \\\"sub(0,1)\\\" is -1 in two's complement.\\n sx := sgt(x, sub(0, 1))\\n sy := sgt(y, sub(0, 1))\\n sd := sgt(denominator, sub(0, 1))\\n }\\n\\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\\n // If there are, the result should be negative. Otherwise, it should be positive.\\n unchecked {\\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\\n }\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - If x is not a perfect square, the result is rounded down.\\n/// - Credits to OpenZeppelin for the explanations in comments below.\\n///\\n/// @param x The uint256 number for which to calculate the square root.\\n/// @return result The result as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(uint256 x) pure returns (uint256 result) {\\n if (x == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of x is a power of 2 such that we have:\\n //\\n // $$\\n // msb(x) <= x <= 2*msb(x)$\\n // $$\\n //\\n // We write $msb(x)$ as $2^k$, and we get:\\n //\\n // $$\\n // k = log_2(x)\\n // $$\\n //\\n // Thus, we can write the initial inequality as:\\n //\\n // $$\\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\\\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\\\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\\n // $$\\n //\\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\\n uint256 xAux = uint256(x);\\n result = 1;\\n if (xAux >= 2 ** 128) {\\n xAux >>= 128;\\n result <<= 64;\\n }\\n if (xAux >= 2 ** 64) {\\n xAux >>= 64;\\n result <<= 32;\\n }\\n if (xAux >= 2 ** 32) {\\n xAux >>= 32;\\n result <<= 16;\\n }\\n if (xAux >= 2 ** 16) {\\n xAux >>= 16;\\n result <<= 8;\\n }\\n if (xAux >= 2 ** 8) {\\n xAux >>= 8;\\n result <<= 4;\\n }\\n if (xAux >= 2 ** 4) {\\n xAux >>= 4;\\n result <<= 2;\\n }\\n if (xAux >= 2 ** 2) {\\n result <<= 1;\\n }\\n\\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\\n // precision into the expected uint128 result.\\n unchecked {\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n\\n // If x is not a perfect square, round the result toward zero.\\n uint256 roundedResult = x / result;\\n if (result >= roundedResult) {\\n result = roundedResult;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaa374e2c26cc93e8c22a6953804ee05f811597ef5fa82f76824378b22944778b\",\"license\":\"MIT\"},\"@prb/math/src/UD2x18.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n/*\\n\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2588\\u2588\\u2554\\u2550\\u2550\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u2588\\u2588\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u255a\\u2550\\u255d \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\n\\n\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u255d\\n\\n*/\\n\\nimport \\\"./ud2x18/Casting.sol\\\";\\nimport \\\"./ud2x18/Constants.sol\\\";\\nimport \\\"./ud2x18/Errors.sol\\\";\\nimport \\\"./ud2x18/ValueType.sol\\\";\\n\",\"keccak256\":\"0xfb624e24cd8bb790fa08e7827819de85504a86e20e961fa4ad126c65b6d90641\",\"license\":\"MIT\"},\"@prb/math/src/UD60x18.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n/*\\n\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2588\\u2588\\u2554\\u2550\\u2550\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u2588\\u2588\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u255a\\u2550\\u255d \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\n\\n\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2588\\u2588\\u2588\\u2588\\u2557\\u255a\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551 \\u255a\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u255d \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u255d\\n\\n*/\\n\\nimport \\\"./ud60x18/Casting.sol\\\";\\nimport \\\"./ud60x18/Constants.sol\\\";\\nimport \\\"./ud60x18/Conversions.sol\\\";\\nimport \\\"./ud60x18/Errors.sol\\\";\\nimport \\\"./ud60x18/Helpers.sol\\\";\\nimport \\\"./ud60x18/Math.sol\\\";\\nimport \\\"./ud60x18/ValueType.sol\\\";\\n\",\"keccak256\":\"0xb98c6f74275914d279e8af6c502c2b1f50d5f6e1ed418d3b0153f5a193206c48\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts an SD1x18 number into SD59x18.\\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\\n}\\n\\n/// @notice Casts an SD1x18 number into UD2x18.\\n/// - x must be positive.\\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\\n }\\n result = UD2x18.wrap(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into UD60x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\\n }\\n result = UD60x18.wrap(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint256.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\\n }\\n result = uint256(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\\n }\\n result = uint128(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\\n }\\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\\n }\\n result = uint40(uint64(xInt));\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\\n result = SD1x18.wrap(x);\\n}\\n\\n/// @notice Unwraps an SD1x18 number into int64.\\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\\n result = SD1x18.unwrap(x);\\n}\\n\\n/// @notice Wraps an int64 number into SD1x18.\\nfunction wrap(int64 x) pure returns (SD1x18 result) {\\n result = SD1x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x9e49e2b37c1bb845861740805edaaef3fe951a7b96eef16ce84fbf76e8278670\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @dev Euler's number as an SD1x18 number.\\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum value an SD1x18 number can have.\\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\\n\\n/// @dev The maximum value an SD1x18 number can have.\\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\\n\\n/// @dev PI as an SD1x18 number.\\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of SD1x18.\\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\\nint64 constant uUNIT = 1e18;\\n\",\"keccak256\":\"0x6496165b80552785a4b65a239b96e2a5fedf62fe54f002eeed72d75e566d7585\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\\n\",\"keccak256\":\"0x836cb42ba619ca369fd4765bc47fefc3c3621369c5861882af14660aca5057ee\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\n\\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\\n/// storage.\\ntype SD1x18 is int64;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD59x18,\\n Casting.intoUD2x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for SD1x18 global;\\n\",\"keccak256\":\"0x2f86f1aa9fca42f40808b51a879b406ac51817647bdb9642f8a79dd8fdb754a7\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { MAX_UINT128, MAX_UINT40 } from \\\"../Common.sol\\\";\\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { uMAX_UD2x18 } from \\\"../ud2x18/Constants.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts an SD59x18 number into int256.\\n/// @dev This is basically a functional alias for {unwrap}.\\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\\n result = SD59x18.unwrap(x);\\n}\\n\\n/// @notice Casts an SD59x18 number into SD1x18.\\n/// @dev Requirements:\\n/// - x must be greater than or equal to `uMIN_SD1x18`.\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < uMIN_SD1x18) {\\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\\n }\\n if (xInt > uMAX_SD1x18) {\\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into UD2x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `uMAX_UD2x18`.\\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\\n }\\n if (xInt > int256(uint256(uMAX_UD2x18))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\\n }\\n result = UD2x18.wrap(uint64(uint256(xInt)));\\n}\\n\\n/// @notice Casts an SD59x18 number into UD60x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\\n }\\n result = UD60x18.wrap(uint256(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into uint256.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\\n }\\n result = uint256(xInt);\\n}\\n\\n/// @notice Casts an SD59x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `uMAX_UINT128`.\\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\\n }\\n if (xInt > int256(uint256(MAX_UINT128))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\\n }\\n result = uint128(uint256(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\\n }\\n if (xInt > int256(uint256(MAX_UINT40))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(uint256(xInt));\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\\n/// @notice Unwraps an SD59x18 number into int256.\\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\\n result = SD59x18.unwrap(x);\\n}\\n\\n/// @notice Wraps an int256 number into SD59x18.\\nfunction wrap(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x3b21b60ec2998c3ae32f647412da51d3683b3f183a807198cc8d157499484f99\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n// NOTICE: the \\\"u\\\" prefix stands for \\\"unwrapped\\\".\\n\\n/// @dev Euler's number as an SD59x18 number.\\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum input permitted in {exp}.\\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\\n\\n/// @dev Any value less than this returns 0 in {exp}.\\nint256 constant uEXP_MIN_THRESHOLD = -41_446531673892822322;\\nSD59x18 constant EXP_MIN_THRESHOLD = SD59x18.wrap(uEXP_MIN_THRESHOLD);\\n\\n/// @dev The maximum input permitted in {exp2}.\\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\\n\\n/// @dev Any value less than this returns 0 in {exp2}.\\nint256 constant uEXP2_MIN_THRESHOLD = -59_794705707972522261;\\nSD59x18 constant EXP2_MIN_THRESHOLD = SD59x18.wrap(uEXP2_MIN_THRESHOLD);\\n\\n/// @dev Half the UNIT number.\\nint256 constant uHALF_UNIT = 0.5e18;\\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\\n\\n/// @dev $log_2(10)$ as an SD59x18 number.\\nint256 constant uLOG2_10 = 3_321928094887362347;\\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\\n\\n/// @dev $log_2(e)$ as an SD59x18 number.\\nint256 constant uLOG2_E = 1_442695040888963407;\\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\\n\\n/// @dev The maximum value an SD59x18 number can have.\\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\\n\\n/// @dev The maximum whole value an SD59x18 number can have.\\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\\n\\n/// @dev The minimum value an SD59x18 number can have.\\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\\n\\n/// @dev The minimum whole value an SD59x18 number can have.\\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\\n\\n/// @dev PI as an SD59x18 number.\\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of SD59x18.\\nint256 constant uUNIT = 1e18;\\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\\n\\n/// @dev The unit number squared.\\nint256 constant uUNIT_SQUARED = 1e36;\\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\\n\\n/// @dev Zero as an SD59x18 number.\\nSD59x18 constant ZERO = SD59x18.wrap(0);\\n\",\"keccak256\":\"0x9bcb8dd6b3e886d140ad1c32747a4f6d29a492529ceb835be878ae837aa6cc3a\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Abs_MinSD59x18();\\n\\n/// @notice Thrown when ceiling a number overflows SD59x18.\\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\\n\\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Div_InputTooSmall();\\n\\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\\n\\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\\n\\n/// @notice Thrown when flooring a number underflows SD59x18.\\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\\n\\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Mul_InputTooSmall();\\n\\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\\n\\n/// @notice Thrown when taking the square root of a negative number.\\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\\n\\n/// @notice Thrown when the calculating the square root overflows SD59x18.\\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\\n\",\"keccak256\":\"0xa6d00fe5efa215ac0df25c896e3da99a12fb61e799644b2ec32da947313d3db4\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() + y.unwrap());\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() & bits);\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() & y.unwrap());\\n}\\n\\n/// @notice Implements the equal (=) operation in the SD59x18 type.\\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() == y.unwrap();\\n}\\n\\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() > y.unwrap();\\n}\\n\\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() >= y.unwrap();\\n}\\n\\n/// @notice Implements a zero comparison check function in the SD59x18 type.\\nfunction isZero(SD59x18 x) pure returns (bool result) {\\n result = x.unwrap() == 0;\\n}\\n\\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() << bits);\\n}\\n\\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() < y.unwrap();\\n}\\n\\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() <= y.unwrap();\\n}\\n\\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() % y.unwrap());\\n}\\n\\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() != y.unwrap();\\n}\\n\\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(~x.unwrap());\\n}\\n\\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() | y.unwrap());\\n}\\n\\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() >> bits);\\n}\\n\\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() - y.unwrap());\\n}\\n\\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(-x.unwrap());\\n}\\n\\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() + y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() - y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(-x.unwrap());\\n }\\n}\\n\\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() ^ y.unwrap());\\n}\\n\",\"keccak256\":\"0x208570f1657cf730cb6c3d81aa14030e0d45cf906cdedea5059369d7df4bb716\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport {\\n uEXP_MAX_INPUT,\\n uEXP2_MAX_INPUT,\\n uEXP_MIN_THRESHOLD,\\n uEXP2_MIN_THRESHOLD,\\n uHALF_UNIT,\\n uLOG2_10,\\n uLOG2_E,\\n uMAX_SD59x18,\\n uMAX_WHOLE_SD59x18,\\n uMIN_SD59x18,\\n uMIN_WHOLE_SD59x18,\\n UNIT,\\n uUNIT,\\n uUNIT_SQUARED,\\n ZERO\\n} from \\\"./Constants.sol\\\";\\nimport { wrap } from \\\"./Helpers.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Calculates the absolute value of x.\\n///\\n/// @dev Requirements:\\n/// - x must be greater than `MIN_SD59x18`.\\n///\\n/// @param x The SD59x18 number for which to calculate the absolute value.\\n/// @param result The absolute value of x as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\\n }\\n result = xInt < 0 ? wrap(-xInt) : x;\\n}\\n\\n/// @notice Calculates the arithmetic average of x and y.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// @param x The first operand as an SD59x18 number.\\n/// @param y The second operand as an SD59x18 number.\\n/// @return result The arithmetic average as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n\\n unchecked {\\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\\n int256 sum = (xInt >> 1) + (yInt >> 1);\\n\\n if (sum < 0) {\\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\\n assembly (\\\"memory-safe\\\") {\\n result := add(sum, and(or(xInt, yInt), 1))\\n }\\n } else {\\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\\n result = wrap(sum + (xInt & yInt & 1));\\n }\\n }\\n}\\n\\n/// @notice Yields the smallest whole number greater than or equal to x.\\n///\\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\\n///\\n/// @param x The SD59x18 number to ceil.\\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt > uMAX_WHOLE_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\\n }\\n\\n int256 remainder = xInt % uUNIT;\\n if (remainder == 0) {\\n result = x;\\n } else {\\n unchecked {\\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\\n int256 resultInt = xInt - remainder;\\n if (xInt > 0) {\\n resultInt += uUNIT;\\n }\\n result = wrap(resultInt);\\n }\\n }\\n}\\n\\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\\n///\\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\\n/// values separately.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n/// - None of the inputs can be `MIN_SD59x18`.\\n/// - The denominator must not be zero.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The numerator as an SD59x18 number.\\n/// @param y The denominator as an SD59x18 number.\\n/// @param result The quotient as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x and y.\\n uint256 xAbs;\\n uint256 yAbs;\\n unchecked {\\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\\n }\\n\\n // Compute the absolute value (x*UNIT\\u00f7y). The resulting value must fit in SD59x18.\\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\\n }\\n\\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\\n // negative, 0 for positive or zero).\\n bool sameSign = (xInt ^ yInt) > -1;\\n\\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\\n unchecked {\\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\\n }\\n}\\n\\n/// @notice Calculates the natural exponent of x using the following formula:\\n///\\n/// $$\\n/// e^x = 2^{x * log_2{e}}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {exp2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}.\\n/// - x must be less than 133_084258667509499441.\\n///\\n/// @param x The exponent as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n\\n // Any input less than the threshold returns zero.\\n // This check also prevents an overflow for very small numbers.\\n if (xInt < uEXP_MIN_THRESHOLD) {\\n return ZERO;\\n }\\n\\n // This check prevents values greater than 192e18 from being passed to {exp2}.\\n if (xInt > uEXP_MAX_INPUT) {\\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Inline the fixed-point multiplication to save gas.\\n int256 doubleUnitProduct = xInt * uLOG2_E;\\n result = exp2(wrap(doubleUnitProduct / uUNIT));\\n }\\n}\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\\n///\\n/// $$\\n/// 2^{-x} = \\\\frac{1}{2^x}\\n/// $$\\n///\\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\\n///\\n/// Notes:\\n/// - If x is less than -59_794705707972522261, the result is zero.\\n///\\n/// Requirements:\\n/// - x must be less than 192e18.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The exponent as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n // The inverse of any number less than the threshold is truncated to zero.\\n if (xInt < uEXP2_MIN_THRESHOLD) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Inline the fixed-point inversion to save gas.\\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\\n }\\n } else {\\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\\n if (xInt > uEXP2_MAX_INPUT) {\\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Convert x to the 192.64-bit fixed-point format.\\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\\n\\n // It is safe to cast the result to int256 due to the checks above.\\n result = wrap(int256(Common.exp2(x_192x64)));\\n }\\n }\\n}\\n\\n/// @notice Yields the greatest whole number less than or equal to x.\\n///\\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\\n///\\n/// @param x The SD59x18 number to floor.\\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < uMIN_WHOLE_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\\n }\\n\\n int256 remainder = xInt % uUNIT;\\n if (remainder == 0) {\\n result = x;\\n } else {\\n unchecked {\\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\\n int256 resultInt = xInt - remainder;\\n if (xInt < 0) {\\n resultInt -= uUNIT;\\n }\\n result = wrap(resultInt);\\n }\\n }\\n}\\n\\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\\n/// of the radix point for negative numbers.\\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\\n/// @param x The SD59x18 number to get the fractional part of.\\n/// @param result The fractional part of x as an SD59x18 number.\\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() % uUNIT);\\n}\\n\\n/// @notice Calculates the geometric mean of x and y, i.e. $\\\\sqrt{x * y}$.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x * y must fit in SD59x18.\\n/// - x * y must not be negative, since complex numbers are not supported.\\n///\\n/// @param x The first operand as an SD59x18 number.\\n/// @param y The second operand as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == 0 || yInt == 0) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\\n int256 xyInt = xInt * yInt;\\n if (xyInt / xInt != yInt) {\\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\\n }\\n\\n // The product must not be negative, since complex numbers are not supported.\\n if (xyInt < 0) {\\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\\n }\\n\\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\\n // during multiplication. See the comments in {Common.sqrt}.\\n uint256 resultUint = Common.sqrt(uint256(xyInt));\\n result = wrap(int256(resultUint));\\n }\\n}\\n\\n/// @notice Calculates the inverse of x.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must not be zero.\\n///\\n/// @param x The SD59x18 number for which to calculate the inverse.\\n/// @return result The inverse as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(uUNIT_SQUARED / x.unwrap());\\n}\\n\\n/// @notice Calculates the natural logarithm of x using the following formula:\\n///\\n/// $$\\n/// ln{x} = log_2{x} / log_2{e}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\\n/// @return result The natural logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\\n // {log2} can return is ~195_205294292027477728.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\\n}\\n\\n/// @notice Calculates the common logarithm of x using the following formula:\\n///\\n/// $$\\n/// log_{10}{x} = log_2{x} / log_2{10}\\n/// $$\\n///\\n/// However, if x is an exact power of ten, a hard coded value is returned.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The SD59x18 number for which to calculate the common logarithm.\\n/// @return result The common logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\\n }\\n\\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\\n // prettier-ignore\\n assembly (\\\"memory-safe\\\") {\\n switch x\\n case 1 { result := mul(uUNIT, sub(0, 18)) }\\n case 10 { result := mul(uUNIT, sub(1, 18)) }\\n case 100 { result := mul(uUNIT, sub(2, 18)) }\\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\\n case 1000000000000000000 { result := 0 }\\n case 10000000000000000000 { result := uUNIT }\\n case 100000000000000000000 { result := mul(uUNIT, 2) }\\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\\n default { result := uMAX_SD59x18 }\\n }\\n\\n if (result.unwrap() == uMAX_SD59x18) {\\n unchecked {\\n // Inline the fixed-point division to save gas.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\\n }\\n }\\n}\\n\\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\\n///\\n/// $$\\n/// log_2{x} = n + log_2{y}, \\\\text{ where } y = x*2^{-n}, \\\\ y \\\\in [1, 2)\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, the input is inverted:\\n///\\n/// $$\\n/// log_2{x} = -log_2{\\\\frac{1}{x}}\\n/// $$\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\\n///\\n/// Notes:\\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\\n///\\n/// Requirements:\\n/// - x must be greater than zero.\\n///\\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\\n/// @return result The binary logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt <= 0) {\\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\\n }\\n\\n unchecked {\\n int256 sign;\\n if (xInt >= uUNIT) {\\n sign = 1;\\n } else {\\n sign = -1;\\n // Inline the fixed-point inversion to save gas.\\n xInt = uUNIT_SQUARED / xInt;\\n }\\n\\n // Calculate the integer part of the logarithm.\\n uint256 n = Common.msb(uint256(xInt / uUNIT));\\n\\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\\n int256 resultInt = int256(n) * uUNIT;\\n\\n // Calculate $y = x * 2^{-n}$.\\n int256 y = xInt >> n;\\n\\n // If y is the unit number, the fractional part is zero.\\n if (y == uUNIT) {\\n return wrap(resultInt * sign);\\n }\\n\\n // Calculate the fractional part via the iterative approximation.\\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\\n int256 DOUBLE_UNIT = 2e18;\\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\\n y = (y * y) / uUNIT;\\n\\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\\n if (y >= DOUBLE_UNIT) {\\n // Add the 2^{-m} factor to the logarithm.\\n resultInt = resultInt + delta;\\n\\n // Halve y, which corresponds to z/2 in the Wikipedia article.\\n y >>= 1;\\n }\\n }\\n resultInt *= sign;\\n result = wrap(resultInt);\\n }\\n}\\n\\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv18}.\\n/// - None of the inputs can be `MIN_SD59x18`.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The multiplicand as an SD59x18 number.\\n/// @param y The multiplier as an SD59x18 number.\\n/// @return result The product as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x and y.\\n uint256 xAbs;\\n uint256 yAbs;\\n unchecked {\\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\\n }\\n\\n // Compute the absolute value (x*y\\u00f7UNIT). The resulting value must fit in SD59x18.\\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\\n }\\n\\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\\n // negative, 0 for positive or zero).\\n bool sameSign = (xInt ^ yInt) > -1;\\n\\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\\n unchecked {\\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\\n }\\n}\\n\\n/// @notice Raises x to the power of y using the following formula:\\n///\\n/// $$\\n/// x^y = 2^{log_2{x} * y}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\\n///\\n/// @param x The base as an SD59x18 number.\\n/// @param y Exponent to raise x to, as an SD59x18 number\\n/// @return result x raised to power y, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n\\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\\n if (xInt == 0) {\\n return yInt == 0 ? UNIT : ZERO;\\n }\\n // If x is `UNIT`, the result is always `UNIT`.\\n else if (xInt == uUNIT) {\\n return UNIT;\\n }\\n\\n // If y is zero, the result is always `UNIT`.\\n if (yInt == 0) {\\n return UNIT;\\n }\\n // If y is `UNIT`, the result is always x.\\n else if (yInt == uUNIT) {\\n return x;\\n }\\n\\n // Calculate the result using the formula.\\n result = exp2(mul(log2(x), y));\\n}\\n\\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\\n/// algorithm \\\"exponentiation by squaring\\\".\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The base as an SD59x18 number.\\n/// @param y The exponent as a uint256.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\\n uint256 xAbs = uint256(abs(x).unwrap());\\n\\n // Calculate the first iteration of the loop in advance.\\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\\n\\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\\n uint256 yAux = y;\\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\\n xAbs = Common.mulDiv18(xAbs, xAbs);\\n\\n // Equivalent to `y % 2 == 1`.\\n if (yAux & 1 > 0) {\\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\\n }\\n }\\n\\n // The result must fit in SD59x18.\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\\n }\\n\\n unchecked {\\n // Is the base negative and the exponent odd? If yes, the result should be negative.\\n int256 resultInt = int256(resultAbs);\\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\\n if (isNegative) {\\n resultInt = -resultInt;\\n }\\n result = wrap(resultInt);\\n }\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - Only the positive root is returned.\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x cannot be negative, since complex numbers are not supported.\\n/// - x must be less than `MAX_SD59x18 / UNIT`.\\n///\\n/// @param x The SD59x18 number for which to calculate the square root.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\\n }\\n if (xInt > uMAX_SD59x18 / uUNIT) {\\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\\n }\\n\\n unchecked {\\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\\n // In this case, the two numbers are both the square root.\\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\\n result = wrap(int256(resultUint));\\n }\\n}\\n\",\"keccak256\":\"0xa074831139fc89ca0e5a36086b30eb50896bb6770cd5823461b1f2769017d2f0\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\nimport \\\"./Helpers.sol\\\" as Helpers;\\nimport \\\"./Math.sol\\\" as Math;\\n\\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type int256.\\ntype SD59x18 is int256;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoInt256,\\n Casting.intoSD1x18,\\n Casting.intoUD2x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Math.abs,\\n Math.avg,\\n Math.ceil,\\n Math.div,\\n Math.exp,\\n Math.exp2,\\n Math.floor,\\n Math.frac,\\n Math.gm,\\n Math.inv,\\n Math.log10,\\n Math.log2,\\n Math.ln,\\n Math.mul,\\n Math.pow,\\n Math.powu,\\n Math.sqrt\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n HELPER FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Helpers.add,\\n Helpers.and,\\n Helpers.eq,\\n Helpers.gt,\\n Helpers.gte,\\n Helpers.isZero,\\n Helpers.lshift,\\n Helpers.lt,\\n Helpers.lte,\\n Helpers.mod,\\n Helpers.neq,\\n Helpers.not,\\n Helpers.or,\\n Helpers.rshift,\\n Helpers.sub,\\n Helpers.uncheckedAdd,\\n Helpers.uncheckedSub,\\n Helpers.uncheckedUnary,\\n Helpers.xor\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n OPERATORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes it possible to use these operators on the SD59x18 type.\\nusing {\\n Helpers.add as +,\\n Helpers.and2 as &,\\n Math.div as /,\\n Helpers.eq as ==,\\n Helpers.gt as >,\\n Helpers.gte as >=,\\n Helpers.lt as <,\\n Helpers.lte as <=,\\n Helpers.mod as %,\\n Math.mul as *,\\n Helpers.neq as !=,\\n Helpers.not as ~,\\n Helpers.or as |,\\n Helpers.sub as -,\\n Helpers.unary as -,\\n Helpers.xor as ^\\n} for SD59x18 global;\\n\",\"keccak256\":\"0xe03112d145dcd5863aff24e5f381debaae29d446acd5666f3d640e3d9af738d7\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport { uMAX_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts a UD2x18 number into SD1x18.\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\\n uint64 xUint = UD2x18.unwrap(x);\\n if (xUint > uint64(uMAX_SD1x18)) {\\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(xUint));\\n}\\n\\n/// @notice Casts a UD2x18 number into SD59x18.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\\n}\\n\\n/// @notice Casts a UD2x18 number into UD60x18.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint128.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\\n result = uint128(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint256.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\\n result = uint256(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\\n uint64 xUint = UD2x18.unwrap(x);\\n if (xUint > uint64(Common.MAX_UINT40)) {\\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(xUint);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\\n result = UD2x18.wrap(x);\\n}\\n\\n/// @notice Unwrap a UD2x18 number into uint64.\\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\\n result = UD2x18.unwrap(x);\\n}\\n\\n/// @notice Wraps a uint64 number into UD2x18.\\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\\n result = UD2x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x9b1a35d432ef951a415fae8098b3c609a99b630a3d5464b3c8e1efa8893eea07\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @dev Euler's number as a UD2x18 number.\\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum value a UD2x18 number can have.\\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\\n\\n/// @dev PI as a UD2x18 number.\\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of UD2x18.\\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\\nuint64 constant uUNIT = 1e18;\\n\",\"keccak256\":\"0x29b0e050c865899e1fb9022b460a7829cdee248c44c4299f068ba80695eec3fc\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\\n\\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\\n\",\"keccak256\":\"0xdf1e22f0b4c8032bcc8b7f63fe3984e1387f3dc7b2e9ab381822249f75376d33\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\n\\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\\n/// storage.\\ntype UD2x18 is uint64;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD1x18,\\n Casting.intoSD59x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for UD2x18 global;\\n\",\"keccak256\":\"0x2802edc9869db116a0b5c490cc5f8554742f747183fa30ac5e9c80bb967e61a1\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { MAX_UINT128, MAX_UINT40 } from \\\"../Common.sol\\\";\\nimport { uMAX_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { uMAX_SD59x18 } from \\\"../sd59x18/Constants.sol\\\";\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { uMAX_UD2x18 } from \\\"../ud2x18/Constants.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts a UD60x18 number into SD1x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uint256(int256(uMAX_SD1x18))) {\\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(uint64(xUint)));\\n}\\n\\n/// @notice Casts a UD60x18 number into UD2x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_UD2x18`.\\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uMAX_UD2x18) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\\n }\\n result = UD2x18.wrap(uint64(xUint));\\n}\\n\\n/// @notice Casts a UD60x18 number into SD59x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_SD59x18`.\\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uint256(uMAX_SD59x18)) {\\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\\n }\\n result = SD59x18.wrap(int256(xUint));\\n}\\n\\n/// @notice Casts a UD60x18 number into uint128.\\n/// @dev This is basically an alias for {unwrap}.\\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x);\\n}\\n\\n/// @notice Casts a UD60x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT128`.\\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > MAX_UINT128) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\\n }\\n result = uint128(xUint);\\n}\\n\\n/// @notice Casts a UD60x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > MAX_UINT40) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(xUint);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\\n/// @notice Unwraps a UD60x18 number into uint256.\\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x);\\n}\\n\\n/// @notice Wraps a uint256 number into the UD60x18 value type.\\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x5bb532da36921cbdac64d1f16de5d366ef1f664502e3b7c07d0ad06917551f85\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n// NOTICE: the \\\"u\\\" prefix stands for \\\"unwrapped\\\".\\n\\n/// @dev Euler's number as a UD60x18 number.\\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum input permitted in {exp}.\\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\\n\\n/// @dev The maximum input permitted in {exp2}.\\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\\n\\n/// @dev Half the UNIT number.\\nuint256 constant uHALF_UNIT = 0.5e18;\\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\\n\\n/// @dev $log_2(10)$ as a UD60x18 number.\\nuint256 constant uLOG2_10 = 3_321928094887362347;\\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\\n\\n/// @dev $log_2(e)$ as a UD60x18 number.\\nuint256 constant uLOG2_E = 1_442695040888963407;\\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\\n\\n/// @dev The maximum value a UD60x18 number can have.\\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\\n\\n/// @dev The maximum whole value a UD60x18 number can have.\\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\\n\\n/// @dev PI as a UD60x18 number.\\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of UD60x18.\\nuint256 constant uUNIT = 1e18;\\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\\n\\n/// @dev The unit number squared.\\nuint256 constant uUNIT_SQUARED = 1e36;\\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\\n\\n/// @dev Zero as a UD60x18 number.\\nUD60x18 constant ZERO = UD60x18.wrap(0);\\n\",\"keccak256\":\"0x2b80d26153d3fdcfb3a9ca772d9309d31ed1275f5b8b54c3ffb54d3652b37d90\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Conversions.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { uMAX_UD60x18, uUNIT } from \\\"./Constants.sol\\\";\\nimport { PRBMath_UD60x18_Convert_Overflow } from \\\"./Errors.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\\n/// @dev The result is rounded toward zero.\\n/// @param x The UD60x18 number to convert.\\n/// @return result The same number in basic integer form.\\nfunction convert(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x) / uUNIT;\\n}\\n\\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\\n///\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\\n///\\n/// @param x The basic integer to convert.\\n/// @param result The same number converted to UD60x18.\\nfunction convert(uint256 x) pure returns (UD60x18 result) {\\n if (x > uMAX_UD60x18 / uUNIT) {\\n revert PRBMath_UD60x18_Convert_Overflow(x);\\n }\\n unchecked {\\n result = UD60x18.wrap(x * uUNIT);\\n }\\n}\\n\",\"keccak256\":\"0xaf7fc2523413822de3b66ba339fe2884fb3b8c6f6cf38ec90a2c3e3aae71df6b\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when ceiling a number overflows UD60x18.\\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\\n\\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\\n\\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when taking the logarithm of a number less than 1.\\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\\n\\n/// @notice Thrown when calculating the square root overflows UD60x18.\\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\\n\",\"keccak256\":\"0xa8c60d4066248df22c49c882873efbc017344107edabc48c52209abbc39cb1e3\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() + y.unwrap());\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() & bits);\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() & y.unwrap());\\n}\\n\\n/// @notice Implements the equal operation (==) in the UD60x18 type.\\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() == y.unwrap();\\n}\\n\\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() > y.unwrap();\\n}\\n\\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() >= y.unwrap();\\n}\\n\\n/// @notice Implements a zero comparison check function in the UD60x18 type.\\nfunction isZero(UD60x18 x) pure returns (bool result) {\\n // This wouldn't work if x could be negative.\\n result = x.unwrap() == 0;\\n}\\n\\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() << bits);\\n}\\n\\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() < y.unwrap();\\n}\\n\\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() <= y.unwrap();\\n}\\n\\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() % y.unwrap());\\n}\\n\\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() != y.unwrap();\\n}\\n\\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\\n result = wrap(~x.unwrap());\\n}\\n\\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() | y.unwrap());\\n}\\n\\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() >> bits);\\n}\\n\\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() - y.unwrap());\\n}\\n\\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() + y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() - y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() ^ y.unwrap());\\n}\\n\",\"keccak256\":\"0xf5faff881391d2c060029499a666cc5f0bea90a213150bb476fae8f02a5df268\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport {\\n uEXP_MAX_INPUT,\\n uEXP2_MAX_INPUT,\\n uHALF_UNIT,\\n uLOG2_10,\\n uLOG2_E,\\n uMAX_UD60x18,\\n uMAX_WHOLE_UD60x18,\\n UNIT,\\n uUNIT,\\n uUNIT_SQUARED,\\n ZERO\\n} from \\\"./Constants.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Calculates the arithmetic average of x and y using the following formula:\\n///\\n/// $$\\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\\n/// $$\\n///\\n/// In English, this is what this formula does:\\n///\\n/// 1. AND x and y.\\n/// 2. Calculate half of XOR x and y.\\n/// 3. Add the two results together.\\n///\\n/// This technique is known as SWAR, which stands for \\\"SIMD within a register\\\". You can read more about it here:\\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// @param x The first operand as a UD60x18 number.\\n/// @param y The second operand as a UD60x18 number.\\n/// @return result The arithmetic average as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n unchecked {\\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\\n }\\n}\\n\\n/// @notice Yields the smallest whole number greater than or equal to x.\\n///\\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\\n///\\n/// @param x The UD60x18 number to ceil.\\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n if (xUint > uMAX_WHOLE_UD60x18) {\\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\\n }\\n\\n assembly (\\\"memory-safe\\\") {\\n // Equivalent to `x % UNIT`.\\n let remainder := mod(x, uUNIT)\\n\\n // Equivalent to `UNIT - remainder`.\\n let delta := sub(uUNIT, remainder)\\n\\n // Equivalent to `x + remainder > 0 ? delta : 0`.\\n result := add(x, mul(delta, gt(remainder, 0)))\\n }\\n}\\n\\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\\n///\\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n///\\n/// @param x The numerator as a UD60x18 number.\\n/// @param y The denominator as a UD60x18 number.\\n/// @param result The quotient as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\\n}\\n\\n/// @notice Calculates the natural exponent of x using the following formula:\\n///\\n/// $$\\n/// e^x = 2^{x * log_2{e}}\\n/// $$\\n///\\n/// @dev Requirements:\\n/// - x must be less than 133_084258667509499441.\\n///\\n/// @param x The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n // This check prevents values greater than 192e18 from being passed to {exp2}.\\n if (xUint > uEXP_MAX_INPUT) {\\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Inline the fixed-point multiplication to save gas.\\n uint256 doubleUnitProduct = xUint * uLOG2_E;\\n result = exp2(wrap(doubleUnitProduct / uUNIT));\\n }\\n}\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method.\\n///\\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\\n///\\n/// Requirements:\\n/// - x must be less than 192e18.\\n/// - The result must fit in UD60x18.\\n///\\n/// @param x The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\\n if (xUint > uEXP2_MAX_INPUT) {\\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\\n }\\n\\n // Convert x to the 192.64-bit fixed-point format.\\n uint256 x_192x64 = (xUint << 64) / uUNIT;\\n\\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\\n result = wrap(Common.exp2(x_192x64));\\n}\\n\\n/// @notice Yields the greatest whole number less than or equal to x.\\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n/// @param x The UD60x18 number to floor.\\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\\n assembly (\\\"memory-safe\\\") {\\n // Equivalent to `x % UNIT`.\\n let remainder := mod(x, uUNIT)\\n\\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\\n result := sub(x, mul(remainder, gt(remainder, 0)))\\n }\\n}\\n\\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\\n/// @param x The UD60x18 number to get the fractional part of.\\n/// @param result The fractional part of x as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\\n assembly (\\\"memory-safe\\\") {\\n result := mod(x, uUNIT)\\n }\\n}\\n\\n/// @notice Calculates the geometric mean of x and y, i.e. $\\\\sqrt{x * y}$, rounding down.\\n///\\n/// @dev Requirements:\\n/// - x * y must fit in UD60x18.\\n///\\n/// @param x The first operand as a UD60x18 number.\\n/// @param y The second operand as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n if (xUint == 0 || yUint == 0) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Checking for overflow this way is faster than letting Solidity do it.\\n uint256 xyUint = xUint * yUint;\\n if (xyUint / xUint != yUint) {\\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\\n }\\n\\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\\n // during multiplication. See the comments in {Common.sqrt}.\\n result = wrap(Common.sqrt(xyUint));\\n }\\n}\\n\\n/// @notice Calculates the inverse of x.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must not be zero.\\n///\\n/// @param x The UD60x18 number for which to calculate the inverse.\\n/// @return result The inverse as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(uUNIT_SQUARED / x.unwrap());\\n }\\n}\\n\\n/// @notice Calculates the natural logarithm of x using the following formula:\\n///\\n/// $$\\n/// ln{x} = log_2{x} / log_2{e}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\\n/// @return result The natural logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\\n unchecked {\\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\\n // {log2} can return is ~196_205294292027477728.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\\n }\\n}\\n\\n/// @notice Calculates the common logarithm of x using the following formula:\\n///\\n/// $$\\n/// log_{10}{x} = log_2{x} / log_2{10}\\n/// $$\\n///\\n/// However, if x is an exact power of ten, a hard coded value is returned.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The UD60x18 number for which to calculate the common logarithm.\\n/// @return result The common logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n if (xUint < uUNIT) {\\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\\n }\\n\\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\\n // prettier-ignore\\n assembly (\\\"memory-safe\\\") {\\n switch x\\n case 1 { result := mul(uUNIT, sub(0, 18)) }\\n case 10 { result := mul(uUNIT, sub(1, 18)) }\\n case 100 { result := mul(uUNIT, sub(2, 18)) }\\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\\n case 1000000000000000000 { result := 0 }\\n case 10000000000000000000 { result := uUNIT }\\n case 100000000000000000000 { result := mul(uUNIT, 2) }\\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\\n default { result := uMAX_UD60x18 }\\n }\\n\\n if (result.unwrap() == uMAX_UD60x18) {\\n unchecked {\\n // Inline the fixed-point division to save gas.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\\n }\\n }\\n}\\n\\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\\n///\\n/// $$\\n/// log_2{x} = n + log_2{y}, \\\\text{ where } y = x*2^{-n}, \\\\ y \\\\in [1, 2)\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, the input is inverted:\\n///\\n/// $$\\n/// log_2{x} = -log_2{\\\\frac{1}{x}}\\n/// $$\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\\n///\\n/// Notes:\\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\\n///\\n/// Requirements:\\n/// - x must be greater than zero.\\n///\\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\\n/// @return result The binary logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n if (xUint < uUNIT) {\\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\\n }\\n\\n unchecked {\\n // Calculate the integer part of the logarithm.\\n uint256 n = Common.msb(xUint / uUNIT);\\n\\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\\n // n is at most 255 and UNIT is 1e18.\\n uint256 resultUint = n * uUNIT;\\n\\n // Calculate $y = x * 2^{-n}$.\\n uint256 y = xUint >> n;\\n\\n // If y is the unit number, the fractional part is zero.\\n if (y == uUNIT) {\\n return wrap(resultUint);\\n }\\n\\n // Calculate the fractional part via the iterative approximation.\\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\\n uint256 DOUBLE_UNIT = 2e18;\\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\\n y = (y * y) / uUNIT;\\n\\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\\n if (y >= DOUBLE_UNIT) {\\n // Add the 2^{-m} factor to the logarithm.\\n resultUint += delta;\\n\\n // Halve y, which corresponds to z/2 in the Wikipedia article.\\n y >>= 1;\\n }\\n }\\n result = wrap(resultUint);\\n }\\n}\\n\\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\\n///\\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n///\\n/// @dev See the documentation in {Common.mulDiv18}.\\n/// @param x The multiplicand as a UD60x18 number.\\n/// @param y The multiplier as a UD60x18 number.\\n/// @return result The product as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\\n}\\n\\n/// @notice Raises x to the power of y.\\n///\\n/// For $1 \\\\leq x \\\\leq \\\\infty$, the following standard formula is used:\\n///\\n/// $$\\n/// x^y = 2^{log_2{x} * y}\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\\n///\\n/// $$\\n/// i = \\\\frac{1}{x}\\n/// w = 2^{log_2{i} * y}\\n/// x^y = \\\\frac{1}{w}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2} and {mul}.\\n/// - Returns `UNIT` for 0^0.\\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\\n///\\n/// @param x The base as a UD60x18 number.\\n/// @param y The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n\\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\\n if (xUint == 0) {\\n return yUint == 0 ? UNIT : ZERO;\\n }\\n // If x is `UNIT`, the result is always `UNIT`.\\n else if (xUint == uUNIT) {\\n return UNIT;\\n }\\n\\n // If y is zero, the result is always `UNIT`.\\n if (yUint == 0) {\\n return UNIT;\\n }\\n // If y is `UNIT`, the result is always x.\\n else if (yUint == uUNIT) {\\n return x;\\n }\\n\\n // If x is greater than `UNIT`, use the standard formula.\\n if (xUint > uUNIT) {\\n result = exp2(mul(log2(x), y));\\n }\\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\\n else {\\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\\n UD60x18 w = exp2(mul(log2(i), y));\\n result = wrap(uUNIT_SQUARED / w.unwrap());\\n }\\n}\\n\\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\\n/// algorithm \\\"exponentiation by squaring\\\".\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - The result must fit in UD60x18.\\n///\\n/// @param x The base as a UD60x18 number.\\n/// @param y The exponent as a uint256.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\\n // Calculate the first iteration of the loop in advance.\\n uint256 xUint = x.unwrap();\\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\\n\\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\\n for (y >>= 1; y > 0; y >>= 1) {\\n xUint = Common.mulDiv18(xUint, xUint);\\n\\n // Equivalent to `y % 2 == 1`.\\n if (y & 1 > 0) {\\n resultUint = Common.mulDiv18(resultUint, xUint);\\n }\\n }\\n result = wrap(resultUint);\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must be less than `MAX_UD60x18 / UNIT`.\\n///\\n/// @param x The UD60x18 number for which to calculate the square root.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n unchecked {\\n if (xUint > uMAX_UD60x18 / uUNIT) {\\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\\n }\\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\\n // In this case, the two numbers are both the square root.\\n result = wrap(Common.sqrt(xUint * uUNIT));\\n }\\n}\\n\",\"keccak256\":\"0x462144667aac3f96d5f8dba7aa68fe4c5a3f61e1d7bbbc81bee21168817f9c09\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\nimport \\\"./Helpers.sol\\\" as Helpers;\\nimport \\\"./Math.sol\\\" as Math;\\n\\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\\n/// @dev The value type is defined here so it can be imported in all other files.\\ntype UD60x18 is uint256;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD1x18,\\n Casting.intoUD2x18,\\n Casting.intoSD59x18,\\n Casting.intoUint128,\\n Casting.intoUint256,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes the functions in this library callable on the UD60x18 type.\\nusing {\\n Math.avg,\\n Math.ceil,\\n Math.div,\\n Math.exp,\\n Math.exp2,\\n Math.floor,\\n Math.frac,\\n Math.gm,\\n Math.inv,\\n Math.ln,\\n Math.log10,\\n Math.log2,\\n Math.mul,\\n Math.pow,\\n Math.powu,\\n Math.sqrt\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n HELPER FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes the functions in this library callable on the UD60x18 type.\\nusing {\\n Helpers.add,\\n Helpers.and,\\n Helpers.eq,\\n Helpers.gt,\\n Helpers.gte,\\n Helpers.isZero,\\n Helpers.lshift,\\n Helpers.lt,\\n Helpers.lte,\\n Helpers.mod,\\n Helpers.neq,\\n Helpers.not,\\n Helpers.or,\\n Helpers.rshift,\\n Helpers.sub,\\n Helpers.uncheckedAdd,\\n Helpers.uncheckedSub,\\n Helpers.xor\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n OPERATORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes it possible to use these operators on the UD60x18 type.\\nusing {\\n Helpers.add as +,\\n Helpers.and2 as &,\\n Math.div as /,\\n Helpers.eq as ==,\\n Helpers.gt as >,\\n Helpers.gte as >=,\\n Helpers.lt as <,\\n Helpers.lte as <=,\\n Helpers.or as |,\\n Helpers.mod as %,\\n Math.mul as *,\\n Helpers.neq as !=,\\n Helpers.not as ~,\\n Helpers.sub as -,\\n Helpers.xor as ^\\n} for UD60x18 global;\\n\",\"keccak256\":\"0xdd873b5124180d9b71498b3a7fe93b1c08c368bec741f7d5f8e17f78a0b70f31\",\"license\":\"MIT\"},\"contracts/DecentSablierStreamManagement.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.28;\\n\\nimport {Enum} from \\\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\\\";\\nimport {IAvatar} from \\\"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\\\";\\nimport {ISablierV2Lockup} from \\\"./interfaces/sablier/full/ISablierV2Lockup.sol\\\";\\nimport {Lockup} from \\\"./interfaces/sablier/full/types/DataTypes.sol\\\";\\n\\ncontract DecentSablierStreamManagement {\\n string public constant NAME = \\\"DecentSablierStreamManagement\\\";\\n\\n function withdrawMaxFromStream(\\n ISablierV2Lockup sablier,\\n address recipientHatAccount,\\n uint256 streamId,\\n address to\\n ) public {\\n // Check if there are funds to withdraw\\n uint128 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\\n if (withdrawableAmount == 0) {\\n return;\\n }\\n\\n // Proxy the Sablier withdrawMax call through IAvatar (Safe)\\n IAvatar(msg.sender).execTransactionFromModule(\\n recipientHatAccount,\\n 0,\\n abi.encodeWithSignature(\\n \\\"execute(address,uint256,bytes,uint8)\\\",\\n address(sablier),\\n 0,\\n abi.encodeWithSignature(\\n \\\"withdrawMax(uint256,address)\\\",\\n streamId,\\n to\\n ),\\n 0\\n ),\\n Enum.Operation.Call\\n );\\n }\\n\\n function cancelStream(ISablierV2Lockup sablier, uint256 streamId) public {\\n // Check if the stream can be cancelled\\n Lockup.Status streamStatus = sablier.statusOf(streamId);\\n if (\\n streamStatus != Lockup.Status.PENDING &&\\n streamStatus != Lockup.Status.STREAMING\\n ) {\\n return;\\n }\\n\\n IAvatar(msg.sender).execTransactionFromModule(\\n address(sablier),\\n 0,\\n abi.encodeWithSignature(\\\"cancel(uint256)\\\", streamId),\\n Enum.Operation.Call\\n );\\n }\\n}\\n\",\"keccak256\":\"0xf36be7e97936d82de0035b8bda2c53dbc52b9ca3b8efe305540a7632cb6fe6ab\",\"license\":\"MIT\"},\"contracts/interfaces/sablier/full/IAdminable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\n/// @title IAdminable\\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\\n/// in the constructor.\\ninterface IAdminable {\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin is transferred.\\n /// @param oldAdmin The address of the old admin.\\n /// @param newAdmin The address of the new admin.\\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice The address of the admin account or contract.\\n function admin() external view returns (address);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Transfers the contract admin to a new address.\\n ///\\n /// @dev Notes:\\n /// - Does not revert if the admin is the same.\\n /// - This function can potentially leave the contract without an admin, thereby removing any\\n /// functionality that is only available to the admin.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newAdmin The address of the new admin.\\n function transferAdmin(address newAdmin) external;\\n}\\n\",\"keccak256\":\"0xa279c49e51228b571329164e36250e82b2c1378e8b549194ab7dd90fca9c3b2b\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/IERC4096.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4906.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC165} from \\\"@openzeppelin/contracts/interfaces/IERC165.sol\\\";\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\n/// @title ERC-721 Metadata Update Extension\\ninterface IERC4906 is IERC165, IERC721 {\\n /// @dev This event emits when the metadata of a token is changed.\\n /// So that the third-party platforms such as NFT market could\\n /// timely update the images and related attributes of the NFT.\\n event MetadataUpdate(uint256 _tokenId);\\n\\n /// @dev This event emits when the metadata of a range of tokens is changed.\\n /// So that the third-party platforms such as NFT market could\\n /// timely update the images and related attributes of the NFTs.\\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\\n}\\n\",\"keccak256\":\"0xa34b9c52cbe36be860244f52256f1b05badf0cb797d208664b87337610d0e82d\",\"license\":\"MIT\"},\"contracts/interfaces/sablier/full/ISablierV2Lockup.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC4906} from \\\"./IERC4096.sol\\\";\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {IERC721Metadata} from \\\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\\\";\\nimport {UD60x18} from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\nimport {Lockup} from \\\"./types/DataTypes.sol\\\";\\nimport {IAdminable} from \\\"./IAdminable.sol\\\";\\nimport {ISablierV2NFTDescriptor} from \\\"./ISablierV2NFTDescriptor.sol\\\";\\n\\n/// @title ISablierV2Lockup\\n/// @notice Common logic between all Sablier V2 Lockup contracts.\\ninterface ISablierV2Lockup is\\n IAdminable, // 0 inherited components\\n IERC4906, // 2 inherited components\\n IERC721Metadata // 2 inherited components\\n{\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin allows a new recipient contract to hook to Sablier.\\n /// @param admin The address of the current contract admin.\\n /// @param recipient The address of the recipient contract put on the allowlist.\\n event AllowToHook(address indexed admin, address recipient);\\n\\n /// @notice Emitted when a stream is canceled.\\n /// @param streamId The ID of the stream.\\n /// @param sender The address of the stream's sender.\\n /// @param recipient The address of the stream's recipient.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\\n /// decimals.\\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\\n /// asset's decimals.\\n event CancelLockupStream(\\n uint256 streamId,\\n address indexed sender,\\n address indexed recipient,\\n IERC20 indexed asset,\\n uint128 senderAmount,\\n uint128 recipientAmount\\n );\\n\\n /// @notice Emitted when a sender gives up the right to cancel a stream.\\n /// @param streamId The ID of the stream.\\n event RenounceLockupStream(uint256 indexed streamId);\\n\\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\\n /// @param admin The address of the current contract admin.\\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\\n event SetNFTDescriptor(\\n address indexed admin,\\n ISablierV2NFTDescriptor oldNFTDescriptor,\\n ISablierV2NFTDescriptor newNFTDescriptor\\n );\\n\\n /// @notice Emitted when assets are withdrawn from a stream.\\n /// @param streamId The ID of the stream.\\n /// @param to The address that has received the withdrawn assets.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\\n event WithdrawFromLockupStream(\\n uint256 indexed streamId,\\n address indexed to,\\n IERC20 indexed asset,\\n uint128 amount\\n );\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Retrieves the address of the ERC-20 asset to be distributed.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\\n\\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getDepositedAmount(\\n uint256 streamId\\n ) external view returns (uint128 depositedAmount);\\n\\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getEndTime(\\n uint256 streamId\\n ) external view returns (uint40 endTime);\\n\\n /// @notice Retrieves the stream's recipient.\\n /// @dev Reverts if the NFT has been burned.\\n /// @param streamId The stream ID for the query.\\n function getRecipient(\\n uint256 streamId\\n ) external view returns (address recipient);\\n\\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\\n /// decimals. This amount is always zero unless the stream was canceled.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getRefundedAmount(\\n uint256 streamId\\n ) external view returns (uint128 refundedAmount);\\n\\n /// @notice Retrieves the stream's sender.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getSender(uint256 streamId) external view returns (address sender);\\n\\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getStartTime(\\n uint256 streamId\\n ) external view returns (uint40 startTime);\\n\\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getWithdrawnAmount(\\n uint256 streamId\\n ) external view returns (uint128 withdrawnAmount);\\n\\n /// @notice Retrieves a flag indicating whether the provided address is a contract allowed to hook to Sablier\\n /// when a stream is canceled or when assets are withdrawn.\\n /// @dev See {ISablierLockupRecipient} for more information.\\n function isAllowedToHook(\\n address recipient\\n ) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\\n /// flag is always `false`.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isCancelable(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isCold(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is depleted.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isDepleted(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream exists.\\n /// @dev Does not revert if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isStream(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isTransferable(\\n uint256 streamId\\n ) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isWarm(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves the maximum broker fee that can be charged by the broker, denoted as a fixed-point\\n /// number where 1e18 is 100%.\\n /// @dev This value is hard coded as a constant.\\n function MAX_BROKER_FEE() external view returns (UD60x18);\\n\\n /// @notice Counter for stream IDs, used in the create functions.\\n function nextStreamId() external view returns (uint256);\\n\\n /// @notice Contract that generates the non-fungible token URI.\\n function nftDescriptor() external view returns (ISablierV2NFTDescriptor);\\n\\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\\n /// of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function refundableAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 refundableAmount);\\n\\n /// @notice Retrieves the stream's status.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function statusOf(\\n uint256 streamId\\n ) external view returns (Lockup.Status status);\\n\\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n ///\\n /// Notes:\\n /// - Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\\n /// to the total amount withdrawn.\\n ///\\n /// @param streamId The stream ID for the query.\\n function streamedAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 streamedAmount);\\n\\n /// @notice Retrieves a flag indicating whether the stream was canceled.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function wasCanceled(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\\n /// decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function withdrawableAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 withdrawableAmount);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Allows a recipient contract to hook to Sablier when a stream is canceled or when assets are withdrawn.\\n /// Useful for implementing contracts that hold streams on behalf of users, such as vaults or staking contracts.\\n ///\\n /// @dev Emits an {AllowToHook} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the contract is already on the allowlist.\\n /// - This is an irreversible operation. The contract cannot be removed from the allowlist.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n /// - `recipient` must have a non-zero code size.\\n /// - `recipient` must implement {ISablierLockupRecipient}.\\n ///\\n /// @param recipient The address of the contract to allow for hooks.\\n function allowToHook(address recipient) external;\\n\\n /// @notice Burns the NFT associated with the stream.\\n ///\\n /// @dev Emits a {Transfer} event.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must reference a depleted stream.\\n /// - The NFT must exist.\\n /// - `msg.sender` must be either the NFT owner or an approved third party.\\n ///\\n /// @param streamId The ID of the stream NFT to burn.\\n function burn(uint256 streamId) external;\\n\\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\\n ///\\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\\n /// stream is marked as depleted.\\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - The stream must be warm and cancelable.\\n /// - `msg.sender` must be the stream's sender.\\n ///\\n /// @param streamId The ID of the stream to cancel.\\n function cancel(uint256 streamId) external;\\n\\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\\n ///\\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\\n ///\\n /// Notes:\\n /// - Refer to the notes in {cancel}.\\n ///\\n /// Requirements:\\n /// - All requirements from {cancel} must be met for each stream.\\n ///\\n /// @param streamIds The IDs of the streams to cancel.\\n function cancelMultiple(uint256[] calldata streamIds) external;\\n\\n /// @notice Removes the right of the stream's sender to cancel the stream.\\n ///\\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - This is an irreversible operation.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must reference a warm stream.\\n /// - `msg.sender` must be the stream's sender.\\n /// - The stream must be cancelable.\\n ///\\n /// @param streamId The ID of the stream to renounce.\\n function renounce(uint256 streamId) external;\\n\\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\\n ///\\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the NFT descriptor is the same.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\\n function setNFTDescriptor(\\n ISablierV2NFTDescriptor newNFTDescriptor\\n ) external;\\n\\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\\n ///\\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - This function attempts to call a hook on the recipient of the stream, unless `msg.sender` is the recipient.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must not reference a null or depleted stream.\\n /// - `to` must not be the zero address.\\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\\n /// - `to` must be the recipient if `msg.sender` is not the stream's recipient or an approved third party.\\n ///\\n /// @param streamId The ID of the stream to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\\n function withdraw(uint256 streamId, address to, uint128 amount) external;\\n\\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\\n ///\\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - Refer to the notes in {withdraw}.\\n ///\\n /// Requirements:\\n /// - Refer to the requirements in {withdraw}.\\n ///\\n /// @param streamId The ID of the stream to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\\n function withdrawMax(\\n uint256 streamId,\\n address to\\n ) external returns (uint128 withdrawnAmount);\\n\\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\\n /// NFT to `newRecipient`.\\n ///\\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\\n ///\\n /// Notes:\\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\\n /// - Refer to the notes in {withdraw}.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the stream's recipient.\\n /// - Refer to the requirements in {withdraw}.\\n /// - Refer to the requirements in {IERC721.transferFrom}.\\n ///\\n /// @param streamId The ID of the stream NFT to transfer.\\n /// @param newRecipient The address of the new owner of the stream NFT.\\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\\n function withdrawMaxAndTransfer(\\n uint256 streamId,\\n address newRecipient\\n ) external returns (uint128 withdrawnAmount);\\n\\n /// @notice Withdraws assets from streams to the recipient of each stream.\\n ///\\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\\n ///\\n /// Notes:\\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - There must be an equal number of `streamIds` and `amounts`.\\n /// - Each stream ID in the array must not reference a null or depleted stream.\\n /// - Each amount in the array must be greater than zero and must not exceed the withdrawable amount.\\n ///\\n /// @param streamIds The IDs of the streams to withdraw from.\\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\\n function withdrawMultiple(\\n uint256[] calldata streamIds,\\n uint128[] calldata amounts\\n ) external;\\n}\\n\",\"keccak256\":\"0x3e5541c38a901637bd310965deb5bbde73ef07fe4ee3c752cbec330c6b9d62a3\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/ISablierV2NFTDescriptor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC721Metadata} from \\\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\\\";\\n\\n/// @title ISablierV2NFTDescriptor\\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\\n/// @dev Inspired by Uniswap V3 Positions NFTs.\\ninterface ISablierV2NFTDescriptor {\\n /// @notice Produces the URI describing a particular stream NFT.\\n /// @dev This is a data URI with the JSON contents directly inlined.\\n /// @param sablier The address of the Sablier contract the stream was created in.\\n /// @param streamId The ID of the stream for which to produce a description.\\n /// @return uri The URI of the ERC721-compliant metadata.\\n function tokenURI(\\n IERC721Metadata sablier,\\n uint256 streamId\\n ) external view returns (string memory uri);\\n}\\n\",\"keccak256\":\"0x4ed430e553d14161e93efdaaacd1a502f49b38969c9d714b45d2e682a74fa0bc\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/types/DataTypes.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {UD2x18} from \\\"@prb/math/src/UD2x18.sol\\\";\\nimport {UD60x18} from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\n// DataTypes.sol\\n//\\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\\n//\\n// - Lockup\\n// - LockupDynamic\\n// - LockupLinear\\n// - LockupTranched\\n//\\n// You will notice that some structs contain \\\"slot\\\" annotations - they are used to indicate the\\n// storage layout of the struct. It is more gas efficient to group small data types together so\\n// that they fit in a single 32-byte slot.\\n\\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\\n/// @param account The address receiving the broker's fee.\\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\\nstruct Broker {\\n address account;\\n UD60x18 fee;\\n}\\n\\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\\nlibrary Lockup {\\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the asset's\\n /// decimals.\\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in the same slot\\n /// saves gas.\\n /// @param deposited The initial amount deposited in the stream, net of broker fee.\\n /// @param withdrawn The cumulative amount withdrawn from the stream.\\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\\n struct Amounts {\\n // slot 0\\n uint128 deposited;\\n uint128 withdrawn;\\n // slot 1\\n uint128 refunded;\\n }\\n\\n /// @notice Struct encapsulating (i) the deposit amount and (ii) the broker fee amount, both denoted in units of the\\n /// asset's decimals.\\n /// @param deposit The amount to deposit in the stream.\\n /// @param brokerFee The broker fee amount.\\n struct CreateAmounts {\\n uint128 deposit;\\n uint128 brokerFee;\\n }\\n\\n /// @notice Enum representing the different statuses of a stream.\\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\\n enum Status {\\n PENDING,\\n STREAMING,\\n SETTLED,\\n CANCELED,\\n DEPLETED\\n }\\n\\n /// @notice A common data structure to be stored in all {SablierV2Lockup} models.\\n /// @dev The fields are arranged like this to save gas via tight variable packing.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param endTime The Unix timestamp indicating the stream's end.\\n /// @param isCancelable Boolean indicating if the stream is cancelable.\\n /// @param wasCanceled Boolean indicating if the stream was canceled.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param isDepleted Boolean indicating if the stream is depleted.\\n /// @param isStream Boolean indicating if the struct entity exists.\\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\\n /// @param amounts Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the\\n /// asset's decimals.\\n struct Stream {\\n // slot 0\\n address sender;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n // slot 1\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n // slot 2 and 3\\n Lockup.Amounts amounts;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\\nlibrary LockupDynamic {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param segments Segments with durations used to compose the dynamic distribution function. Timestamps are\\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n SegmentWithDuration[] segments;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param segments Segments used to compose the dynamic distribution function.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n uint40 startTime;\\n Segment[] segments;\\n Broker broker;\\n }\\n\\n /// @notice Segment struct used in the Lockup Dynamic stream.\\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\\n /// @param timestamp The Unix timestamp indicating the segment's end.\\n struct Segment {\\n // slot 0\\n uint128 amount;\\n UD2x18 exponent;\\n uint40 timestamp;\\n }\\n\\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDurations}.\\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\\n /// @param duration The time difference in seconds between the segment and the previous one.\\n struct SegmentWithDuration {\\n uint128 amount;\\n UD2x18 exponent;\\n uint40 duration;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the segments.\\n struct StreamLD {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n Segment[] segments;\\n }\\n\\n /// @notice Struct encapsulating the LockupDynamic timestamps.\\n /// @param start The Unix timestamp indicating the stream's start.\\n /// @param end The Unix timestamp indicating the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 end;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\\nlibrary LockupLinear {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param durations Struct encapsulating (i) cliff period duration and (ii) total stream duration, both in seconds.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n Durations durations;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param timestamps Struct encapsulating (i) the stream's start time, (ii) cliff time, and (iii) end time, all as\\n /// Unix timestamps.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n Timestamps timestamps;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the cliff duration and the total duration.\\n /// @param cliff The cliff duration in seconds.\\n /// @param total The total duration in seconds.\\n struct Durations {\\n uint40 cliff;\\n uint40 total;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the cliff time.\\n struct StreamLL {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n uint40 endTime;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n uint40 cliffTime;\\n }\\n\\n /// @notice Struct encapsulating the LockupLinear timestamps.\\n /// @param start The Unix timestamp for the stream's start.\\n /// @param cliff The Unix timestamp for the cliff period's end. A value of zero means there is no cliff.\\n /// @param end The Unix timestamp for the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 cliff;\\n uint40 end;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupTranched}.\\nlibrary LockupTranched {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param tranches Tranches with durations used to compose the tranched distribution function. Timestamps are\\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n TrancheWithDuration[] tranches;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param tranches Tranches used to compose the tranched distribution function.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n uint40 startTime;\\n Tranche[] tranches;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the tranches.\\n struct StreamLT {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n Tranche[] tranches;\\n }\\n\\n /// @notice Struct encapsulating the LockupTranched timestamps.\\n /// @param start The Unix timestamp indicating the stream's start.\\n /// @param end The Unix timestamp indicating the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 end;\\n }\\n\\n /// @notice Tranche struct used in the Lockup Tranched stream.\\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\\n /// @param timestamp The Unix timestamp indicating the tranche's end.\\n struct Tranche {\\n // slot 0\\n uint128 amount;\\n uint40 timestamp;\\n }\\n\\n /// @notice Tranche struct used at runtime in {SablierV2LockupTranched.createWithDurations}.\\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\\n /// @param duration The time difference in seconds between the tranche and the previous one.\\n struct TrancheWithDuration {\\n uint128 amount;\\n uint40 duration;\\n }\\n}\\n\",\"keccak256\":\"0x727722c0ec71a76a947b935c9dfcac8fd846d6c3547dfbc8739c7109f3b95068\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", + "bytecode": "0x6080604052348015600f57600080fd5b506105fe8061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80636778d4b0146100465780637dc14a8e1461005b578063a3f4df7e1461006e575b600080fd5b6100596100543660046103d0565b6100c0565b005b610059610069366004610423565b610256565b6100aa6040518060400160405280601d81526020017f446563656e745361626c69657253747265616d4d616e6167656d656e7400000081525081565b6040516100b79190610495565b60405180910390f35b60405163d975dfed60e01b8152600481018390526000906001600160a01b0386169063d975dfed90602401602060405180830381865afa158015610108573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012c91906104af565b9050806001600160801b03166000036101455750610250565b336001600160a01b031663468721a7856000886000888860405160240161017f9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529181526020820180516001600160e01b031663ea5ead1960e01b179052516101bc939291906000906024016104d8565b60408051601f198184030181529181526020820180516001600160e01b0316635194544760e01b1790525160e085901b6001600160e01b031916815261020a9392919060009060040161052f565b6020604051808303816000875af1158015610229573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024d9190610585565b50505b50505050565b604051632b4d7bf560e21b8152600481018290526000906001600160a01b0384169063ad35efd490602401602060405180830381865afa15801561029e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c291906105a7565b905060008160048111156102d8576102d8610519565b141580156102f8575060018160048111156102f5576102f5610519565b14155b1561030257505050565b336001600160a01b031663468721a78460008560405160240161032791815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166340e58ee560e01b1790525160e085901b6001600160e01b03191681526103759392919060009060040161052f565b6020604051808303816000875af1158015610394573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102509190610585565b6001600160a01b03811681146103cd57600080fd5b50565b600080600080608085870312156103e657600080fd5b84356103f1816103b8565b93506020850135610401816103b8565b9250604085013591506060850135610418816103b8565b939692955090935050565b6000806040838503121561043657600080fd5b8235610441816103b8565b946020939093013593505050565b6000815180845260005b8181101561047557602081850181015186830182015201610459565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006104a8602083018461044f565b9392505050565b6000602082840312156104c157600080fd5b81516001600160801b03811681146104a857600080fd5b6001600160a01b038516815260ff841660208201526080604082018190526000906105059083018561044f565b905060ff8316606083015295945050505050565b634e487b7160e01b600052602160045260246000fd5b60018060a01b0385168152836020820152608060408201526000610556608083018561044f565b90506002831061057657634e487b7160e01b600052602160045260246000fd5b82606083015295945050505050565b60006020828403121561059757600080fd5b815180151581146104a857600080fd5b6000602082840312156105b957600080fd5b8151600581106104a857600080fdfea2646970667358221220c473750d62fe01ec9f421a499df8738e767b4a5341626c81a992fcdb3ee192de64736f6c634300081c0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80636778d4b0146100465780637dc14a8e1461005b578063a3f4df7e1461006e575b600080fd5b6100596100543660046103d0565b6100c0565b005b610059610069366004610423565b610256565b6100aa6040518060400160405280601d81526020017f446563656e745361626c69657253747265616d4d616e6167656d656e7400000081525081565b6040516100b79190610495565b60405180910390f35b60405163d975dfed60e01b8152600481018390526000906001600160a01b0386169063d975dfed90602401602060405180830381865afa158015610108573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012c91906104af565b9050806001600160801b03166000036101455750610250565b336001600160a01b031663468721a7856000886000888860405160240161017f9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529181526020820180516001600160e01b031663ea5ead1960e01b179052516101bc939291906000906024016104d8565b60408051601f198184030181529181526020820180516001600160e01b0316635194544760e01b1790525160e085901b6001600160e01b031916815261020a9392919060009060040161052f565b6020604051808303816000875af1158015610229573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024d9190610585565b50505b50505050565b604051632b4d7bf560e21b8152600481018290526000906001600160a01b0384169063ad35efd490602401602060405180830381865afa15801561029e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c291906105a7565b905060008160048111156102d8576102d8610519565b141580156102f8575060018160048111156102f5576102f5610519565b14155b1561030257505050565b336001600160a01b031663468721a78460008560405160240161032791815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166340e58ee560e01b1790525160e085901b6001600160e01b03191681526103759392919060009060040161052f565b6020604051808303816000875af1158015610394573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102509190610585565b6001600160a01b03811681146103cd57600080fd5b50565b600080600080608085870312156103e657600080fd5b84356103f1816103b8565b93506020850135610401816103b8565b9250604085013591506060850135610418816103b8565b939692955090935050565b6000806040838503121561043657600080fd5b8235610441816103b8565b946020939093013593505050565b6000815180845260005b8181101561047557602081850181015186830182015201610459565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006104a8602083018461044f565b9392505050565b6000602082840312156104c157600080fd5b81516001600160801b03811681146104a857600080fd5b6001600160a01b038516815260ff841660208201526080604082018190526000906105059083018561044f565b905060ff8316606083015295945050505050565b634e487b7160e01b600052602160045260246000fd5b60018060a01b0385168152836020820152608060408201526000610556608083018561044f565b90506002831061057657634e487b7160e01b600052602160045260246000fd5b82606083015295945050505050565b60006020828403121561059757600080fd5b815180151581146104a857600080fd5b6000602082840312156105b957600080fd5b8151600581106104a857600080fdfea2646970667358221220c473750d62fe01ec9f421a499df8738e767b4a5341626c81a992fcdb3ee192de64736f6c634300081c0033", + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/deployments/sepolia/solcInputs/4511b61209438ca20d2458493e70bb24.json b/deployments/sepolia/solcInputs/4511b61209438ca20d2458493e70bb24.json new file mode 100644 index 00000000..c068a9c4 --- /dev/null +++ b/deployments/sepolia/solcInputs/4511b61209438ca20d2458493e70bb24.json @@ -0,0 +1,351 @@ +{ + "language": "Solidity", + "sources": { + "@gnosis.pm/safe-contracts/contracts/base/Executor.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\n\n/// @title Executor - A contract that can execute transactions\n/// @author Richard Meissner - \ncontract Executor {\n function execute(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 txGas\n ) internal returns (bool success) {\n if (operation == Enum.Operation.DelegateCall) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n success := delegatecall(txGas, to, add(data, 0x20), mload(data), 0, 0)\n }\n } else {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n success := call(txGas, to, value, add(data, 0x20), mload(data), 0, 0)\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/FallbackManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../common/SelfAuthorized.sol\";\n\n/// @title Fallback Manager - A contract that manages fallback calls made to this contract\n/// @author Richard Meissner - \ncontract FallbackManager is SelfAuthorized {\n event ChangedFallbackHandler(address handler);\n\n // keccak256(\"fallback_manager.handler.address\")\n bytes32 internal constant FALLBACK_HANDLER_STORAGE_SLOT = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5;\n\n function internalSetFallbackHandler(address handler) internal {\n bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, handler)\n }\n }\n\n /// @dev Allows to add a contract to handle fallback calls.\n /// Only fallback calls without value and with data will be forwarded.\n /// This can only be done via a Safe transaction.\n /// @param handler contract to handle fallbacks calls.\n function setFallbackHandler(address handler) public authorized {\n internalSetFallbackHandler(handler);\n emit ChangedFallbackHandler(handler);\n }\n\n // solhint-disable-next-line payable-fallback,no-complex-fallback\n fallback() external {\n bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let handler := sload(slot)\n if iszero(handler) {\n return(0, 0)\n }\n calldatacopy(0, 0, calldatasize())\n // The msg.sender address is shifted to the left by 12 bytes to remove the padding\n // Then the address without padding is stored right after the calldata\n mstore(calldatasize(), shl(96, caller()))\n // Add 20 bytes for the address appended add the end\n let success := call(gas(), handler, 0, 0, add(calldatasize(), 20), 0, 0)\n returndatacopy(0, 0, returndatasize())\n if iszero(success) {\n revert(0, returndatasize())\n }\n return(0, returndatasize())\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/GuardManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\n\ninterface Guard {\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external;\n\n function checkAfterExecution(bytes32 txHash, bool success) external;\n}\n\n/// @title Fallback Manager - A contract that manages fallback calls made to this contract\n/// @author Richard Meissner - \ncontract GuardManager is SelfAuthorized {\n event ChangedGuard(address guard);\n // keccak256(\"guard_manager.guard.address\")\n bytes32 internal constant GUARD_STORAGE_SLOT = 0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8;\n\n /// @dev Set a guard that checks transactions before execution\n /// @param guard The address of the guard to be used or the 0 address to disable the guard\n function setGuard(address guard) external authorized {\n bytes32 slot = GUARD_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, guard)\n }\n emit ChangedGuard(guard);\n }\n\n function getGuard() internal view returns (address guard) {\n bytes32 slot = GUARD_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n guard := sload(slot)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/ModuleManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\nimport \"./Executor.sol\";\n\n/// @title Module Manager - A contract that manages modules that can execute transactions via this contract\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract ModuleManager is SelfAuthorized, Executor {\n event EnabledModule(address module);\n event DisabledModule(address module);\n event ExecutionFromModuleSuccess(address indexed module);\n event ExecutionFromModuleFailure(address indexed module);\n\n address internal constant SENTINEL_MODULES = address(0x1);\n\n mapping(address => address) internal modules;\n\n function setupModules(address to, bytes memory data) internal {\n require(modules[SENTINEL_MODULES] == address(0), \"GS100\");\n modules[SENTINEL_MODULES] = SENTINEL_MODULES;\n if (to != address(0))\n // Setup has to complete successfully or transaction fails.\n require(execute(to, 0, data, Enum.Operation.DelegateCall, gasleft()), \"GS000\");\n }\n\n /// @dev Allows to add a module to the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Enables the module `module` for the Safe.\n /// @param module Module to be whitelisted.\n function enableModule(address module) public authorized {\n // Module address cannot be null or sentinel.\n require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n // Module cannot be added twice.\n require(modules[module] == address(0), \"GS102\");\n modules[module] = modules[SENTINEL_MODULES];\n modules[SENTINEL_MODULES] = module;\n emit EnabledModule(module);\n }\n\n /// @dev Allows to remove a module from the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Disables the module `module` for the Safe.\n /// @param prevModule Module that pointed to the module to be removed in the linked list\n /// @param module Module to be removed.\n function disableModule(address prevModule, address module) public authorized {\n // Validate module address and check that it corresponds to module index.\n require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n require(modules[prevModule] == module, \"GS103\");\n modules[prevModule] = modules[module];\n modules[module] = address(0);\n emit DisabledModule(module);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public virtual returns (bool success) {\n // Only whitelisted modules are allowed.\n require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), \"GS104\");\n // Execute transaction without further confirmations.\n success = execute(to, value, data, operation, gasleft());\n if (success) emit ExecutionFromModuleSuccess(msg.sender);\n else emit ExecutionFromModuleFailure(msg.sender);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModuleReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public returns (bool success, bytes memory returnData) {\n success = execTransactionFromModule(to, value, data, operation);\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // Load free memory location\n let ptr := mload(0x40)\n // We allocate memory for the return data by setting the free memory location to\n // current free memory location + data size + 32 bytes for data size value\n mstore(0x40, add(ptr, add(returndatasize(), 0x20)))\n // Store the size\n mstore(ptr, returndatasize())\n // Store the data\n returndatacopy(add(ptr, 0x20), 0, returndatasize())\n // Point the return data to the correct memory location\n returnData := ptr\n }\n }\n\n /// @dev Returns if an module is enabled\n /// @return True if the module is enabled\n function isModuleEnabled(address module) public view returns (bool) {\n return SENTINEL_MODULES != module && modules[module] != address(0);\n }\n\n /// @dev Returns array of modules.\n /// @param start Start of the page.\n /// @param pageSize Maximum number of modules that should be returned.\n /// @return array Array of modules.\n /// @return next Start of the next page.\n function getModulesPaginated(address start, uint256 pageSize) external view returns (address[] memory array, address next) {\n // Init array with max page size\n array = new address[](pageSize);\n\n // Populate return array\n uint256 moduleCount = 0;\n address currentModule = modules[start];\n while (currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {\n array[moduleCount] = currentModule;\n currentModule = modules[currentModule];\n moduleCount++;\n }\n next = currentModule;\n // Set correct size of returned array\n // solhint-disable-next-line no-inline-assembly\n assembly {\n mstore(array, moduleCount)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/OwnerManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/SelfAuthorized.sol\";\n\n/// @title OwnerManager - Manages a set of owners and a threshold to perform actions.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract OwnerManager is SelfAuthorized {\n event AddedOwner(address owner);\n event RemovedOwner(address owner);\n event ChangedThreshold(uint256 threshold);\n\n address internal constant SENTINEL_OWNERS = address(0x1);\n\n mapping(address => address) internal owners;\n uint256 internal ownerCount;\n uint256 internal threshold;\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n function setupOwners(address[] memory _owners, uint256 _threshold) internal {\n // Threshold can only be 0 at initialization.\n // Check ensures that setup function can only be called once.\n require(threshold == 0, \"GS200\");\n // Validate that threshold is smaller than number of added owners.\n require(_threshold <= _owners.length, \"GS201\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"GS202\");\n // Initializing Safe owners.\n address currentOwner = SENTINEL_OWNERS;\n for (uint256 i = 0; i < _owners.length; i++) {\n // Owner address cannot be null.\n address owner = _owners[i];\n require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, \"GS203\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"GS204\");\n owners[currentOwner] = owner;\n currentOwner = owner;\n }\n owners[currentOwner] = SENTINEL_OWNERS;\n ownerCount = _owners.length;\n threshold = _threshold;\n }\n\n /// @dev Allows to add a new owner to the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.\n /// @param owner New owner address.\n /// @param _threshold New threshold.\n function addOwnerWithThreshold(address owner, uint256 _threshold) public authorized {\n // Owner address cannot be null, the sentinel or the Safe itself.\n require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), \"GS203\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"GS204\");\n owners[owner] = owners[SENTINEL_OWNERS];\n owners[SENTINEL_OWNERS] = owner;\n ownerCount++;\n emit AddedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold) changeThreshold(_threshold);\n }\n\n /// @dev Allows to remove an owner from the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.\n /// @param prevOwner Owner that pointed to the owner to be removed in the linked list\n /// @param owner Owner address to be removed.\n /// @param _threshold New threshold.\n function removeOwner(\n address prevOwner,\n address owner,\n uint256 _threshold\n ) public authorized {\n // Only allow to remove an owner, if threshold can still be reached.\n require(ownerCount - 1 >= _threshold, \"GS201\");\n // Validate owner address and check that it corresponds to owner index.\n require(owner != address(0) && owner != SENTINEL_OWNERS, \"GS203\");\n require(owners[prevOwner] == owner, \"GS205\");\n owners[prevOwner] = owners[owner];\n owners[owner] = address(0);\n ownerCount--;\n emit RemovedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold) changeThreshold(_threshold);\n }\n\n /// @dev Allows to swap/replace an owner from the Safe with another address.\n /// This can only be done via a Safe transaction.\n /// @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.\n /// @param prevOwner Owner that pointed to the owner to be replaced in the linked list\n /// @param oldOwner Owner address to be replaced.\n /// @param newOwner New owner address.\n function swapOwner(\n address prevOwner,\n address oldOwner,\n address newOwner\n ) public authorized {\n // Owner address cannot be null, the sentinel or the Safe itself.\n require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), \"GS203\");\n // No duplicate owners allowed.\n require(owners[newOwner] == address(0), \"GS204\");\n // Validate oldOwner address and check that it corresponds to owner index.\n require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, \"GS203\");\n require(owners[prevOwner] == oldOwner, \"GS205\");\n owners[newOwner] = owners[oldOwner];\n owners[prevOwner] = newOwner;\n owners[oldOwner] = address(0);\n emit RemovedOwner(oldOwner);\n emit AddedOwner(newOwner);\n }\n\n /// @dev Allows to update the number of required confirmations by Safe owners.\n /// This can only be done via a Safe transaction.\n /// @notice Changes the threshold of the Safe to `_threshold`.\n /// @param _threshold New threshold.\n function changeThreshold(uint256 _threshold) public authorized {\n // Validate that threshold is smaller than number of owners.\n require(_threshold <= ownerCount, \"GS201\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"GS202\");\n threshold = _threshold;\n emit ChangedThreshold(threshold);\n }\n\n function getThreshold() public view returns (uint256) {\n return threshold;\n }\n\n function isOwner(address owner) public view returns (bool) {\n return owner != SENTINEL_OWNERS && owners[owner] != address(0);\n }\n\n /// @dev Returns array of owners.\n /// @return Array of Safe owners.\n function getOwners() public view returns (address[] memory) {\n address[] memory array = new address[](ownerCount);\n\n // populate return array\n uint256 index = 0;\n address currentOwner = owners[SENTINEL_OWNERS];\n while (currentOwner != SENTINEL_OWNERS) {\n array[index] = currentOwner;\n currentOwner = owners[currentOwner];\n index++;\n }\n return array;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/Enum.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Enum - Collection of enums\n/// @author Richard Meissner - \ncontract Enum {\n enum Operation {Call, DelegateCall}\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/EtherPaymentFallback.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title EtherPaymentFallback - A contract that has a fallback to accept ether payments\n/// @author Richard Meissner - \ncontract EtherPaymentFallback {\n event SafeReceived(address indexed sender, uint256 value);\n\n /// @dev Fallback function accepts Ether transactions.\n receive() external payable {\n emit SafeReceived(msg.sender, msg.value);\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SecuredTokenTransfer.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SecuredTokenTransfer - Secure token transfer\n/// @author Richard Meissner - \ncontract SecuredTokenTransfer {\n /// @dev Transfers a token and returns if it was a success\n /// @param token Token that should be transferred\n /// @param receiver Receiver to whom the token should be transferred\n /// @param amount The amount of tokens that should be transferred\n function transferToken(\n address token,\n address receiver,\n uint256 amount\n ) internal returns (bool transferred) {\n // 0xa9059cbb - keccack(\"transfer(address,uint256)\")\n bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // We write the return value to scratch space.\n // See https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory\n let success := call(sub(gas(), 10000), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n switch returndatasize()\n case 0 {\n transferred := success\n }\n case 0x20 {\n transferred := iszero(or(iszero(success), iszero(mload(0))))\n }\n default {\n transferred := 0\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SelfAuthorized.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SelfAuthorized - authorizes current contract to perform actions\n/// @author Richard Meissner - \ncontract SelfAuthorized {\n function requireSelfCall() private view {\n require(msg.sender == address(this), \"GS031\");\n }\n\n modifier authorized() {\n // This is a function call as it minimized the bytecode size\n requireSelfCall();\n _;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SignatureDecoder.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SignatureDecoder - Decodes signatures that a encoded as bytes\n/// @author Richard Meissner - \ncontract SignatureDecoder {\n /// @dev divides bytes signature into `uint8 v, bytes32 r, bytes32 s`.\n /// @notice Make sure to peform a bounds check for @param pos, to avoid out of bounds access on @param signatures\n /// @param pos which signature to read. A prior bounds check of this parameter should be performed, to avoid out of bounds access\n /// @param signatures concatenated rsv signatures\n function signatureSplit(bytes memory signatures, uint256 pos)\n internal\n pure\n returns (\n uint8 v,\n bytes32 r,\n bytes32 s\n )\n {\n // The signature format is a compact form of:\n // {bytes32 r}{bytes32 s}{uint8 v}\n // Compact means, uint8 is not padded to 32 bytes.\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let signaturePos := mul(0x41, pos)\n r := mload(add(signatures, add(signaturePos, 0x20)))\n s := mload(add(signatures, add(signaturePos, 0x40)))\n // Here we are loading the last 32 bytes, including 31 bytes\n // of 's'. There is no 'mload8' to do this.\n //\n // 'byte' is not working due to the Solidity parser, so lets\n // use the second best option, 'and'\n v := and(mload(add(signatures, add(signaturePos, 0x41))), 0xff)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/Singleton.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Singleton - Base for singleton contracts (should always be first super contract)\n/// This contract is tightly coupled to our proxy contract (see `proxies/GnosisSafeProxy.sol`)\n/// @author Richard Meissner - \ncontract Singleton {\n // singleton always needs to be first declared variable, to ensure that it is at the same location as in the Proxy contract.\n // It should also always be ensured that the address is stored alone (uses a full word)\n address private singleton;\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/StorageAccessible.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title StorageAccessible - generic base contract that allows callers to access all internal storage.\n/// @notice See https://github.com/gnosis/util-contracts/blob/bb5fe5fb5df6d8400998094fb1b32a178a47c3a1/contracts/StorageAccessible.sol\ncontract StorageAccessible {\n /**\n * @dev Reads `length` bytes of storage in the currents contract\n * @param offset - the offset in the current contract's storage in words to start reading from\n * @param length - the number of words (32 bytes) of data to read\n * @return the bytes that were read.\n */\n function getStorageAt(uint256 offset, uint256 length) public view returns (bytes memory) {\n bytes memory result = new bytes(length * 32);\n for (uint256 index = 0; index < length; index++) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let word := sload(add(offset, index))\n mstore(add(add(result, 0x20), mul(index, 0x20)), word)\n }\n }\n return result;\n }\n\n /**\n * @dev Performs a delegetecall on a targetContract in the context of self.\n * Internally reverts execution to avoid side effects (making it static).\n *\n * This method reverts with data equal to `abi.encode(bool(success), bytes(response))`.\n * Specifically, the `returndata` after a call to this method will be:\n * `success:bool || response.length:uint256 || response:bytes`.\n *\n * @param targetContract Address of the contract containing the code to execute.\n * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).\n */\n function simulateAndRevert(address targetContract, bytes memory calldataPayload) external {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let success := delegatecall(gas(), targetContract, add(calldataPayload, 0x20), mload(calldataPayload), 0, 0)\n\n mstore(0x00, success)\n mstore(0x20, returndatasize())\n returndatacopy(0x40, 0, returndatasize())\n revert(0, add(returndatasize(), 0x40))\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/external/GnosisSafeMath.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title GnosisSafeMath\n * @dev Math operations with safety checks that revert on error\n * Renamed from SafeMath to GnosisSafeMath to avoid conflicts\n * TODO: remove once open zeppelin update to solc 0.5.0\n */\nlibrary GnosisSafeMath {\n /**\n * @dev Multiplies two numbers, reverts on overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b);\n\n return c;\n }\n\n /**\n * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Adds two numbers, reverts on overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a);\n\n return c;\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 a >= b ? a : b;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/GnosisSafe.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./base/ModuleManager.sol\";\nimport \"./base/OwnerManager.sol\";\nimport \"./base/FallbackManager.sol\";\nimport \"./base/GuardManager.sol\";\nimport \"./common/EtherPaymentFallback.sol\";\nimport \"./common/Singleton.sol\";\nimport \"./common/SignatureDecoder.sol\";\nimport \"./common/SecuredTokenTransfer.sol\";\nimport \"./common/StorageAccessible.sol\";\nimport \"./interfaces/ISignatureValidator.sol\";\nimport \"./external/GnosisSafeMath.sol\";\n\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafe is\n EtherPaymentFallback,\n Singleton,\n ModuleManager,\n OwnerManager,\n SignatureDecoder,\n SecuredTokenTransfer,\n ISignatureValidatorConstants,\n FallbackManager,\n StorageAccessible,\n GuardManager\n{\n using GnosisSafeMath for uint256;\n\n string public constant VERSION = \"1.3.0\";\n\n // keccak256(\n // \"EIP712Domain(uint256 chainId,address verifyingContract)\"\n // );\n bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;\n\n // keccak256(\n // \"SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)\"\n // );\n bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;\n\n event SafeSetup(address indexed initiator, address[] owners, uint256 threshold, address initializer, address fallbackHandler);\n event ApproveHash(bytes32 indexed approvedHash, address indexed owner);\n event SignMsg(bytes32 indexed msgHash);\n event ExecutionFailure(bytes32 txHash, uint256 payment);\n event ExecutionSuccess(bytes32 txHash, uint256 payment);\n\n uint256 public nonce;\n bytes32 private _deprecatedDomainSeparator;\n // Mapping to keep track of all message hashes that have been approve by ALL REQUIRED owners\n mapping(bytes32 => uint256) public signedMessages;\n // Mapping to keep track of all hashes (message or transaction) that have been approve by ANY owners\n mapping(address => mapping(bytes32 => uint256)) public approvedHashes;\n\n // This constructor ensures that this contract can only be used as a master copy for Proxy contracts\n constructor() {\n // By setting the threshold it is not possible to call setup anymore,\n // so we create a Safe with 0 owners and threshold 1.\n // This is an unusable Safe, perfect for the singleton\n threshold = 1;\n }\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n /// @param to Contract address for optional delegate call.\n /// @param data Data payload for optional delegate call.\n /// @param fallbackHandler Handler for fallback calls to this contract\n /// @param paymentToken Token that should be used for the payment (0 is ETH)\n /// @param payment Value that should be paid\n /// @param paymentReceiver Adddress that should receive the payment (or 0 if tx.origin)\n function setup(\n address[] calldata _owners,\n uint256 _threshold,\n address to,\n bytes calldata data,\n address fallbackHandler,\n address paymentToken,\n uint256 payment,\n address payable paymentReceiver\n ) external {\n // setupOwners checks if the Threshold is already set, therefore preventing that this method is called twice\n setupOwners(_owners, _threshold);\n if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);\n // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules\n setupModules(to, data);\n\n if (payment > 0) {\n // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)\n // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment\n handlePayment(payment, 0, 1, paymentToken, paymentReceiver);\n }\n emit SafeSetup(msg.sender, _owners, _threshold, to, fallbackHandler);\n }\n\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\n /// Note: The fees are always transferred, even if the user transaction fails.\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @param safeTxGas Gas that should be used for the Safe transaction.\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Gas price that should be used for the payment calculation.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\n function execTransaction(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures\n ) public payable virtual returns (bool success) {\n bytes32 txHash;\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n bytes memory txHashData =\n encodeTransactionData(\n // Transaction info\n to,\n value,\n data,\n operation,\n safeTxGas,\n // Payment info\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n // Signature info\n nonce\n );\n // Increase nonce and execute transaction.\n nonce++;\n txHash = keccak256(txHashData);\n checkSignatures(txHash, txHashData, signatures);\n }\n address guard = getGuard();\n {\n if (guard != address(0)) {\n Guard(guard).checkTransaction(\n // Transaction info\n to,\n value,\n data,\n operation,\n safeTxGas,\n // Payment info\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n // Signature info\n signatures,\n msg.sender\n );\n }\n }\n // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)\n // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150\n require(gasleft() >= ((safeTxGas * 64) / 63).max(safeTxGas + 2500) + 500, \"GS010\");\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n uint256 gasUsed = gasleft();\n // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)\n // We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas\n success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);\n gasUsed = gasUsed.sub(gasleft());\n // If no safeTxGas and no gasPrice was set (e.g. both are 0), then the internal tx is required to be successful\n // This makes it possible to use `estimateGas` without issues, as it searches for the minimum gas where the tx doesn't revert\n require(success || safeTxGas != 0 || gasPrice != 0, \"GS013\");\n // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls\n uint256 payment = 0;\n if (gasPrice > 0) {\n payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);\n }\n if (success) emit ExecutionSuccess(txHash, payment);\n else emit ExecutionFailure(txHash, payment);\n }\n {\n if (guard != address(0)) {\n Guard(guard).checkAfterExecution(txHash, success);\n }\n }\n }\n\n function handlePayment(\n uint256 gasUsed,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver\n ) private returns (uint256 payment) {\n // solhint-disable-next-line avoid-tx-origin\n address payable receiver = refundReceiver == address(0) ? payable(tx.origin) : refundReceiver;\n if (gasToken == address(0)) {\n // For ETH we will only adjust the gas price to not be higher than the actual used gas price\n payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);\n require(receiver.send(payment), \"GS011\");\n } else {\n payment = gasUsed.add(baseGas).mul(gasPrice);\n require(transferToken(gasToken, receiver, payment), \"GS012\");\n }\n }\n\n /**\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n * @param data That should be signed (this is passed to an external validator contract)\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\n */\n function checkSignatures(\n bytes32 dataHash,\n bytes memory data,\n bytes memory signatures\n ) public view {\n // Load threshold to avoid multiple storage loads\n uint256 _threshold = threshold;\n // Check that a threshold is set\n require(_threshold > 0, \"GS001\");\n checkNSignatures(dataHash, data, signatures, _threshold);\n }\n\n /**\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n * @param data That should be signed (this is passed to an external validator contract)\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\n * @param requiredSignatures Amount of required valid signatures.\n */\n function checkNSignatures(\n bytes32 dataHash,\n bytes memory data,\n bytes memory signatures,\n uint256 requiredSignatures\n ) public view {\n // Check that the provided signature data is not too short\n require(signatures.length >= requiredSignatures.mul(65), \"GS020\");\n // There cannot be an owner with address 0.\n address lastOwner = address(0);\n address currentOwner;\n uint8 v;\n bytes32 r;\n bytes32 s;\n uint256 i;\n for (i = 0; i < requiredSignatures; i++) {\n (v, r, s) = signatureSplit(signatures, i);\n if (v == 0) {\n // If v is 0 then it is a contract signature\n // When handling contract signatures the address of the contract is encoded into r\n currentOwner = address(uint160(uint256(r)));\n\n // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes\n // This check is not completely accurate, since it is possible that more signatures than the threshold are send.\n // Here we only check that the pointer is not pointing inside the part that is being processed\n require(uint256(s) >= requiredSignatures.mul(65), \"GS021\");\n\n // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)\n require(uint256(s).add(32) <= signatures.length, \"GS022\");\n\n // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length\n uint256 contractSignatureLen;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n contractSignatureLen := mload(add(add(signatures, s), 0x20))\n }\n require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, \"GS023\");\n\n // Check signature\n bytes memory contractSignature;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s\n contractSignature := add(add(signatures, s), 0x20)\n }\n require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, \"GS024\");\n } else if (v == 1) {\n // If v is 1 then it is an approved hash\n // When handling approved hashes the address of the approver is encoded into r\n currentOwner = address(uint160(uint256(r)));\n // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction\n require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, \"GS025\");\n } else if (v > 30) {\n // If v > 30 then default va (27,28) has been adjusted for eth_sign flow\n // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover\n currentOwner = ecrecover(keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", dataHash)), v - 4, r, s);\n } else {\n // Default is the ecrecover flow with the provided data hash\n // Use ecrecover with the messageHash for EOA signatures\n currentOwner = ecrecover(dataHash, v, r, s);\n }\n require(currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS, \"GS026\");\n lastOwner = currentOwner;\n }\n }\n\n /// @dev Allows to estimate a Safe transaction.\n /// This method is only meant for estimation purpose, therefore the call will always revert and encode the result in the revert data.\n /// Since the `estimateGas` function includes refunds, call this method to get an estimated of the costs that are deducted from the safe with `execTransaction`\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @return Estimate without refunds and overhead fees (base transaction and payload data gas costs).\n /// @notice Deprecated in favor of common/StorageAccessible.sol and will be removed in next version.\n function requiredTxGas(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation\n ) external returns (uint256) {\n uint256 startGas = gasleft();\n // We don't provide an error message here, as we use it to return the estimate\n require(execute(to, value, data, operation, gasleft()));\n uint256 requiredGas = startGas - gasleft();\n // Convert response to string and return via error message\n revert(string(abi.encodePacked(requiredGas)));\n }\n\n /**\n * @dev Marks a hash as approved. This can be used to validate a hash that is used by a signature.\n * @param hashToApprove The hash that should be marked as approved for signatures that are verified by this contract.\n */\n function approveHash(bytes32 hashToApprove) external {\n require(owners[msg.sender] != address(0), \"GS030\");\n approvedHashes[msg.sender][hashToApprove] = 1;\n emit ApproveHash(hashToApprove, msg.sender);\n }\n\n /// @dev Returns the chain id used by this contract.\n function getChainId() public view returns (uint256) {\n uint256 id;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n id := chainid()\n }\n return id;\n }\n\n function domainSeparator() public view returns (bytes32) {\n return keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, getChainId(), this));\n }\n\n /// @dev Returns the bytes that are hashed to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Gas that should be used for the safe transaction.\n /// @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash bytes.\n function encodeTransactionData(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n ) public view returns (bytes memory) {\n bytes32 safeTxHash =\n keccak256(\n abi.encode(\n SAFE_TX_TYPEHASH,\n to,\n value,\n keccak256(data),\n operation,\n safeTxGas,\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n _nonce\n )\n );\n return abi.encodePacked(bytes1(0x19), bytes1(0x01), domainSeparator(), safeTxHash);\n }\n\n /// @dev Returns hash to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Fas that should be used for the safe transaction.\n /// @param baseGas Gas costs for data used to trigger the safe transaction.\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash.\n function getTransactionHash(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n ) public view returns (bytes32) {\n return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./GnosisSafe.sol\";\n\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafeL2 is GnosisSafe {\n event SafeMultiSigTransaction(\n address to,\n uint256 value,\n bytes data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes signatures,\n // We combine nonce, sender and threshold into one to avoid stack too deep\n // Dev note: additionalInfo should not contain `bytes`, as this complicates decoding\n bytes additionalInfo\n );\n\n event SafeModuleTransaction(address module, address to, uint256 value, bytes data, Enum.Operation operation);\n\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\n /// Note: The fees are always transferred, even if the user transaction fails.\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @param safeTxGas Gas that should be used for the Safe transaction.\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Gas price that should be used for the payment calculation.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\n function execTransaction(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures\n ) public payable override returns (bool) {\n bytes memory additionalInfo;\n {\n additionalInfo = abi.encode(nonce, msg.sender, threshold);\n }\n emit SafeMultiSigTransaction(\n to,\n value,\n data,\n operation,\n safeTxGas,\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n signatures,\n additionalInfo\n );\n return super.execTransaction(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, signatures);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public override returns (bool success) {\n emit SafeModuleTransaction(msg.sender, to, value, data, operation);\n success = super.execTransactionFromModule(to, value, data, operation);\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/interfaces/ISignatureValidator.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\ncontract ISignatureValidatorConstants {\n // bytes4(keccak256(\"isValidSignature(bytes,bytes)\")\n bytes4 internal constant EIP1271_MAGIC_VALUE = 0x20c13b0b;\n}\n\nabstract contract ISignatureValidator is ISignatureValidatorConstants {\n /**\n * @dev Should return whether the signature provided is valid for the provided data\n * @param _data Arbitrary length data signed on the behalf of address(this)\n * @param _signature Signature byte array associated with _data\n *\n * MUST return the bytes4 magic value 0x20c13b0b when function passes.\n * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)\n * MUST allow external calls\n */\n function isValidSignature(bytes memory _data, bytes memory _signature) public view virtual returns (bytes4);\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Multi Send Call Only - Allows to batch multiple transactions into one, but only calls\n/// @author Stefan George - \n/// @author Richard Meissner - \n/// @notice The guard logic is not required here as this contract doesn't support nested delegate calls\ncontract MultiSendCallOnly {\n /// @dev Sends multiple transactions and reverts all if one fails.\n /// @param transactions Encoded transactions. Each transaction is encoded as a packed bytes of\n /// operation has to be uint8(0) in this version (=> 1 byte),\n /// to as a address (=> 20 bytes),\n /// value as a uint256 (=> 32 bytes),\n /// data length as a uint256 (=> 32 bytes),\n /// data as bytes.\n /// see abi.encodePacked for more information on packed encoding\n /// @notice The code is for most part the same as the normal MultiSend (to keep compatibility),\n /// but reverts if a transaction tries to use a delegatecall.\n /// @notice This method is payable as delegatecalls keep the msg.value from the previous call\n /// If the calling method (e.g. execTransaction) received ETH this would revert otherwise\n function multiSend(bytes memory transactions) public payable {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let length := mload(transactions)\n let i := 0x20\n for {\n // Pre block is not used in \"while mode\"\n } lt(i, length) {\n // Post block is not used in \"while mode\"\n } {\n // First byte of the data is the operation.\n // We shift by 248 bits (256 - 8 [operation byte]) it right since mload will always load 32 bytes (a word).\n // This will also zero out unused data.\n let operation := shr(0xf8, mload(add(transactions, i)))\n // We offset the load address by 1 byte (operation byte)\n // We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data.\n let to := shr(0x60, mload(add(transactions, add(i, 0x01))))\n // We offset the load address by 21 byte (operation byte + 20 address bytes)\n let value := mload(add(transactions, add(i, 0x15)))\n // We offset the load address by 53 byte (operation byte + 20 address bytes + 32 value bytes)\n let dataLength := mload(add(transactions, add(i, 0x35)))\n // We offset the load address by 85 byte (operation byte + 20 address bytes + 32 value bytes + 32 data length bytes)\n let data := add(transactions, add(i, 0x55))\n let success := 0\n switch operation\n case 0 {\n success := call(gas(), to, value, data, dataLength, 0, 0)\n }\n // This version does not allow delegatecalls\n case 1 {\n revert(0, 0)\n }\n if eq(success, 0) {\n revert(0, 0)\n }\n // Next entry starts at 85 byte + data length\n i := add(i, add(0x55, dataLength))\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxy.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain\n/// @author Richard Meissner - \ninterface IProxy {\n function masterCopy() external view returns (address);\n}\n\n/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafeProxy {\n // singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.\n // To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`\n address internal singleton;\n\n /// @dev Constructor function sets address of singleton contract.\n /// @param _singleton Singleton address.\n constructor(address _singleton) {\n require(_singleton != address(0), \"Invalid singleton address provided\");\n singleton = _singleton;\n }\n\n /// @dev Fallback function forwards all transactions and returns all received return data.\n fallback() external payable {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)\n // 0xa619486e == keccak(\"masterCopy()\"). The value is right padded to 32-bytes with 0s\n if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {\n mstore(0, _singleton)\n return(0, 0x20)\n }\n calldatacopy(0, 0, calldatasize())\n let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)\n returndatacopy(0, 0, returndatasize())\n if eq(success, 0) {\n revert(0, returndatasize())\n }\n return(0, returndatasize())\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./GnosisSafeProxy.sol\";\nimport \"./IProxyCreationCallback.sol\";\n\n/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n/// @author Stefan George - \ncontract GnosisSafeProxyFactory {\n event ProxyCreation(GnosisSafeProxy proxy, address singleton);\n\n /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n /// @param singleton Address of singleton contract.\n /// @param data Payload for message call sent to new proxy contract.\n function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {\n proxy = new GnosisSafeProxy(singleton);\n if (data.length > 0)\n // solhint-disable-next-line no-inline-assembly\n assembly {\n if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {\n revert(0, 0)\n }\n }\n emit ProxyCreation(proxy, singleton);\n }\n\n /// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.\n function proxyRuntimeCode() public pure returns (bytes memory) {\n return type(GnosisSafeProxy).runtimeCode;\n }\n\n /// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.\n function proxyCreationCode() public pure returns (bytes memory) {\n return type(GnosisSafeProxy).creationCode;\n }\n\n /// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.\n /// This method is only meant as an utility to be called from other methods\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function deployProxyWithNonce(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce\n ) internal returns (GnosisSafeProxy proxy) {\n // If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it\n bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));\n bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));\n // solhint-disable-next-line no-inline-assembly\n assembly {\n proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)\n }\n require(address(proxy) != address(0), \"Create2 call failed\");\n }\n\n /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function createProxyWithNonce(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce\n ) public returns (GnosisSafeProxy proxy) {\n proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);\n if (initializer.length > 0)\n // solhint-disable-next-line no-inline-assembly\n assembly {\n if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {\n revert(0, 0)\n }\n }\n emit ProxyCreation(proxy, _singleton);\n }\n\n /// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n /// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.\n function createProxyWithCallback(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce,\n IProxyCreationCallback callback\n ) public returns (GnosisSafeProxy proxy) {\n uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));\n proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);\n if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);\n }\n\n /// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`\n /// This method is only meant for address calculation purpose when you use an initializer that would revert,\n /// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function calculateCreateProxyWithNonceAddress(\n address _singleton,\n bytes calldata initializer,\n uint256 saltNonce\n ) external returns (GnosisSafeProxy proxy) {\n proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);\n revert(string(abi.encodePacked(proxy)));\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/IProxyCreationCallback.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"./GnosisSafeProxy.sol\";\n\ninterface IProxyCreationCallback {\n function proxyCreated(\n GnosisSafeProxy proxy,\n address _singleton,\n bytes calldata initializer,\n uint256 saltNonce\n ) external;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/core/Module.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Module Interface - A contract that can pass messages to a Module Manager contract if enabled by that contract.\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../interfaces/IAvatar.sol\";\nimport \"../factory/FactoryFriendly.sol\";\nimport \"../guard/Guardable.sol\";\n\nabstract contract Module is FactoryFriendly, Guardable {\n /// @dev Address that will ultimately execute function calls.\n address public avatar;\n /// @dev Address that this module will pass transactions to.\n address public target;\n\n /// @dev Emitted each time the avatar is set.\n event AvatarSet(address indexed previousAvatar, address indexed newAvatar);\n /// @dev Emitted each time the Target is set.\n event TargetSet(address indexed previousTarget, address indexed newTarget);\n\n /// @dev Sets the avatar to a new avatar (`newAvatar`).\n /// @notice Can only be called by the current owner.\n function setAvatar(address _avatar) public onlyOwner {\n address previousAvatar = avatar;\n avatar = _avatar;\n emit AvatarSet(previousAvatar, _avatar);\n }\n\n /// @dev Sets the target to a new target (`newTarget`).\n /// @notice Can only be called by the current owner.\n function setTarget(address _target) public onlyOwner {\n address previousTarget = target;\n target = _target;\n emit TargetSet(previousTarget, _target);\n }\n\n /// @dev Passes a transaction to be executed by the avatar.\n /// @notice Can only be called by this contract.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function exec(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) internal returns (bool success) {\n /// Check if a transactioon guard is enabled.\n if (guard != address(0)) {\n IGuard(guard).checkTransaction(\n /// Transaction info used by module transactions.\n to,\n value,\n data,\n operation,\n /// Zero out the redundant transaction information only used for Safe multisig transctions.\n 0,\n 0,\n 0,\n address(0),\n payable(0),\n bytes(\"0x\"),\n msg.sender\n );\n }\n success = IAvatar(target).execTransactionFromModule(\n to,\n value,\n data,\n operation\n );\n if (guard != address(0)) {\n IGuard(guard).checkAfterExecution(bytes32(\"0x\"), success);\n }\n return success;\n }\n\n /// @dev Passes a transaction to be executed by the target and returns data.\n /// @notice Can only be called by this contract.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execAndReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) internal returns (bool success, bytes memory returnData) {\n /// Check if a transactioon guard is enabled.\n if (guard != address(0)) {\n IGuard(guard).checkTransaction(\n /// Transaction info used by module transactions.\n to,\n value,\n data,\n operation,\n /// Zero out the redundant transaction information only used for Safe multisig transctions.\n 0,\n 0,\n 0,\n address(0),\n payable(0),\n bytes(\"0x\"),\n msg.sender\n );\n }\n (success, returnData) = IAvatar(target)\n .execTransactionFromModuleReturnData(to, value, data, operation);\n if (guard != address(0)) {\n IGuard(guard).checkAfterExecution(bytes32(\"0x\"), success);\n }\n return (success, returnData);\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/factory/FactoryFriendly.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Zodiac FactoryFriendly - A contract that allows other contracts to be initializable and pass bytes as arguments to define contract state\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nabstract contract FactoryFriendly is OwnableUpgradeable {\n function setUp(bytes memory initializeParams) public virtual;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.8.0;\n\ncontract ModuleProxyFactory {\n event ModuleProxyCreation(\n address indexed proxy,\n address indexed masterCopy\n );\n\n /// `target` can not be zero.\n error ZeroAddress(address target);\n\n /// `address_` is already taken.\n error TakenAddress(address address_);\n\n /// @notice Initialization failed.\n error FailedInitialization();\n\n function createProxy(address target, bytes32 salt)\n internal\n returns (address result)\n {\n if (address(target) == address(0)) revert ZeroAddress(target);\n bytes memory deployment = abi.encodePacked(\n hex\"602d8060093d393df3363d3d373d3d3d363d73\",\n target,\n hex\"5af43d82803e903d91602b57fd5bf3\"\n );\n // solhint-disable-next-line no-inline-assembly\n assembly {\n result := create2(0, add(deployment, 0x20), mload(deployment), salt)\n }\n if (result == address(0)) revert TakenAddress(result);\n }\n\n function deployModule(\n address masterCopy,\n bytes memory initializer,\n uint256 saltNonce\n ) public returns (address proxy) {\n proxy = createProxy(\n masterCopy,\n keccak256(abi.encodePacked(keccak256(initializer), saltNonce))\n );\n (bool success, ) = proxy.call(initializer);\n if (!success) revert FailedInitialization();\n\n emit ModuleProxyCreation(proxy, masterCopy);\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/guard/BaseGuard.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport \"../interfaces/IGuard.sol\";\n\nabstract contract BaseGuard is IERC165 {\n function supportsInterface(bytes4 interfaceId)\n external\n pure\n override\n returns (bool)\n {\n return\n interfaceId == type(IGuard).interfaceId || // 0xe6d7a83a\n interfaceId == type(IERC165).interfaceId; // 0x01ffc9a7\n }\n\n /// @dev Module transactions only use the first four parameters: to, value, data, and operation.\n /// Module.sol hardcodes the remaining parameters as 0 since they are not used for module transactions.\n /// @notice This interface is used to maintain compatibilty with Gnosis Safe transaction guards.\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external virtual;\n\n function checkAfterExecution(bytes32 txHash, bool success) external virtual;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/guard/Guardable.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"./BaseGuard.sol\";\n\n/// @title Guardable - A contract that manages fallback calls made to this contract\ncontract Guardable is OwnableUpgradeable {\n address public guard;\n\n event ChangedGuard(address guard);\n\n /// `guard_` does not implement IERC165.\n error NotIERC165Compliant(address guard_);\n\n /// @dev Set a guard that checks transactions before execution.\n /// @param _guard The address of the guard to be used or the 0 address to disable the guard.\n function setGuard(address _guard) external onlyOwner {\n if (_guard != address(0)) {\n if (!BaseGuard(_guard).supportsInterface(type(IGuard).interfaceId))\n revert NotIERC165Compliant(_guard);\n }\n guard = _guard;\n emit ChangedGuard(guard);\n }\n\n function getGuard() external view returns (address _guard) {\n return guard;\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Zodiac Avatar - A contract that manages modules that can execute transactions via this contract.\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\n\ninterface IAvatar {\n event EnabledModule(address module);\n event DisabledModule(address module);\n event ExecutionFromModuleSuccess(address indexed module);\n event ExecutionFromModuleFailure(address indexed module);\n\n /// @dev Enables a module on the avatar.\n /// @notice Can only be called by the avatar.\n /// @notice Modules should be stored as a linked list.\n /// @notice Must emit EnabledModule(address module) if successful.\n /// @param module Module to be enabled.\n function enableModule(address module) external;\n\n /// @dev Disables a module on the avatar.\n /// @notice Can only be called by the avatar.\n /// @notice Must emit DisabledModule(address module) if successful.\n /// @param prevModule Address that pointed to the module to be removed in the linked list\n /// @param module Module to be removed.\n function disableModule(address prevModule, address module) external;\n\n /// @dev Allows a Module to execute a transaction.\n /// @notice Can only be called by an enabled module.\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) external returns (bool success);\n\n /// @dev Allows a Module to execute a transaction and return data\n /// @notice Can only be called by an enabled module.\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execTransactionFromModuleReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) external returns (bool success, bytes memory returnData);\n\n /// @dev Returns if an module is enabled\n /// @return True if the module is enabled\n function isModuleEnabled(address module) external view returns (bool);\n\n /// @dev Returns array of modules.\n /// @param start Start of the page.\n /// @param pageSize Maximum number of modules that should be returned.\n /// @return array Array of modules.\n /// @return next Start of the next page.\n function getModulesPaginated(address start, uint256 pageSize)\n external\n view\n returns (address[] memory array, address next);\n}\n" + }, + "@gnosis.pm/zodiac/contracts/interfaces/IGuard.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\n\ninterface IGuard {\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external;\n\n function checkAfterExecution(bytes32 txHash, bool success) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 * By default, the owner account will be the one that deploys the contract. This\n * can 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 OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\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 require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing 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 require(newOwner != address(0), \"Ownable: new owner is the zero address\");\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/governance/utils/IVotesUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotesUpgradeable {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\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 * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\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 Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 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. Equivalent to `reinitializer(1)`.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\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 * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\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 modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\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 require(_initializing, \"Initializable: contract is not initializing\");\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 function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20Upgradeable.sol\";\nimport \"./extensions/IERC20MetadataUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC20_init_unchained(name_, symbol_);\n }\n\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[45] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20PermitUpgradeable.sol\";\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/cryptography/draft-EIP712Upgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {\n using CountersUpgradeable for CountersUpgradeable.Counter;\n\n mapping(address => CountersUpgradeable.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n function __ERC20Permit_init(string memory name) internal onlyInitializing {\n __EIP712_init_unchained(name, \"1\");\n }\n\n function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSAUpgradeable.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n CountersUpgradeable.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20SnapshotUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC20Snapshot.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/ArraysUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances and\n * total supply at the time are recorded for later access.\n *\n * This can be used to safely create mechanisms based on token balances such as trustless dividends or weighted voting.\n * In naive implementations it's possible to perform a \"double spend\" attack by reusing the same balance from different\n * accounts. By using snapshots to calculate dividends or voting power, those attacks no longer apply. It can also be\n * used to create an efficient ERC20 forking mechanism.\n *\n * Snapshots are created by the internal {_snapshot} function, which will emit the {Snapshot} event and return a\n * snapshot id. To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with the snapshot\n * id. To get the balance of an account at the time of a snapshot, call the {balanceOfAt} function with the snapshot id\n * and the account address.\n *\n * NOTE: Snapshot policy can be customized by overriding the {_getCurrentSnapshotId} method. For example, having it\n * return `block.number` will trigger the creation of snapshot at the beginning of each new block. When overriding this\n * function, be careful about the monotonicity of its result. Non-monotonic snapshot ids will break the contract.\n *\n * Implementing snapshots for every block using this method will incur significant gas costs. For a gas-efficient\n * alternative consider {ERC20Votes}.\n *\n * ==== Gas Costs\n *\n * Snapshots are efficient. Snapshot creation is _O(1)_. Retrieval of balances or total supply from a snapshot is _O(log\n * n)_ in the number of snapshots that have been created, although _n_ for a specific account will generally be much\n * smaller since identical balances in subsequent snapshots are stored as a single entry.\n *\n * There is a constant overhead for normal ERC20 transfers due to the additional snapshot bookkeeping. This overhead is\n * only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent\n * transfers will have normal cost until the next snapshot, and so on.\n */\n\nabstract contract ERC20SnapshotUpgradeable is Initializable, ERC20Upgradeable {\n function __ERC20Snapshot_init() internal onlyInitializing {\n }\n\n function __ERC20Snapshot_init_unchained() internal onlyInitializing {\n }\n // Inspired by Jordi Baylina's MiniMeToken to record historical balances:\n // https://github.com/Giveth/minime/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol\n\n using ArraysUpgradeable for uint256[];\n using CountersUpgradeable for CountersUpgradeable.Counter;\n\n // Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a\n // Snapshot struct, but that would impede usage of functions that work on an array.\n struct Snapshots {\n uint256[] ids;\n uint256[] values;\n }\n\n mapping(address => Snapshots) private _accountBalanceSnapshots;\n Snapshots private _totalSupplySnapshots;\n\n // Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid.\n CountersUpgradeable.Counter private _currentSnapshotId;\n\n /**\n * @dev Emitted by {_snapshot} when a snapshot identified by `id` is created.\n */\n event Snapshot(uint256 id);\n\n /**\n * @dev Creates a new snapshot and returns its snapshot id.\n *\n * Emits a {Snapshot} event that contains the same id.\n *\n * {_snapshot} is `internal` and you have to decide how to expose it externally. Its usage may be restricted to a\n * set of accounts, for example using {AccessControl}, or it may be open to the public.\n *\n * [WARNING]\n * ====\n * While an open way of calling {_snapshot} is required for certain trust minimization mechanisms such as forking,\n * you must consider that it can potentially be used by attackers in two ways.\n *\n * First, it can be used to increase the cost of retrieval of values from snapshots, although it will grow\n * logarithmically thus rendering this attack ineffective in the long term. Second, it can be used to target\n * specific accounts and increase the cost of ERC20 transfers for them, in the ways specified in the Gas Costs\n * section above.\n *\n * We haven't measured the actual numbers; if this is something you're interested in please reach out to us.\n * ====\n */\n function _snapshot() internal virtual returns (uint256) {\n _currentSnapshotId.increment();\n\n uint256 currentId = _getCurrentSnapshotId();\n emit Snapshot(currentId);\n return currentId;\n }\n\n /**\n * @dev Get the current snapshotId\n */\n function _getCurrentSnapshotId() internal view virtual returns (uint256) {\n return _currentSnapshotId.current();\n }\n\n /**\n * @dev Retrieves the balance of `account` at the time `snapshotId` was created.\n */\n function balanceOfAt(address account, uint256 snapshotId) public view virtual returns (uint256) {\n (bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]);\n\n return snapshotted ? value : balanceOf(account);\n }\n\n /**\n * @dev Retrieves the total supply at the time `snapshotId` was created.\n */\n function totalSupplyAt(uint256 snapshotId) public view virtual returns (uint256) {\n (bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots);\n\n return snapshotted ? value : totalSupply();\n }\n\n // Update balance and/or total supply snapshots before the values are modified. This is implemented\n // in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations.\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n if (from == address(0)) {\n // mint\n _updateAccountSnapshot(to);\n _updateTotalSupplySnapshot();\n } else if (to == address(0)) {\n // burn\n _updateAccountSnapshot(from);\n _updateTotalSupplySnapshot();\n } else {\n // transfer\n _updateAccountSnapshot(from);\n _updateAccountSnapshot(to);\n }\n }\n\n function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) {\n require(snapshotId > 0, \"ERC20Snapshot: id is 0\");\n require(snapshotId <= _getCurrentSnapshotId(), \"ERC20Snapshot: nonexistent id\");\n\n // When a valid snapshot is queried, there are three possibilities:\n // a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was never\n // created for this id, and all stored snapshot ids are smaller than the requested one. The value that corresponds\n // to this id is the current one.\n // b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with the\n // requested id, and its value is the one to return.\n // c) More snapshots were created after the requested one, and the queried value was later modified. There will be\n // no entry for the requested id: the value that corresponds to it is that of the smallest snapshot id that is\n // larger than the requested one.\n //\n // In summary, we need to find an element in an array, returning the index of the smallest value that is larger if\n // it is not found, unless said value doesn't exist (e.g. when all values are smaller). Arrays.findUpperBound does\n // exactly this.\n\n uint256 index = snapshots.ids.findUpperBound(snapshotId);\n\n if (index == snapshots.ids.length) {\n return (false, 0);\n } else {\n return (true, snapshots.values[index]);\n }\n }\n\n function _updateAccountSnapshot(address account) private {\n _updateSnapshot(_accountBalanceSnapshots[account], balanceOf(account));\n }\n\n function _updateTotalSupplySnapshot() private {\n _updateSnapshot(_totalSupplySnapshots, totalSupply());\n }\n\n function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private {\n uint256 currentId = _getCurrentSnapshotId();\n if (_lastSnapshotId(snapshots.ids) < currentId) {\n snapshots.ids.push(currentId);\n snapshots.values.push(currentValue);\n }\n }\n\n function _lastSnapshotId(uint256[] storage ids) private view returns (uint256) {\n if (ids.length == 0) {\n return 0;\n } else {\n return ids[ids.length - 1];\n }\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[46] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Votes.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-ERC20PermitUpgradeable.sol\";\nimport \"../../../utils/math/MathUpgradeable.sol\";\nimport \"../../../governance/utils/IVotesUpgradeable.sol\";\nimport \"../../../utils/math/SafeCastUpgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's,\n * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1.\n *\n * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module.\n *\n * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either\n * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting\n * power can be queried through the public accessors {getVotes} and {getPastVotes}.\n *\n * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it\n * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.\n *\n * _Available since v4.2._\n */\nabstract contract ERC20VotesUpgradeable is Initializable, IVotesUpgradeable, ERC20PermitUpgradeable {\n function __ERC20Votes_init() internal onlyInitializing {\n }\n\n function __ERC20Votes_init_unchained() internal onlyInitializing {\n }\n struct Checkpoint {\n uint32 fromBlock;\n uint224 votes;\n }\n\n bytes32 private constant _DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n mapping(address => address) private _delegates;\n mapping(address => Checkpoint[]) private _checkpoints;\n Checkpoint[] private _totalSupplyCheckpoints;\n\n /**\n * @dev Get the `pos`-th checkpoint for `account`.\n */\n function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) {\n return _checkpoints[account][pos];\n }\n\n /**\n * @dev Get number of checkpoints for `account`.\n */\n function numCheckpoints(address account) public view virtual returns (uint32) {\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\n }\n\n /**\n * @dev Get the address `account` is currently delegating to.\n */\n function delegates(address account) public view virtual override returns (address) {\n return _delegates[account];\n }\n\n /**\n * @dev Gets the current votes balance for `account`\n */\n function getVotes(address account) public view virtual override returns (uint256) {\n uint256 pos = _checkpoints[account].length;\n return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;\n }\n\n /**\n * @dev Retrieve the number of votes for `account` at the end of `blockNumber`.\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_checkpoints[account], blockNumber);\n }\n\n /**\n * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances.\n * It is but NOT the sum of all the delegated votes!\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastTotalSupply(uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber);\n }\n\n /**\n * @dev Lookup a value in a list of (sorted) checkpoints.\n */\n function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) {\n // We run a binary search to look for the earliest checkpoint taken after `blockNumber`.\n //\n // During the loop, the index of the wanted checkpoint remains in the range [low-1, high).\n // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.\n // - If the middle checkpoint is after `blockNumber`, we look in [low, mid)\n // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high)\n // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not\n // out of bounds (in which case we're looking too far in the past and the result is 0).\n // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is\n // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out\n // the same.\n uint256 high = ckpts.length;\n uint256 low = 0;\n while (low < high) {\n uint256 mid = MathUpgradeable.average(low, high);\n if (ckpts[mid].fromBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n return high == 0 ? 0 : ckpts[high - 1].votes;\n }\n\n /**\n * @dev Delegate votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) public virtual override {\n _delegate(_msgSender(), delegatee);\n }\n\n /**\n * @dev Delegates votes from signer to `delegatee`\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= expiry, \"ERC20Votes: signature expired\");\n address signer = ECDSAUpgradeable.recover(\n _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))),\n v,\n r,\n s\n );\n require(nonce == _useNonce(signer), \"ERC20Votes: invalid nonce\");\n _delegate(signer, delegatee);\n }\n\n /**\n * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).\n */\n function _maxSupply() internal view virtual returns (uint224) {\n return type(uint224).max;\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been increased.\n */\n function _mint(address account, uint256 amount) internal virtual override {\n super._mint(account, amount);\n require(totalSupply() <= _maxSupply(), \"ERC20Votes: total supply risks overflowing votes\");\n\n _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been decreased.\n */\n function _burn(address account, uint256 amount) internal virtual override {\n super._burn(account, amount);\n\n _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);\n }\n\n /**\n * @dev Move voting power when tokens are transferred.\n *\n * Emits a {DelegateVotesChanged} event.\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._afterTokenTransfer(from, to, amount);\n\n _moveVotingPower(delegates(from), delegates(to), amount);\n }\n\n /**\n * @dev Change delegation for `delegator` to `delegatee`.\n *\n * Emits events {DelegateChanged} and {DelegateVotesChanged}.\n */\n function _delegate(address delegator, address delegatee) internal virtual {\n address currentDelegate = delegates(delegator);\n uint256 delegatorBalance = balanceOf(delegator);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _moveVotingPower(\n address src,\n address dst,\n uint256 amount\n ) private {\n if (src != dst && amount > 0) {\n if (src != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);\n emit DelegateVotesChanged(src, oldWeight, newWeight);\n }\n\n if (dst != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\n }\n }\n }\n\n function _writeCheckpoint(\n Checkpoint[] storage ckpts,\n function(uint256, uint256) view returns (uint256) op,\n uint256 delta\n ) private returns (uint256 oldWeight, uint256 newWeight) {\n uint256 pos = ckpts.length;\n oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes;\n newWeight = op(oldWeight, delta);\n\n if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {\n ckpts[pos - 1].votes = SafeCastUpgradeable.toUint224(newWeight);\n } else {\n ckpts.push(Checkpoint({fromBlock: SafeCastUpgradeable.toUint32(block.number), votes: SafeCastUpgradeable.toUint224(newWeight)}));\n }\n }\n\n function _add(uint256 a, uint256 b) private pure returns (uint256) {\n return a + b;\n }\n\n function _subtract(uint256 a, uint256 b) private pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[47] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20WrapperUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/ERC20Wrapper.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../utils/SafeERC20Upgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Extension of the ERC20 token contract to support token wrapping.\n *\n * Users can deposit and withdraw \"underlying tokens\" and receive a matching number of \"wrapped tokens\". This is useful\n * in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the\n * wrapping of an existing \"basic\" ERC20 into a governance token.\n *\n * _Available since v4.2._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20WrapperUpgradeable is Initializable, ERC20Upgradeable {\n IERC20Upgradeable public underlying;\n\n function __ERC20Wrapper_init(IERC20Upgradeable underlyingToken) internal onlyInitializing {\n __ERC20Wrapper_init_unchained(underlyingToken);\n }\n\n function __ERC20Wrapper_init_unchained(IERC20Upgradeable underlyingToken) internal onlyInitializing {\n underlying = underlyingToken;\n }\n\n /**\n * @dev See {ERC20-decimals}.\n */\n function decimals() public view virtual override returns (uint8) {\n try IERC20MetadataUpgradeable(address(underlying)).decimals() returns (uint8 value) {\n return value;\n } catch {\n return super.decimals();\n }\n }\n\n /**\n * @dev Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.\n */\n function depositFor(address account, uint256 amount) public virtual returns (bool) {\n SafeERC20Upgradeable.safeTransferFrom(underlying, _msgSender(), address(this), amount);\n _mint(account, amount);\n return true;\n }\n\n /**\n * @dev Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.\n */\n function withdrawTo(address account, uint256 amount) public virtual returns (bool) {\n _burn(_msgSender(), amount);\n SafeERC20Upgradeable.safeTransfer(underlying, account, amount);\n return true;\n }\n\n /**\n * @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal\n * function that can be exposed with access control if desired.\n */\n function _recover(address account) internal virtual returns (uint256) {\n uint256 value = underlying.balanceOf(address(this)) - totalSupply();\n _mint(account, value);\n return value;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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 function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\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 /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ArraysUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Arrays.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\n\n/**\n * @dev Collection of functions related to array types.\n */\nlibrary ArraysUpgradeable {\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 * `array` is expected to be sorted in ascending order, and to contain no\n * repeated elements.\n */\n function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {\n if (array.length == 0) {\n return 0;\n }\n\n uint256 low = 0;\n uint256 high = array.length;\n\n while (low < high) {\n uint256 mid = MathUpgradeable.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 down (it does integer division with truncation).\n if (array[mid] > 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 && array[low - 1] == element) {\n return low - 1;\n } else {\n return low;\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary CountersUpgradeable {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSAUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 52\n */\nabstract contract EIP712Upgradeable is Initializable {\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n __EIP712_init_unchained(name, version);\n }\n\n function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev The hash of the name parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712NameHash() internal virtual view returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /**\n * @dev The hash of the version parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712VersionHash() internal virtual view returns (bytes32) {\n return _HASHED_VERSION;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\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 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 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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / 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 prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\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 works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\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^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`.\n // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.\n // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.\n // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a\n // good first aproximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1;\n uint256 x = a;\n if (x >> 128 > 0) {\n x >>= 128;\n result <<= 64;\n }\n if (x >> 64 > 0) {\n x >>= 64;\n result <<= 32;\n }\n if (x >> 32 > 0) {\n x >>= 32;\n result <<= 16;\n }\n if (x >> 16 > 0) {\n x >>= 16;\n result <<= 8;\n }\n if (x >> 8 > 0) {\n x >>= 8;\n result <<= 4;\n }\n if (x >> 4 > 0) {\n x >>= 4;\n result <<= 2;\n }\n if (x >> 2 > 0) {\n result <<= 1;\n }\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n uint256 result = sqrt(a);\n if (rounding == Rounding.Up && result * result < a) {\n result += 1;\n }\n return result;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX 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 *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\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 * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\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 * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\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 * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\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 * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\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 * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\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 * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\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 * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\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 * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\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 * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\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 * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\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 * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\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 * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\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 * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\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 * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\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 * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\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 * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\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 * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\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 * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\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 * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\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 * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\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 * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\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 * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\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 * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\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 * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\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 * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\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 * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\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 * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\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 * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\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 * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\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 * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\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 * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\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 * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\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 * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248) {\n require(value >= type(int248).min && value <= type(int248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return int248(value);\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 * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240) {\n require(value >= type(int240).min && value <= type(int240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return int240(value);\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 * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232) {\n require(value >= type(int232).min && value <= type(int232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return int232(value);\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 * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224) {\n require(value >= type(int224).min && value <= type(int224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return int224(value);\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 * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216) {\n require(value >= type(int216).min && value <= type(int216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return int216(value);\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 * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208) {\n require(value >= type(int208).min && value <= type(int208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return int208(value);\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 * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200) {\n require(value >= type(int200).min && value <= type(int200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return int200(value);\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 * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192) {\n require(value >= type(int192).min && value <= type(int192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return int192(value);\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 * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184) {\n require(value >= type(int184).min && value <= type(int184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return int184(value);\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 * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176) {\n require(value >= type(int176).min && value <= type(int176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return int176(value);\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 * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168) {\n require(value >= type(int168).min && value <= type(int168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return int168(value);\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 * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160) {\n require(value >= type(int160).min && value <= type(int160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return int160(value);\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 * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152) {\n require(value >= type(int152).min && value <= type(int152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return int152(value);\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 * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144) {\n require(value >= type(int144).min && value <= type(int144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return int144(value);\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 * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136) {\n require(value >= type(int136).min && value <= type(int136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return int136(value);\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 * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128) {\n require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return int128(value);\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 * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120) {\n require(value >= type(int120).min && value <= type(int120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return int120(value);\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 * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112) {\n require(value >= type(int112).min && value <= type(int112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return int112(value);\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 * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104) {\n require(value >= type(int104).min && value <= type(int104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return int104(value);\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 * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96) {\n require(value >= type(int96).min && value <= type(int96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return int96(value);\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 * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88) {\n require(value >= type(int88).min && value <= type(int88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return int88(value);\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 * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80) {\n require(value >= type(int80).min && value <= type(int80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return int80(value);\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 * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72) {\n require(value >= type(int72).min && value <= type(int72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return int72(value);\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 * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64) {\n require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return int64(value);\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 * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56) {\n require(value >= type(int56).min && value <= type(int56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return int56(value);\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 * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48) {\n require(value >= type(int48).min && value <= type(int48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return int48(value);\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 * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40) {\n require(value >= type(int40).min && value <= type(int40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return int40(value);\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 * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32) {\n require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return int32(value);\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 * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24) {\n require(value >= type(int24).min && value <= type(int24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return int24(value);\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 * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16) {\n require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return int16(value);\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 * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8) {\n require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return int8(value);\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 * _Available since v3.0._\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 require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@openzeppelin/contracts/governance/utils/IVotes.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotes {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/ERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\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 /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\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" + }, + "@openzeppelin/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 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 *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165Storage.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Storage.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ERC165.sol\";\n\n/**\n * @dev Storage based implementation of the {IERC165} interface.\n *\n * Contracts may inherit from this and call {_registerInterface} to declare\n * their support of an interface.\n */\nabstract contract ERC165Storage is ERC165 {\n /**\n * @dev Mapping of interface ids to whether or not it's supported.\n */\n mapping(bytes4 => bool) private _supportedInterfaces;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return super.supportsInterface(interfaceId) || _supportedInterfaces[interfaceId];\n }\n\n /**\n * @dev Registers the contract as an implementer of the interface defined by\n * `interfaceId`. Support of the actual ERC165 interface is automatic and\n * registering its interface id is not required.\n *\n * See {IERC165-supportsInterface}.\n *\n * Requirements:\n *\n * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).\n */\n function _registerInterface(bytes4 interfaceId) internal virtual {\n require(interfaceId != 0xffffffff, \"ERC165: invalid interface id\");\n _supportedInterfaces[interfaceId] = true;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\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[EIP 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" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@prb/math/src/Common.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\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 works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\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^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n" + }, + "@prb/math/src/sd1x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n" + }, + "@prb/math/src/sd1x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint64 constant uUNIT = 1e18;\n" + }, + "@prb/math/src/sd1x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n" + }, + "@prb/math/src/sd1x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n" + }, + "@prb/math/src/sd59x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n" + }, + "@prb/math/src/sd59x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev Any value less than this returns 0 in {exp}.\nint256 constant uEXP_MIN_THRESHOLD = -41_446531673892822322;\nSD59x18 constant EXP_MIN_THRESHOLD = SD59x18.wrap(uEXP_MIN_THRESHOLD);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Any value less than this returns 0 in {exp2}.\nint256 constant uEXP2_MIN_THRESHOLD = -59_794705707972522261;\nSD59x18 constant EXP2_MIN_THRESHOLD = SD59x18.wrap(uEXP2_MIN_THRESHOLD);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n" + }, + "@prb/math/src/sd59x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n" + }, + "@prb/math/src/sd59x18/Helpers.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" + }, + "@prb/math/src/sd59x18/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uEXP_MIN_THRESHOLD,\n uEXP2_MIN_THRESHOLD,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // Any input less than the threshold returns zero.\n // This check also prevents an overflow for very small numbers.\n if (xInt < uEXP_MIN_THRESHOLD) {\n return ZERO;\n }\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than the threshold is truncated to zero.\n if (xInt < uEXP2_MIN_THRESHOLD) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n" + }, + "@prb/math/src/sd59x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n" + }, + "@prb/math/src/UD2x18.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗╚════██╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║ █████╔╝ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══╝ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud2x18/Casting.sol\";\nimport \"./ud2x18/Constants.sol\";\nimport \"./ud2x18/Errors.sol\";\nimport \"./ud2x18/ValueType.sol\";\n" + }, + "@prb/math/src/ud2x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n" + }, + "@prb/math/src/ud2x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\nuint64 constant uUNIT = 1e18;\n" + }, + "@prb/math/src/ud2x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n" + }, + "@prb/math/src/ud2x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n" + }, + "@prb/math/src/UD60x18.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n" + }, + "@prb/math/src/ud60x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n" + }, + "@prb/math/src/ud60x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n" + }, + "@prb/math/src/ud60x18/Conversions.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n" + }, + "@prb/math/src/ud60x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n" + }, + "@prb/math/src/ud60x18/Helpers.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" + }, + "@prb/math/src/ud60x18/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n///\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n" + }, + "@prb/math/src/ud60x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n" + }, + "contracts/DecentSablierStreamManagement.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.28;\n\nimport {Enum} from \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport {IAvatar} from \"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\";\nimport {ISablierV2Lockup} from \"./interfaces/sablier/full/ISablierV2Lockup.sol\";\nimport {Lockup} from \"./interfaces/sablier/full/types/DataTypes.sol\";\n\ncontract DecentSablierStreamManagement {\n string public constant NAME = \"DecentSablierStreamManagement\";\n\n function withdrawMaxFromStream(\n ISablierV2Lockup sablier,\n address recipientHatAccount,\n uint256 streamId,\n address to\n ) public {\n // Check if there are funds to withdraw\n uint128 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\n if (withdrawableAmount == 0) {\n return;\n }\n\n // Proxy the Sablier withdrawMax call through IAvatar (Safe)\n IAvatar(msg.sender).execTransactionFromModule(\n recipientHatAccount,\n 0,\n abi.encodeWithSignature(\n \"execute(address,uint256,bytes,uint8)\",\n address(sablier),\n 0,\n abi.encodeWithSignature(\n \"withdrawMax(uint256,address)\",\n streamId,\n to\n ),\n 0\n ),\n Enum.Operation.Call\n );\n }\n\n function cancelStream(ISablierV2Lockup sablier, uint256 streamId) public {\n // Check if the stream can be cancelled\n Lockup.Status streamStatus = sablier.statusOf(streamId);\n if (\n streamStatus != Lockup.Status.PENDING &&\n streamStatus != Lockup.Status.STREAMING\n ) {\n return;\n }\n\n IAvatar(msg.sender).execTransactionFromModule(\n address(sablier),\n 0,\n abi.encodeWithSignature(\"cancel(uint256)\", streamId),\n Enum.Operation.Call\n );\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol';\n" + }, + "contracts/interfaces/hats/IHats.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0\n// Copyright (C) 2023 Haberdasher Labs\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see .\n\npragma solidity >=0.8.13;\n\ninterface IHats {\n function mintTopHat(\n address _target,\n string memory _details,\n string memory _imageURI\n ) external returns (uint256 topHatId);\n\n function createHat(\n uint256 _admin,\n string calldata _details,\n uint32 _maxSupply,\n address _eligibility,\n address _toggle,\n bool _mutable,\n string calldata _imageURI\n ) external returns (uint256 newHatId);\n\n function mintHat(\n uint256 _hatId,\n address _wearer\n ) external returns (bool success);\n\n function transferHat(uint256 _hatId, address _from, address _to) external;\n}\n" + }, + "contracts/interfaces/IERC6551Registry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IERC6551Registry {\n /**\n * @dev Creates a token bound account for a non-fungible token.\n *\n * If account has already been created, returns the account address without calling create2.\n *\n * Emits ERC6551AccountCreated event.\n *\n * @return account The address of the token bound account\n */\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address account);\n}\n" + }, + "contracts/interfaces/sablier/full/IAdminable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\n/// @title IAdminable\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\n/// in the constructor.\ninterface IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin is transferred.\n /// @param oldAdmin The address of the old admin.\n /// @param newAdmin The address of the new admin.\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice The address of the admin account or contract.\n function admin() external view returns (address);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Transfers the contract admin to a new address.\n ///\n /// @dev Notes:\n /// - Does not revert if the admin is the same.\n /// - This function can potentially leave the contract without an admin, thereby removing any\n /// functionality that is only available to the admin.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newAdmin The address of the new admin.\n function transferAdmin(address newAdmin) external;\n}\n" + }, + "contracts/interfaces/sablier/full/IERC4096.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4906.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\n/// @title ERC-721 Metadata Update Extension\ninterface IERC4906 is IERC165, IERC721 {\n /// @dev This event emits when the metadata of a token is changed.\n /// So that the third-party platforms such as NFT market could\n /// timely update the images and related attributes of the NFT.\n event MetadataUpdate(uint256 _tokenId);\n\n /// @dev This event emits when the metadata of a range of tokens is changed.\n /// So that the third-party platforms such as NFT market could\n /// timely update the images and related attributes of the NFTs.\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n}\n" + }, + "contracts/interfaces/sablier/full/ISablierV2Lockup.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC4906} from \"./IERC4096.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IERC721Metadata} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\nimport {UD60x18} from \"@prb/math/src/UD60x18.sol\";\n\nimport {Lockup} from \"./types/DataTypes.sol\";\nimport {IAdminable} from \"./IAdminable.sol\";\nimport {ISablierV2NFTDescriptor} from \"./ISablierV2NFTDescriptor.sol\";\n\n/// @title ISablierV2Lockup\n/// @notice Common logic between all Sablier V2 Lockup contracts.\ninterface ISablierV2Lockup is\n IAdminable, // 0 inherited components\n IERC4906, // 2 inherited components\n IERC721Metadata // 2 inherited components\n{\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin allows a new recipient contract to hook to Sablier.\n /// @param admin The address of the current contract admin.\n /// @param recipient The address of the recipient contract put on the allowlist.\n event AllowToHook(address indexed admin, address recipient);\n\n /// @notice Emitted when a stream is canceled.\n /// @param streamId The ID of the stream.\n /// @param sender The address of the stream's sender.\n /// @param recipient The address of the stream's recipient.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\n /// decimals.\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\n /// asset's decimals.\n event CancelLockupStream(\n uint256 streamId,\n address indexed sender,\n address indexed recipient,\n IERC20 indexed asset,\n uint128 senderAmount,\n uint128 recipientAmount\n );\n\n /// @notice Emitted when a sender gives up the right to cancel a stream.\n /// @param streamId The ID of the stream.\n event RenounceLockupStream(uint256 indexed streamId);\n\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\n /// @param admin The address of the current contract admin.\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n event SetNFTDescriptor(\n address indexed admin,\n ISablierV2NFTDescriptor oldNFTDescriptor,\n ISablierV2NFTDescriptor newNFTDescriptor\n );\n\n /// @notice Emitted when assets are withdrawn from a stream.\n /// @param streamId The ID of the stream.\n /// @param to The address that has received the withdrawn assets.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\n event WithdrawFromLockupStream(\n uint256 indexed streamId,\n address indexed to,\n IERC20 indexed asset,\n uint128 amount\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the address of the ERC-20 asset to be distributed.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\n\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getDepositedAmount(\n uint256 streamId\n ) external view returns (uint128 depositedAmount);\n\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getEndTime(\n uint256 streamId\n ) external view returns (uint40 endTime);\n\n /// @notice Retrieves the stream's recipient.\n /// @dev Reverts if the NFT has been burned.\n /// @param streamId The stream ID for the query.\n function getRecipient(\n uint256 streamId\n ) external view returns (address recipient);\n\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\n /// decimals. This amount is always zero unless the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getRefundedAmount(\n uint256 streamId\n ) external view returns (uint128 refundedAmount);\n\n /// @notice Retrieves the stream's sender.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getSender(uint256 streamId) external view returns (address sender);\n\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getStartTime(\n uint256 streamId\n ) external view returns (uint40 startTime);\n\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getWithdrawnAmount(\n uint256 streamId\n ) external view returns (uint128 withdrawnAmount);\n\n /// @notice Retrieves a flag indicating whether the provided address is a contract allowed to hook to Sablier\n /// when a stream is canceled or when assets are withdrawn.\n /// @dev See {ISablierLockupRecipient} for more information.\n function isAllowedToHook(\n address recipient\n ) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\n /// flag is always `false`.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isCancelable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isCold(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isDepleted(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream exists.\n /// @dev Does not revert if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isStream(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isTransferable(\n uint256 streamId\n ) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isWarm(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves the maximum broker fee that can be charged by the broker, denoted as a fixed-point\n /// number where 1e18 is 100%.\n /// @dev This value is hard coded as a constant.\n function MAX_BROKER_FEE() external view returns (UD60x18);\n\n /// @notice Counter for stream IDs, used in the create functions.\n function nextStreamId() external view returns (uint256);\n\n /// @notice Contract that generates the non-fungible token URI.\n function nftDescriptor() external view returns (ISablierV2NFTDescriptor);\n\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\n /// of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function refundableAmountOf(\n uint256 streamId\n ) external view returns (uint128 refundableAmount);\n\n /// @notice Retrieves the stream's status.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function statusOf(\n uint256 streamId\n ) external view returns (Lockup.Status status);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n ///\n /// Notes:\n /// - Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\n /// to the total amount withdrawn.\n ///\n /// @param streamId The stream ID for the query.\n function streamedAmountOf(\n uint256 streamId\n ) external view returns (uint128 streamedAmount);\n\n /// @notice Retrieves a flag indicating whether the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function wasCanceled(uint256 streamId) external view returns (bool result);\n\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\n /// decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function withdrawableAmountOf(\n uint256 streamId\n ) external view returns (uint128 withdrawableAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Allows a recipient contract to hook to Sablier when a stream is canceled or when assets are withdrawn.\n /// Useful for implementing contracts that hold streams on behalf of users, such as vaults or staking contracts.\n ///\n /// @dev Emits an {AllowToHook} event.\n ///\n /// Notes:\n /// - Does not revert if the contract is already on the allowlist.\n /// - This is an irreversible operation. The contract cannot be removed from the allowlist.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n /// - `recipient` must have a non-zero code size.\n /// - `recipient` must implement {ISablierLockupRecipient}.\n ///\n /// @param recipient The address of the contract to allow for hooks.\n function allowToHook(address recipient) external;\n\n /// @notice Burns the NFT associated with the stream.\n ///\n /// @dev Emits a {Transfer} event.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a depleted stream.\n /// - The NFT must exist.\n /// - `msg.sender` must be either the NFT owner or an approved third party.\n ///\n /// @param streamId The ID of the stream NFT to burn.\n function burn(uint256 streamId) external;\n\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\n ///\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\n /// stream is marked as depleted.\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - The stream must be warm and cancelable.\n /// - `msg.sender` must be the stream's sender.\n ///\n /// @param streamId The ID of the stream to cancel.\n function cancel(uint256 streamId) external;\n\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\n ///\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - Refer to the notes in {cancel}.\n ///\n /// Requirements:\n /// - All requirements from {cancel} must be met for each stream.\n ///\n /// @param streamIds The IDs of the streams to cancel.\n function cancelMultiple(uint256[] calldata streamIds) external;\n\n /// @notice Removes the right of the stream's sender to cancel the stream.\n ///\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This is an irreversible operation.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a warm stream.\n /// - `msg.sender` must be the stream's sender.\n /// - The stream must be cancelable.\n ///\n /// @param streamId The ID of the stream to renounce.\n function renounce(uint256 streamId) external;\n\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\n ///\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\n ///\n /// Notes:\n /// - Does not revert if the NFT descriptor is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n function setNFTDescriptor(\n ISablierV2NFTDescriptor newNFTDescriptor\n ) external;\n\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of the stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must not reference a null or depleted stream.\n /// - `to` must not be the zero address.\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\n /// - `to` must be the recipient if `msg.sender` is not the stream's recipient or an approved third party.\n ///\n /// @param streamId The ID of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\n function withdraw(uint256 streamId, address to, uint128 amount) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - Refer to the requirements in {withdraw}.\n ///\n /// @param streamId The ID of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\n function withdrawMax(\n uint256 streamId,\n address to\n ) external returns (uint128 withdrawnAmount);\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\n /// NFT to `newRecipient`.\n ///\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\n ///\n /// Notes:\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - `msg.sender` must be the stream's recipient.\n /// - Refer to the requirements in {withdraw}.\n /// - Refer to the requirements in {IERC721.transferFrom}.\n ///\n /// @param streamId The ID of the stream NFT to transfer.\n /// @param newRecipient The address of the new owner of the stream NFT.\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\n function withdrawMaxAndTransfer(\n uint256 streamId,\n address newRecipient\n ) external returns (uint128 withdrawnAmount);\n\n /// @notice Withdraws assets from streams to the recipient of each stream.\n ///\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - There must be an equal number of `streamIds` and `amounts`.\n /// - Each stream ID in the array must not reference a null or depleted stream.\n /// - Each amount in the array must be greater than zero and must not exceed the withdrawable amount.\n ///\n /// @param streamIds The IDs of the streams to withdraw from.\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\n function withdrawMultiple(\n uint256[] calldata streamIds,\n uint128[] calldata amounts\n ) external;\n}\n" + }, + "contracts/interfaces/sablier/full/ISablierV2NFTDescriptor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC721Metadata} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\n/// @title ISablierV2NFTDescriptor\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\n/// @dev Inspired by Uniswap V3 Positions NFTs.\ninterface ISablierV2NFTDescriptor {\n /// @notice Produces the URI describing a particular stream NFT.\n /// @dev This is a data URI with the JSON contents directly inlined.\n /// @param sablier The address of the Sablier contract the stream was created in.\n /// @param streamId The ID of the stream for which to produce a description.\n /// @return uri The URI of the ERC721-compliant metadata.\n function tokenURI(\n IERC721Metadata sablier,\n uint256 streamId\n ) external view returns (string memory uri);\n}\n" + }, + "contracts/interfaces/sablier/full/types/DataTypes.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {UD2x18} from \"@prb/math/src/UD2x18.sol\";\nimport {UD60x18} from \"@prb/math/src/UD60x18.sol\";\n\n// DataTypes.sol\n//\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\n//\n// - Lockup\n// - LockupDynamic\n// - LockupLinear\n// - LockupTranched\n//\n// You will notice that some structs contain \"slot\" annotations - they are used to indicate the\n// storage layout of the struct. It is more gas efficient to group small data types together so\n// that they fit in a single 32-byte slot.\n\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\n/// @param account The address receiving the broker's fee.\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\nstruct Broker {\n address account;\n UD60x18 fee;\n}\n\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\nlibrary Lockup {\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the asset's\n /// decimals.\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in the same slot\n /// saves gas.\n /// @param deposited The initial amount deposited in the stream, net of broker fee.\n /// @param withdrawn The cumulative amount withdrawn from the stream.\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\n struct Amounts {\n // slot 0\n uint128 deposited;\n uint128 withdrawn;\n // slot 1\n uint128 refunded;\n }\n\n /// @notice Struct encapsulating (i) the deposit amount and (ii) the broker fee amount, both denoted in units of the\n /// asset's decimals.\n /// @param deposit The amount to deposit in the stream.\n /// @param brokerFee The broker fee amount.\n struct CreateAmounts {\n uint128 deposit;\n uint128 brokerFee;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING,\n STREAMING,\n SETTLED,\n CANCELED,\n DEPLETED\n }\n\n /// @notice A common data structure to be stored in all {SablierV2Lockup} models.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address distributing the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\nlibrary LockupDynamic {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param segments Segments with durations used to compose the dynamic distribution function. Timestamps are\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n SegmentWithDuration[] segments;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param segments Segments used to compose the dynamic distribution function.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n uint40 startTime;\n Segment[] segments;\n Broker broker;\n }\n\n /// @notice Segment struct used in the Lockup Dynamic stream.\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\n /// @param timestamp The Unix timestamp indicating the segment's end.\n struct Segment {\n // slot 0\n uint128 amount;\n UD2x18 exponent;\n uint40 timestamp;\n }\n\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDurations}.\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\n /// @param duration The time difference in seconds between the segment and the previous one.\n struct SegmentWithDuration {\n uint128 amount;\n UD2x18 exponent;\n uint40 duration;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the segments.\n struct StreamLD {\n address sender;\n address recipient;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n Segment[] segments;\n }\n\n /// @notice Struct encapsulating the LockupDynamic timestamps.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 end;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\nlibrary LockupLinear {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param durations Struct encapsulating (i) cliff period duration and (ii) total stream duration, both in seconds.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Durations durations;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param timestamps Struct encapsulating (i) the stream's start time, (ii) cliff time, and (iii) end time, all as\n /// Unix timestamps.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the cliff duration and the total duration.\n /// @param cliff The cliff duration in seconds.\n /// @param total The total duration in seconds.\n struct Durations {\n uint40 cliff;\n uint40 total;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the cliff time.\n struct StreamLL {\n address sender;\n address recipient;\n uint40 startTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n uint40 endTime;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n uint40 cliffTime;\n }\n\n /// @notice Struct encapsulating the LockupLinear timestamps.\n /// @param start The Unix timestamp for the stream's start.\n /// @param cliff The Unix timestamp for the cliff period's end. A value of zero means there is no cliff.\n /// @param end The Unix timestamp for the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupTranched}.\nlibrary LockupTranched {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param tranches Tranches with durations used to compose the tranched distribution function. Timestamps are\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n TrancheWithDuration[] tranches;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param tranches Tranches used to compose the tranched distribution function.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n uint40 startTime;\n Tranche[] tranches;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the tranches.\n struct StreamLT {\n address sender;\n address recipient;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n Tranche[] tranches;\n }\n\n /// @notice Struct encapsulating the LockupTranched timestamps.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 end;\n }\n\n /// @notice Tranche struct used in the Lockup Tranched stream.\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\n /// @param timestamp The Unix timestamp indicating the tranche's end.\n struct Tranche {\n // slot 0\n uint128 amount;\n uint40 timestamp;\n }\n\n /// @notice Tranche struct used at runtime in {SablierV2LockupTranched.createWithDurations}.\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\n /// @param duration The time difference in seconds between the tranche and the previous one.\n struct TrancheWithDuration {\n uint128 amount;\n uint40 duration;\n }\n}\n" + }, + "contracts/interfaces/sablier/ISablierV2LockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {LockupLinear} from \"./LockupLinear.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface ISablierV2LockupLinear {\n function createWithTimestamps(\n LockupLinear.CreateWithTimestamps calldata params\n ) external returns (uint256 streamId);\n}\n" + }, + "contracts/interfaces/sablier/LockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nlibrary LockupLinear {\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n struct Broker {\n address account;\n uint256 fee;\n }\n}\n" + }, + "contracts/mocks/ERC6551Registry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IERC6551Registry {\n /**\n * @dev The registry MUST emit the ERC6551AccountCreated event upon successful account creation.\n */\n event ERC6551AccountCreated(\n address account,\n address indexed implementation,\n bytes32 salt,\n uint256 chainId,\n address indexed tokenContract,\n uint256 indexed tokenId\n );\n\n /**\n * @dev The registry MUST revert with AccountCreationFailed error if the create2 operation fails.\n */\n error AccountCreationFailed();\n\n /**\n * @dev Creates a token bound account for a non-fungible token.\n *\n * If account has already been created, returns the account address without calling create2.\n *\n * Emits ERC6551AccountCreated event.\n *\n * @return account The address of the token bound account\n */\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address account);\n\n /**\n * @dev Returns the computed token bound account address for a non-fungible token.\n *\n * @return account The address of the token bound account\n */\n function account(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external view returns (address account);\n}\n\ncontract ERC6551Registry is IERC6551Registry {\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address) {\n assembly {\n // Memory Layout:\n // ----\n // 0x00 0xff (1 byte)\n // 0x01 registry (address) (20 bytes)\n // 0x15 salt (bytes32) (32 bytes)\n // 0x35 Bytecode Hash (bytes32) (32 bytes)\n // ----\n // 0x55 ERC-1167 Constructor + Header (20 bytes)\n // 0x69 implementation (address) (20 bytes)\n // 0x5D ERC-1167 Footer (15 bytes)\n // 0x8C salt (uint256) (32 bytes)\n // 0xAC chainId (uint256) (32 bytes)\n // 0xCC tokenContract (address) (32 bytes)\n // 0xEC tokenId (uint256) (32 bytes)\n\n // Silence unused variable warnings\n pop(chainId)\n\n // Copy bytecode + constant data to memory\n calldatacopy(0x8c, 0x24, 0x80) // salt, chainId, tokenContract, tokenId\n mstore(0x6c, 0x5af43d82803e903d91602b57fd5bf3) // ERC-1167 footer\n mstore(0x5d, implementation) // implementation\n mstore(0x49, 0x3d60ad80600a3d3981f3363d3d373d3d3d363d73) // ERC-1167 constructor + header\n\n // Copy create2 computation data to memory\n mstore8(0x00, 0xff) // 0xFF\n mstore(0x35, keccak256(0x55, 0xb7)) // keccak256(bytecode)\n mstore(0x01, shl(96, address())) // registry address\n mstore(0x15, salt) // salt\n\n // Compute account address\n let computed := keccak256(0x00, 0x55)\n\n // If the account has not yet been deployed\n if iszero(extcodesize(computed)) {\n // Deploy account contract\n let deployed := create2(0, 0x55, 0xb7, salt)\n\n // Revert if the deployment fails\n if iszero(deployed) {\n mstore(0x00, 0x20188a59) // `AccountCreationFailed()`\n revert(0x1c, 0x04)\n }\n\n // Store account address in memory before salt and chainId\n mstore(0x6c, deployed)\n\n // Emit the ERC6551AccountCreated event\n log4(\n 0x6c,\n 0x60,\n // `ERC6551AccountCreated(address,address,bytes32,uint256,address,uint256)`\n 0x79f19b3655ee38b1ce526556b7731a20c8f218fbda4a3990b6cc4172fdf88722,\n implementation,\n tokenContract,\n tokenId\n )\n\n // Return the account address\n return(0x6c, 0x20)\n }\n\n // Otherwise, return the computed account address\n mstore(0x00, shr(96, shl(96, computed)))\n return(0x00, 0x20)\n }\n }\n\n function account(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external view returns (address) {\n assembly {\n // Silence unused variable warnings\n pop(chainId)\n pop(tokenContract)\n pop(tokenId)\n\n // Copy bytecode + constant data to memory\n calldatacopy(0x8c, 0x24, 0x80) // salt, chainId, tokenContract, tokenId\n mstore(0x6c, 0x5af43d82803e903d91602b57fd5bf3) // ERC-1167 footer\n mstore(0x5d, implementation) // implementation\n mstore(0x49, 0x3d60ad80600a3d3981f3363d3d373d3d3d363d73) // ERC-1167 constructor + header\n\n // Copy create2 computation data to memory\n mstore8(0x00, 0xff) // 0xFF\n mstore(0x35, keccak256(0x55, 0xb7)) // keccak256(bytecode)\n mstore(0x01, shl(96, address())) // registry address\n mstore(0x15, salt) // salt\n\n // Store computed account address in memory\n mstore(0x00, shr(96, shl(96, keccak256(0x00, 0x55))))\n\n // Return computed account address\n return(0x00, 0x20)\n }\n }\n}\n" + }, + "contracts/mocks/MockContract.sol": { + "content": "//SPDX-License-Identifier: Unlicense\n\npragma solidity ^0.8.19;\n\n/**\n * Mock contract for testing\n */\ncontract MockContract {\n event DidSomething(string message);\n\n error Reverting();\n\n function doSomething() public {\n doSomethingWithParam(\"doSomething()\");\n }\n\n function doSomethingWithParam(string memory _message) public {\n emit DidSomething(_message);\n }\n\n function returnSomething(string memory _s)\n external\n pure\n returns (string memory)\n {\n return _s;\n }\n\n function revertSomething() external pure {\n revert Reverting();\n }\n}\n" + }, + "contracts/mocks/MockLockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nlibrary MockLockupLinear {\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n struct Broker {\n address account;\n uint256 fee;\n }\n\n struct Stream {\n address sender;\n uint40 startTime;\n uint40 endTime;\n uint40 cliffTime;\n bool cancelable;\n bool wasCanceled;\n address asset;\n bool transferable;\n uint128 totalAmount;\n address recipient;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING,\n STREAMING,\n SETTLED,\n CANCELED,\n DEPLETED\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file From bdfe98f3bd564166d0bb722ea836c19e195112e9 Mon Sep 17 00:00:00 2001 From: Kellar Date: Thu, 10 Oct 2024 17:35:35 +0100 Subject: [PATCH 2/3] Deploy contracts --- .../base/DecentSablierStreamManagement.json | 100 +++++ .../4511b61209438ca20d2458493e70bb24.json | 351 ++++++++++++++++++ .../DecentSablierStreamManagement.json | 100 +++++ .../4511b61209438ca20d2458493e70bb24.json | 351 ++++++++++++++++++ .../DecentSablierStreamManagement.json | 100 +++++ .../4511b61209438ca20d2458493e70bb24.json | 351 ++++++++++++++++++ .../DecentSablierStreamManagement.json | 116 ++++++ .../4511b61209438ca20d2458493e70bb24.json | 351 ++++++++++++++++++ 8 files changed, 1820 insertions(+) create mode 100644 deployments/base/DecentSablierStreamManagement.json create mode 100644 deployments/base/solcInputs/4511b61209438ca20d2458493e70bb24.json create mode 100644 deployments/mainnet/DecentSablierStreamManagement.json create mode 100644 deployments/mainnet/solcInputs/4511b61209438ca20d2458493e70bb24.json create mode 100644 deployments/optimism/DecentSablierStreamManagement.json create mode 100644 deployments/optimism/solcInputs/4511b61209438ca20d2458493e70bb24.json create mode 100644 deployments/polygon/DecentSablierStreamManagement.json create mode 100644 deployments/polygon/solcInputs/4511b61209438ca20d2458493e70bb24.json diff --git a/deployments/base/DecentSablierStreamManagement.json b/deployments/base/DecentSablierStreamManagement.json new file mode 100644 index 00000000..a4695b56 --- /dev/null +++ b/deployments/base/DecentSablierStreamManagement.json @@ -0,0 +1,100 @@ +{ + "address": "0x10295461bf4ad03A76Bf29d8e98bf068ec333854", + "abi": [ + { + "inputs": [], + "name": "NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ISablierV2Lockup", + "name": "sablier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + } + ], + "name": "cancelStream", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ISablierV2Lockup", + "name": "sablier", + "type": "address" + }, + { + "internalType": "address", + "name": "recipientHatAccount", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "withdrawMaxFromStream", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xe8c58dad912fb02c5477f4d221e92994a80fbc2b8d26c05da7f394582c9451bb", + "receipt": { + "to": null, + "from": "0xb5Ca125166C1987A35EDD550E16846Fa1e1D9bB3", + "contractAddress": "0x10295461bf4ad03A76Bf29d8e98bf068ec333854", + "transactionIndex": 95, + "gasUsed": "384441", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xe2639b222eafa8314a402b10a98cab3ca4ca1143cbfdf696850f1a07b2a4256a", + "transactionHash": "0xe8c58dad912fb02c5477f4d221e92994a80fbc2b8d26c05da7f394582c9451bb", + "logs": [], + "blockNumber": 20894292, + "cumulativeGasUsed": "20584732", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4511b61209438ca20d2458493e70bb24", + "metadata": "{\"compiler\":{\"version\":\"0.8.28+commit.7893614a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"NAME\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISablierV2Lockup\",\"name\":\"sablier\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"streamId\",\"type\":\"uint256\"}],\"name\":\"cancelStream\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISablierV2Lockup\",\"name\":\"sablier\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipientHatAccount\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"streamId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"withdrawMaxFromStream\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/DecentSablierStreamManagement.sol\":\"DecentSablierStreamManagement\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only\\npragma solidity >=0.7.0 <0.9.0;\\n\\n/// @title Enum - Collection of enums\\n/// @author Richard Meissner - \\ncontract Enum {\\n enum Operation {Call, DelegateCall}\\n}\\n\",\"keccak256\":\"0x473e45b1a5cc47be494b0e123c9127f0c11c1e0992a321ae5a644c0bfdb2c14f\",\"license\":\"LGPL-3.0-only\"},\"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only\\n\\n/// @title Zodiac Avatar - A contract that manages modules that can execute transactions via this contract.\\npragma solidity >=0.7.0 <0.9.0;\\n\\nimport \\\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\\\";\\n\\ninterface IAvatar {\\n event EnabledModule(address module);\\n event DisabledModule(address module);\\n event ExecutionFromModuleSuccess(address indexed module);\\n event ExecutionFromModuleFailure(address indexed module);\\n\\n /// @dev Enables a module on the avatar.\\n /// @notice Can only be called by the avatar.\\n /// @notice Modules should be stored as a linked list.\\n /// @notice Must emit EnabledModule(address module) if successful.\\n /// @param module Module to be enabled.\\n function enableModule(address module) external;\\n\\n /// @dev Disables a module on the avatar.\\n /// @notice Can only be called by the avatar.\\n /// @notice Must emit DisabledModule(address module) if successful.\\n /// @param prevModule Address that pointed to the module to be removed in the linked list\\n /// @param module Module to be removed.\\n function disableModule(address prevModule, address module) external;\\n\\n /// @dev Allows a Module to execute a transaction.\\n /// @notice Can only be called by an enabled module.\\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\\n function execTransactionFromModule(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation\\n ) external returns (bool success);\\n\\n /// @dev Allows a Module to execute a transaction and return data\\n /// @notice Can only be called by an enabled module.\\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\\n function execTransactionFromModuleReturnData(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation\\n ) external returns (bool success, bytes memory returnData);\\n\\n /// @dev Returns if an module is enabled\\n /// @return True if the module is enabled\\n function isModuleEnabled(address module) external view returns (bool);\\n\\n /// @dev Returns array of modules.\\n /// @param start Start of the page.\\n /// @param pageSize Maximum number of modules that should be returned.\\n /// @return array Array of modules.\\n /// @return next Start of the next page.\\n function getModulesPaginated(address start, uint256 pageSize)\\n external\\n view\\n returns (address[] memory array, address next);\\n}\\n\",\"keccak256\":\"0xcd5508ffe596eef8fbccfd5fc4f10a34397773547ce64e212d48b5212865ec1f\",\"license\":\"LGPL-3.0-only\"},\"@openzeppelin/contracts/interfaces/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/introspection/IERC165.sol\\\";\\n\",\"keccak256\":\"0xd04b0f06e0666f29cf7cccc82894de541e19bb30a765b107b1e40bb7fe5f7d7a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xed6a749c5373af398105ce6ee3ac4763aa450ea7285d268c85d9eeca809cdb1f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Metadata is IERC721 {\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x75b829ff2f26c14355d1cba20e16fe7b29ca58eb5fef665ede48bc0f9c6c74b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\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[EIP 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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@prb/math/src/Common.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n// Common.sol\\n//\\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\\n// always operate with SD59x18 and UD60x18 numbers.\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CUSTOM ERRORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\\n\\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\\n\\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\\nerror PRBMath_MulDivSigned_InputTooSmall();\\n\\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CONSTANTS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @dev The maximum value a uint128 number can have.\\nuint128 constant MAX_UINT128 = type(uint128).max;\\n\\n/// @dev The maximum value a uint40 number can have.\\nuint40 constant MAX_UINT40 = type(uint40).max;\\n\\n/// @dev The unit number, which the decimal precision of the fixed-point types.\\nuint256 constant UNIT = 1e18;\\n\\n/// @dev The unit number inverted mod 2^256.\\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\\n\\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\\n/// bit in the binary representation of `UNIT`.\\nuint256 constant UNIT_LPOTD = 262144;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method.\\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(uint256 x) pure returns (uint256 result) {\\n unchecked {\\n // Start from 0.5 in the 192.64-bit fixed-point format.\\n result = 0x800000000000000000000000000000000000000000000000;\\n\\n // The following logic multiplies the result by $\\\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\\n //\\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\\n // we know that `x & 0xFF` is also 1.\\n if (x & 0xFF00000000000000 > 0) {\\n if (x & 0x8000000000000000 > 0) {\\n result = (result * 0x16A09E667F3BCC909) >> 64;\\n }\\n if (x & 0x4000000000000000 > 0) {\\n result = (result * 0x1306FE0A31B7152DF) >> 64;\\n }\\n if (x & 0x2000000000000000 > 0) {\\n result = (result * 0x1172B83C7D517ADCE) >> 64;\\n }\\n if (x & 0x1000000000000000 > 0) {\\n result = (result * 0x10B5586CF9890F62A) >> 64;\\n }\\n if (x & 0x800000000000000 > 0) {\\n result = (result * 0x1059B0D31585743AE) >> 64;\\n }\\n if (x & 0x400000000000000 > 0) {\\n result = (result * 0x102C9A3E778060EE7) >> 64;\\n }\\n if (x & 0x200000000000000 > 0) {\\n result = (result * 0x10163DA9FB33356D8) >> 64;\\n }\\n if (x & 0x100000000000000 > 0) {\\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\\n }\\n }\\n\\n if (x & 0xFF000000000000 > 0) {\\n if (x & 0x80000000000000 > 0) {\\n result = (result * 0x10058C86DA1C09EA2) >> 64;\\n }\\n if (x & 0x40000000000000 > 0) {\\n result = (result * 0x1002C605E2E8CEC50) >> 64;\\n }\\n if (x & 0x20000000000000 > 0) {\\n result = (result * 0x100162F3904051FA1) >> 64;\\n }\\n if (x & 0x10000000000000 > 0) {\\n result = (result * 0x1000B175EFFDC76BA) >> 64;\\n }\\n if (x & 0x8000000000000 > 0) {\\n result = (result * 0x100058BA01FB9F96D) >> 64;\\n }\\n if (x & 0x4000000000000 > 0) {\\n result = (result * 0x10002C5CC37DA9492) >> 64;\\n }\\n if (x & 0x2000000000000 > 0) {\\n result = (result * 0x1000162E525EE0547) >> 64;\\n }\\n if (x & 0x1000000000000 > 0) {\\n result = (result * 0x10000B17255775C04) >> 64;\\n }\\n }\\n\\n if (x & 0xFF0000000000 > 0) {\\n if (x & 0x800000000000 > 0) {\\n result = (result * 0x1000058B91B5BC9AE) >> 64;\\n }\\n if (x & 0x400000000000 > 0) {\\n result = (result * 0x100002C5C89D5EC6D) >> 64;\\n }\\n if (x & 0x200000000000 > 0) {\\n result = (result * 0x10000162E43F4F831) >> 64;\\n }\\n if (x & 0x100000000000 > 0) {\\n result = (result * 0x100000B1721BCFC9A) >> 64;\\n }\\n if (x & 0x80000000000 > 0) {\\n result = (result * 0x10000058B90CF1E6E) >> 64;\\n }\\n if (x & 0x40000000000 > 0) {\\n result = (result * 0x1000002C5C863B73F) >> 64;\\n }\\n if (x & 0x20000000000 > 0) {\\n result = (result * 0x100000162E430E5A2) >> 64;\\n }\\n if (x & 0x10000000000 > 0) {\\n result = (result * 0x1000000B172183551) >> 64;\\n }\\n }\\n\\n if (x & 0xFF00000000 > 0) {\\n if (x & 0x8000000000 > 0) {\\n result = (result * 0x100000058B90C0B49) >> 64;\\n }\\n if (x & 0x4000000000 > 0) {\\n result = (result * 0x10000002C5C8601CC) >> 64;\\n }\\n if (x & 0x2000000000 > 0) {\\n result = (result * 0x1000000162E42FFF0) >> 64;\\n }\\n if (x & 0x1000000000 > 0) {\\n result = (result * 0x10000000B17217FBB) >> 64;\\n }\\n if (x & 0x800000000 > 0) {\\n result = (result * 0x1000000058B90BFCE) >> 64;\\n }\\n if (x & 0x400000000 > 0) {\\n result = (result * 0x100000002C5C85FE3) >> 64;\\n }\\n if (x & 0x200000000 > 0) {\\n result = (result * 0x10000000162E42FF1) >> 64;\\n }\\n if (x & 0x100000000 > 0) {\\n result = (result * 0x100000000B17217F8) >> 64;\\n }\\n }\\n\\n if (x & 0xFF000000 > 0) {\\n if (x & 0x80000000 > 0) {\\n result = (result * 0x10000000058B90BFC) >> 64;\\n }\\n if (x & 0x40000000 > 0) {\\n result = (result * 0x1000000002C5C85FE) >> 64;\\n }\\n if (x & 0x20000000 > 0) {\\n result = (result * 0x100000000162E42FF) >> 64;\\n }\\n if (x & 0x10000000 > 0) {\\n result = (result * 0x1000000000B17217F) >> 64;\\n }\\n if (x & 0x8000000 > 0) {\\n result = (result * 0x100000000058B90C0) >> 64;\\n }\\n if (x & 0x4000000 > 0) {\\n result = (result * 0x10000000002C5C860) >> 64;\\n }\\n if (x & 0x2000000 > 0) {\\n result = (result * 0x1000000000162E430) >> 64;\\n }\\n if (x & 0x1000000 > 0) {\\n result = (result * 0x10000000000B17218) >> 64;\\n }\\n }\\n\\n if (x & 0xFF0000 > 0) {\\n if (x & 0x800000 > 0) {\\n result = (result * 0x1000000000058B90C) >> 64;\\n }\\n if (x & 0x400000 > 0) {\\n result = (result * 0x100000000002C5C86) >> 64;\\n }\\n if (x & 0x200000 > 0) {\\n result = (result * 0x10000000000162E43) >> 64;\\n }\\n if (x & 0x100000 > 0) {\\n result = (result * 0x100000000000B1721) >> 64;\\n }\\n if (x & 0x80000 > 0) {\\n result = (result * 0x10000000000058B91) >> 64;\\n }\\n if (x & 0x40000 > 0) {\\n result = (result * 0x1000000000002C5C8) >> 64;\\n }\\n if (x & 0x20000 > 0) {\\n result = (result * 0x100000000000162E4) >> 64;\\n }\\n if (x & 0x10000 > 0) {\\n result = (result * 0x1000000000000B172) >> 64;\\n }\\n }\\n\\n if (x & 0xFF00 > 0) {\\n if (x & 0x8000 > 0) {\\n result = (result * 0x100000000000058B9) >> 64;\\n }\\n if (x & 0x4000 > 0) {\\n result = (result * 0x10000000000002C5D) >> 64;\\n }\\n if (x & 0x2000 > 0) {\\n result = (result * 0x1000000000000162E) >> 64;\\n }\\n if (x & 0x1000 > 0) {\\n result = (result * 0x10000000000000B17) >> 64;\\n }\\n if (x & 0x800 > 0) {\\n result = (result * 0x1000000000000058C) >> 64;\\n }\\n if (x & 0x400 > 0) {\\n result = (result * 0x100000000000002C6) >> 64;\\n }\\n if (x & 0x200 > 0) {\\n result = (result * 0x10000000000000163) >> 64;\\n }\\n if (x & 0x100 > 0) {\\n result = (result * 0x100000000000000B1) >> 64;\\n }\\n }\\n\\n if (x & 0xFF > 0) {\\n if (x & 0x80 > 0) {\\n result = (result * 0x10000000000000059) >> 64;\\n }\\n if (x & 0x40 > 0) {\\n result = (result * 0x1000000000000002C) >> 64;\\n }\\n if (x & 0x20 > 0) {\\n result = (result * 0x10000000000000016) >> 64;\\n }\\n if (x & 0x10 > 0) {\\n result = (result * 0x1000000000000000B) >> 64;\\n }\\n if (x & 0x8 > 0) {\\n result = (result * 0x10000000000000006) >> 64;\\n }\\n if (x & 0x4 > 0) {\\n result = (result * 0x10000000000000003) >> 64;\\n }\\n if (x & 0x2 > 0) {\\n result = (result * 0x10000000000000001) >> 64;\\n }\\n if (x & 0x1 > 0) {\\n result = (result * 0x10000000000000001) >> 64;\\n }\\n }\\n\\n // In the code snippet below, two operations are executed simultaneously:\\n //\\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\\n //\\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\\n // integer part, $2^n$.\\n result *= UNIT;\\n result >>= (191 - (x >> 64));\\n }\\n}\\n\\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\\n///\\n/// @dev See the note on \\\"msb\\\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\\n///\\n/// Each step in this implementation is equivalent to this high-level code:\\n///\\n/// ```solidity\\n/// if (x >= 2 ** 128) {\\n/// x >>= 128;\\n/// result += 128;\\n/// }\\n/// ```\\n///\\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\\n///\\n/// The Yul instructions used below are:\\n///\\n/// - \\\"gt\\\" is \\\"greater than\\\"\\n/// - \\\"or\\\" is the OR bitwise operator\\n/// - \\\"shl\\\" is \\\"shift left\\\"\\n/// - \\\"shr\\\" is \\\"shift right\\\"\\n///\\n/// @param x The uint256 number for which to find the index of the most significant bit.\\n/// @return result The index of the most significant bit as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction msb(uint256 x) pure returns (uint256 result) {\\n // 2^128\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^64\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^32\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(5, gt(x, 0xFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^16\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(4, gt(x, 0xFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^8\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(3, gt(x, 0xFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^4\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(2, gt(x, 0xF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^2\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(1, gt(x, 0x3))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^1\\n // No need to shift x any more.\\n assembly (\\\"memory-safe\\\") {\\n let factor := gt(x, 0x1)\\n result := or(result, factor)\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f7denominator with 512-bit precision.\\n///\\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - The denominator must not be zero.\\n/// - The result must fit in uint256.\\n///\\n/// @param x The multiplicand as a uint256.\\n/// @param y The multiplier as a uint256.\\n/// @param denominator The divisor as a uint256.\\n/// @return result The result as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly (\\\"memory-safe\\\") {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n unchecked {\\n return prod0 / denominator;\\n }\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n if (prod1 >= denominator) {\\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\\n }\\n\\n ////////////////////////////////////////////////////////////////////////////\\n // 512 by 256 division\\n ////////////////////////////////////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly (\\\"memory-safe\\\") {\\n // Compute remainder using the mulmod Yul instruction.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512-bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n unchecked {\\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\\n uint256 lpotdod = denominator & (~denominator + 1);\\n uint256 flippedLpotdod;\\n\\n assembly (\\\"memory-safe\\\") {\\n // Factor powers of two out of denominator.\\n denominator := div(denominator, lpotdod)\\n\\n // Divide [prod1 prod0] by lpotdod.\\n prod0 := div(prod0, lpotdod)\\n\\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * flippedLpotdod;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\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 works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\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^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f71e18 with 512-bit precision.\\n///\\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\\n///\\n/// Notes:\\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\\n/// - The result is rounded toward zero.\\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\\n///\\n/// $$\\n/// \\\\begin{cases}\\n/// x * y = MAX\\\\_UINT256 * UNIT \\\\\\\\\\n/// (x * y) \\\\% UNIT \\\\geq \\\\frac{UNIT}{2}\\n/// \\\\end{cases}\\n/// $$\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {mulDiv}.\\n/// - The result must fit in uint256.\\n///\\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\\n uint256 prod0;\\n uint256 prod1;\\n assembly (\\\"memory-safe\\\") {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n if (prod1 == 0) {\\n unchecked {\\n return prod0 / UNIT;\\n }\\n }\\n\\n if (prod1 >= UNIT) {\\n revert PRBMath_MulDiv18_Overflow(x, y);\\n }\\n\\n uint256 remainder;\\n assembly (\\\"memory-safe\\\") {\\n remainder := mulmod(x, y, UNIT)\\n result :=\\n mul(\\n or(\\n div(sub(prod0, remainder), UNIT_LPOTD),\\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\\n ),\\n UNIT_INVERSE\\n )\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f7denominator with 512-bit precision.\\n///\\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {mulDiv}.\\n/// - None of the inputs can be `type(int256).min`.\\n/// - The result must fit in int256.\\n///\\n/// @param x The multiplicand as an int256.\\n/// @param y The multiplier as an int256.\\n/// @param denominator The divisor as an int256.\\n/// @return result The result as an int256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\\n revert PRBMath_MulDivSigned_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x, y and the denominator.\\n uint256 xAbs;\\n uint256 yAbs;\\n uint256 dAbs;\\n unchecked {\\n xAbs = x < 0 ? uint256(-x) : uint256(x);\\n yAbs = y < 0 ? uint256(-y) : uint256(y);\\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\\n }\\n\\n // Compute the absolute value of x*y\\u00f7denominator. The result must fit in int256.\\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\\n if (resultAbs > uint256(type(int256).max)) {\\n revert PRBMath_MulDivSigned_Overflow(x, y);\\n }\\n\\n // Get the signs of x, y and the denominator.\\n uint256 sx;\\n uint256 sy;\\n uint256 sd;\\n assembly (\\\"memory-safe\\\") {\\n // \\\"sgt\\\" is the \\\"signed greater than\\\" assembly instruction and \\\"sub(0,1)\\\" is -1 in two's complement.\\n sx := sgt(x, sub(0, 1))\\n sy := sgt(y, sub(0, 1))\\n sd := sgt(denominator, sub(0, 1))\\n }\\n\\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\\n // If there are, the result should be negative. Otherwise, it should be positive.\\n unchecked {\\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\\n }\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - If x is not a perfect square, the result is rounded down.\\n/// - Credits to OpenZeppelin for the explanations in comments below.\\n///\\n/// @param x The uint256 number for which to calculate the square root.\\n/// @return result The result as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(uint256 x) pure returns (uint256 result) {\\n if (x == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of x is a power of 2 such that we have:\\n //\\n // $$\\n // msb(x) <= x <= 2*msb(x)$\\n // $$\\n //\\n // We write $msb(x)$ as $2^k$, and we get:\\n //\\n // $$\\n // k = log_2(x)\\n // $$\\n //\\n // Thus, we can write the initial inequality as:\\n //\\n // $$\\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\\\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\\\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\\n // $$\\n //\\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\\n uint256 xAux = uint256(x);\\n result = 1;\\n if (xAux >= 2 ** 128) {\\n xAux >>= 128;\\n result <<= 64;\\n }\\n if (xAux >= 2 ** 64) {\\n xAux >>= 64;\\n result <<= 32;\\n }\\n if (xAux >= 2 ** 32) {\\n xAux >>= 32;\\n result <<= 16;\\n }\\n if (xAux >= 2 ** 16) {\\n xAux >>= 16;\\n result <<= 8;\\n }\\n if (xAux >= 2 ** 8) {\\n xAux >>= 8;\\n result <<= 4;\\n }\\n if (xAux >= 2 ** 4) {\\n xAux >>= 4;\\n result <<= 2;\\n }\\n if (xAux >= 2 ** 2) {\\n result <<= 1;\\n }\\n\\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\\n // precision into the expected uint128 result.\\n unchecked {\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n\\n // If x is not a perfect square, round the result toward zero.\\n uint256 roundedResult = x / result;\\n if (result >= roundedResult) {\\n result = roundedResult;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaa374e2c26cc93e8c22a6953804ee05f811597ef5fa82f76824378b22944778b\",\"license\":\"MIT\"},\"@prb/math/src/UD2x18.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n/*\\n\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2588\\u2588\\u2554\\u2550\\u2550\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u2588\\u2588\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u255a\\u2550\\u255d \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\n\\n\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u255d\\n\\n*/\\n\\nimport \\\"./ud2x18/Casting.sol\\\";\\nimport \\\"./ud2x18/Constants.sol\\\";\\nimport \\\"./ud2x18/Errors.sol\\\";\\nimport \\\"./ud2x18/ValueType.sol\\\";\\n\",\"keccak256\":\"0xfb624e24cd8bb790fa08e7827819de85504a86e20e961fa4ad126c65b6d90641\",\"license\":\"MIT\"},\"@prb/math/src/UD60x18.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n/*\\n\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2588\\u2588\\u2554\\u2550\\u2550\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u2588\\u2588\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u255a\\u2550\\u255d \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\n\\n\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2588\\u2588\\u2588\\u2588\\u2557\\u255a\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551 \\u255a\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u255d \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u255d\\n\\n*/\\n\\nimport \\\"./ud60x18/Casting.sol\\\";\\nimport \\\"./ud60x18/Constants.sol\\\";\\nimport \\\"./ud60x18/Conversions.sol\\\";\\nimport \\\"./ud60x18/Errors.sol\\\";\\nimport \\\"./ud60x18/Helpers.sol\\\";\\nimport \\\"./ud60x18/Math.sol\\\";\\nimport \\\"./ud60x18/ValueType.sol\\\";\\n\",\"keccak256\":\"0xb98c6f74275914d279e8af6c502c2b1f50d5f6e1ed418d3b0153f5a193206c48\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts an SD1x18 number into SD59x18.\\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\\n}\\n\\n/// @notice Casts an SD1x18 number into UD2x18.\\n/// - x must be positive.\\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\\n }\\n result = UD2x18.wrap(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into UD60x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\\n }\\n result = UD60x18.wrap(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint256.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\\n }\\n result = uint256(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\\n }\\n result = uint128(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\\n }\\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\\n }\\n result = uint40(uint64(xInt));\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\\n result = SD1x18.wrap(x);\\n}\\n\\n/// @notice Unwraps an SD1x18 number into int64.\\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\\n result = SD1x18.unwrap(x);\\n}\\n\\n/// @notice Wraps an int64 number into SD1x18.\\nfunction wrap(int64 x) pure returns (SD1x18 result) {\\n result = SD1x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x9e49e2b37c1bb845861740805edaaef3fe951a7b96eef16ce84fbf76e8278670\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @dev Euler's number as an SD1x18 number.\\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum value an SD1x18 number can have.\\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\\n\\n/// @dev The maximum value an SD1x18 number can have.\\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\\n\\n/// @dev PI as an SD1x18 number.\\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of SD1x18.\\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\\nint64 constant uUNIT = 1e18;\\n\",\"keccak256\":\"0x6496165b80552785a4b65a239b96e2a5fedf62fe54f002eeed72d75e566d7585\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\\n\",\"keccak256\":\"0x836cb42ba619ca369fd4765bc47fefc3c3621369c5861882af14660aca5057ee\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\n\\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\\n/// storage.\\ntype SD1x18 is int64;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD59x18,\\n Casting.intoUD2x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for SD1x18 global;\\n\",\"keccak256\":\"0x2f86f1aa9fca42f40808b51a879b406ac51817647bdb9642f8a79dd8fdb754a7\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { MAX_UINT128, MAX_UINT40 } from \\\"../Common.sol\\\";\\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { uMAX_UD2x18 } from \\\"../ud2x18/Constants.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts an SD59x18 number into int256.\\n/// @dev This is basically a functional alias for {unwrap}.\\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\\n result = SD59x18.unwrap(x);\\n}\\n\\n/// @notice Casts an SD59x18 number into SD1x18.\\n/// @dev Requirements:\\n/// - x must be greater than or equal to `uMIN_SD1x18`.\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < uMIN_SD1x18) {\\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\\n }\\n if (xInt > uMAX_SD1x18) {\\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into UD2x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `uMAX_UD2x18`.\\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\\n }\\n if (xInt > int256(uint256(uMAX_UD2x18))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\\n }\\n result = UD2x18.wrap(uint64(uint256(xInt)));\\n}\\n\\n/// @notice Casts an SD59x18 number into UD60x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\\n }\\n result = UD60x18.wrap(uint256(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into uint256.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\\n }\\n result = uint256(xInt);\\n}\\n\\n/// @notice Casts an SD59x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `uMAX_UINT128`.\\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\\n }\\n if (xInt > int256(uint256(MAX_UINT128))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\\n }\\n result = uint128(uint256(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\\n }\\n if (xInt > int256(uint256(MAX_UINT40))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(uint256(xInt));\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\\n/// @notice Unwraps an SD59x18 number into int256.\\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\\n result = SD59x18.unwrap(x);\\n}\\n\\n/// @notice Wraps an int256 number into SD59x18.\\nfunction wrap(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x3b21b60ec2998c3ae32f647412da51d3683b3f183a807198cc8d157499484f99\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n// NOTICE: the \\\"u\\\" prefix stands for \\\"unwrapped\\\".\\n\\n/// @dev Euler's number as an SD59x18 number.\\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum input permitted in {exp}.\\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\\n\\n/// @dev Any value less than this returns 0 in {exp}.\\nint256 constant uEXP_MIN_THRESHOLD = -41_446531673892822322;\\nSD59x18 constant EXP_MIN_THRESHOLD = SD59x18.wrap(uEXP_MIN_THRESHOLD);\\n\\n/// @dev The maximum input permitted in {exp2}.\\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\\n\\n/// @dev Any value less than this returns 0 in {exp2}.\\nint256 constant uEXP2_MIN_THRESHOLD = -59_794705707972522261;\\nSD59x18 constant EXP2_MIN_THRESHOLD = SD59x18.wrap(uEXP2_MIN_THRESHOLD);\\n\\n/// @dev Half the UNIT number.\\nint256 constant uHALF_UNIT = 0.5e18;\\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\\n\\n/// @dev $log_2(10)$ as an SD59x18 number.\\nint256 constant uLOG2_10 = 3_321928094887362347;\\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\\n\\n/// @dev $log_2(e)$ as an SD59x18 number.\\nint256 constant uLOG2_E = 1_442695040888963407;\\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\\n\\n/// @dev The maximum value an SD59x18 number can have.\\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\\n\\n/// @dev The maximum whole value an SD59x18 number can have.\\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\\n\\n/// @dev The minimum value an SD59x18 number can have.\\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\\n\\n/// @dev The minimum whole value an SD59x18 number can have.\\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\\n\\n/// @dev PI as an SD59x18 number.\\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of SD59x18.\\nint256 constant uUNIT = 1e18;\\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\\n\\n/// @dev The unit number squared.\\nint256 constant uUNIT_SQUARED = 1e36;\\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\\n\\n/// @dev Zero as an SD59x18 number.\\nSD59x18 constant ZERO = SD59x18.wrap(0);\\n\",\"keccak256\":\"0x9bcb8dd6b3e886d140ad1c32747a4f6d29a492529ceb835be878ae837aa6cc3a\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Abs_MinSD59x18();\\n\\n/// @notice Thrown when ceiling a number overflows SD59x18.\\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\\n\\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Div_InputTooSmall();\\n\\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\\n\\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\\n\\n/// @notice Thrown when flooring a number underflows SD59x18.\\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\\n\\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Mul_InputTooSmall();\\n\\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\\n\\n/// @notice Thrown when taking the square root of a negative number.\\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\\n\\n/// @notice Thrown when the calculating the square root overflows SD59x18.\\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\\n\",\"keccak256\":\"0xa6d00fe5efa215ac0df25c896e3da99a12fb61e799644b2ec32da947313d3db4\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() + y.unwrap());\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() & bits);\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() & y.unwrap());\\n}\\n\\n/// @notice Implements the equal (=) operation in the SD59x18 type.\\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() == y.unwrap();\\n}\\n\\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() > y.unwrap();\\n}\\n\\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() >= y.unwrap();\\n}\\n\\n/// @notice Implements a zero comparison check function in the SD59x18 type.\\nfunction isZero(SD59x18 x) pure returns (bool result) {\\n result = x.unwrap() == 0;\\n}\\n\\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() << bits);\\n}\\n\\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() < y.unwrap();\\n}\\n\\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() <= y.unwrap();\\n}\\n\\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() % y.unwrap());\\n}\\n\\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() != y.unwrap();\\n}\\n\\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(~x.unwrap());\\n}\\n\\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() | y.unwrap());\\n}\\n\\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() >> bits);\\n}\\n\\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() - y.unwrap());\\n}\\n\\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(-x.unwrap());\\n}\\n\\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() + y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() - y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(-x.unwrap());\\n }\\n}\\n\\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() ^ y.unwrap());\\n}\\n\",\"keccak256\":\"0x208570f1657cf730cb6c3d81aa14030e0d45cf906cdedea5059369d7df4bb716\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport {\\n uEXP_MAX_INPUT,\\n uEXP2_MAX_INPUT,\\n uEXP_MIN_THRESHOLD,\\n uEXP2_MIN_THRESHOLD,\\n uHALF_UNIT,\\n uLOG2_10,\\n uLOG2_E,\\n uMAX_SD59x18,\\n uMAX_WHOLE_SD59x18,\\n uMIN_SD59x18,\\n uMIN_WHOLE_SD59x18,\\n UNIT,\\n uUNIT,\\n uUNIT_SQUARED,\\n ZERO\\n} from \\\"./Constants.sol\\\";\\nimport { wrap } from \\\"./Helpers.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Calculates the absolute value of x.\\n///\\n/// @dev Requirements:\\n/// - x must be greater than `MIN_SD59x18`.\\n///\\n/// @param x The SD59x18 number for which to calculate the absolute value.\\n/// @param result The absolute value of x as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\\n }\\n result = xInt < 0 ? wrap(-xInt) : x;\\n}\\n\\n/// @notice Calculates the arithmetic average of x and y.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// @param x The first operand as an SD59x18 number.\\n/// @param y The second operand as an SD59x18 number.\\n/// @return result The arithmetic average as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n\\n unchecked {\\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\\n int256 sum = (xInt >> 1) + (yInt >> 1);\\n\\n if (sum < 0) {\\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\\n assembly (\\\"memory-safe\\\") {\\n result := add(sum, and(or(xInt, yInt), 1))\\n }\\n } else {\\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\\n result = wrap(sum + (xInt & yInt & 1));\\n }\\n }\\n}\\n\\n/// @notice Yields the smallest whole number greater than or equal to x.\\n///\\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\\n///\\n/// @param x The SD59x18 number to ceil.\\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt > uMAX_WHOLE_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\\n }\\n\\n int256 remainder = xInt % uUNIT;\\n if (remainder == 0) {\\n result = x;\\n } else {\\n unchecked {\\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\\n int256 resultInt = xInt - remainder;\\n if (xInt > 0) {\\n resultInt += uUNIT;\\n }\\n result = wrap(resultInt);\\n }\\n }\\n}\\n\\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\\n///\\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\\n/// values separately.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n/// - None of the inputs can be `MIN_SD59x18`.\\n/// - The denominator must not be zero.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The numerator as an SD59x18 number.\\n/// @param y The denominator as an SD59x18 number.\\n/// @param result The quotient as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x and y.\\n uint256 xAbs;\\n uint256 yAbs;\\n unchecked {\\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\\n }\\n\\n // Compute the absolute value (x*UNIT\\u00f7y). The resulting value must fit in SD59x18.\\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\\n }\\n\\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\\n // negative, 0 for positive or zero).\\n bool sameSign = (xInt ^ yInt) > -1;\\n\\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\\n unchecked {\\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\\n }\\n}\\n\\n/// @notice Calculates the natural exponent of x using the following formula:\\n///\\n/// $$\\n/// e^x = 2^{x * log_2{e}}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {exp2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}.\\n/// - x must be less than 133_084258667509499441.\\n///\\n/// @param x The exponent as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n\\n // Any input less than the threshold returns zero.\\n // This check also prevents an overflow for very small numbers.\\n if (xInt < uEXP_MIN_THRESHOLD) {\\n return ZERO;\\n }\\n\\n // This check prevents values greater than 192e18 from being passed to {exp2}.\\n if (xInt > uEXP_MAX_INPUT) {\\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Inline the fixed-point multiplication to save gas.\\n int256 doubleUnitProduct = xInt * uLOG2_E;\\n result = exp2(wrap(doubleUnitProduct / uUNIT));\\n }\\n}\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\\n///\\n/// $$\\n/// 2^{-x} = \\\\frac{1}{2^x}\\n/// $$\\n///\\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\\n///\\n/// Notes:\\n/// - If x is less than -59_794705707972522261, the result is zero.\\n///\\n/// Requirements:\\n/// - x must be less than 192e18.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The exponent as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n // The inverse of any number less than the threshold is truncated to zero.\\n if (xInt < uEXP2_MIN_THRESHOLD) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Inline the fixed-point inversion to save gas.\\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\\n }\\n } else {\\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\\n if (xInt > uEXP2_MAX_INPUT) {\\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Convert x to the 192.64-bit fixed-point format.\\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\\n\\n // It is safe to cast the result to int256 due to the checks above.\\n result = wrap(int256(Common.exp2(x_192x64)));\\n }\\n }\\n}\\n\\n/// @notice Yields the greatest whole number less than or equal to x.\\n///\\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\\n///\\n/// @param x The SD59x18 number to floor.\\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < uMIN_WHOLE_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\\n }\\n\\n int256 remainder = xInt % uUNIT;\\n if (remainder == 0) {\\n result = x;\\n } else {\\n unchecked {\\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\\n int256 resultInt = xInt - remainder;\\n if (xInt < 0) {\\n resultInt -= uUNIT;\\n }\\n result = wrap(resultInt);\\n }\\n }\\n}\\n\\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\\n/// of the radix point for negative numbers.\\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\\n/// @param x The SD59x18 number to get the fractional part of.\\n/// @param result The fractional part of x as an SD59x18 number.\\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() % uUNIT);\\n}\\n\\n/// @notice Calculates the geometric mean of x and y, i.e. $\\\\sqrt{x * y}$.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x * y must fit in SD59x18.\\n/// - x * y must not be negative, since complex numbers are not supported.\\n///\\n/// @param x The first operand as an SD59x18 number.\\n/// @param y The second operand as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == 0 || yInt == 0) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\\n int256 xyInt = xInt * yInt;\\n if (xyInt / xInt != yInt) {\\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\\n }\\n\\n // The product must not be negative, since complex numbers are not supported.\\n if (xyInt < 0) {\\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\\n }\\n\\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\\n // during multiplication. See the comments in {Common.sqrt}.\\n uint256 resultUint = Common.sqrt(uint256(xyInt));\\n result = wrap(int256(resultUint));\\n }\\n}\\n\\n/// @notice Calculates the inverse of x.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must not be zero.\\n///\\n/// @param x The SD59x18 number for which to calculate the inverse.\\n/// @return result The inverse as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(uUNIT_SQUARED / x.unwrap());\\n}\\n\\n/// @notice Calculates the natural logarithm of x using the following formula:\\n///\\n/// $$\\n/// ln{x} = log_2{x} / log_2{e}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\\n/// @return result The natural logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\\n // {log2} can return is ~195_205294292027477728.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\\n}\\n\\n/// @notice Calculates the common logarithm of x using the following formula:\\n///\\n/// $$\\n/// log_{10}{x} = log_2{x} / log_2{10}\\n/// $$\\n///\\n/// However, if x is an exact power of ten, a hard coded value is returned.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The SD59x18 number for which to calculate the common logarithm.\\n/// @return result The common logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\\n }\\n\\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\\n // prettier-ignore\\n assembly (\\\"memory-safe\\\") {\\n switch x\\n case 1 { result := mul(uUNIT, sub(0, 18)) }\\n case 10 { result := mul(uUNIT, sub(1, 18)) }\\n case 100 { result := mul(uUNIT, sub(2, 18)) }\\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\\n case 1000000000000000000 { result := 0 }\\n case 10000000000000000000 { result := uUNIT }\\n case 100000000000000000000 { result := mul(uUNIT, 2) }\\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\\n default { result := uMAX_SD59x18 }\\n }\\n\\n if (result.unwrap() == uMAX_SD59x18) {\\n unchecked {\\n // Inline the fixed-point division to save gas.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\\n }\\n }\\n}\\n\\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\\n///\\n/// $$\\n/// log_2{x} = n + log_2{y}, \\\\text{ where } y = x*2^{-n}, \\\\ y \\\\in [1, 2)\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, the input is inverted:\\n///\\n/// $$\\n/// log_2{x} = -log_2{\\\\frac{1}{x}}\\n/// $$\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\\n///\\n/// Notes:\\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\\n///\\n/// Requirements:\\n/// - x must be greater than zero.\\n///\\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\\n/// @return result The binary logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt <= 0) {\\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\\n }\\n\\n unchecked {\\n int256 sign;\\n if (xInt >= uUNIT) {\\n sign = 1;\\n } else {\\n sign = -1;\\n // Inline the fixed-point inversion to save gas.\\n xInt = uUNIT_SQUARED / xInt;\\n }\\n\\n // Calculate the integer part of the logarithm.\\n uint256 n = Common.msb(uint256(xInt / uUNIT));\\n\\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\\n int256 resultInt = int256(n) * uUNIT;\\n\\n // Calculate $y = x * 2^{-n}$.\\n int256 y = xInt >> n;\\n\\n // If y is the unit number, the fractional part is zero.\\n if (y == uUNIT) {\\n return wrap(resultInt * sign);\\n }\\n\\n // Calculate the fractional part via the iterative approximation.\\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\\n int256 DOUBLE_UNIT = 2e18;\\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\\n y = (y * y) / uUNIT;\\n\\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\\n if (y >= DOUBLE_UNIT) {\\n // Add the 2^{-m} factor to the logarithm.\\n resultInt = resultInt + delta;\\n\\n // Halve y, which corresponds to z/2 in the Wikipedia article.\\n y >>= 1;\\n }\\n }\\n resultInt *= sign;\\n result = wrap(resultInt);\\n }\\n}\\n\\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv18}.\\n/// - None of the inputs can be `MIN_SD59x18`.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The multiplicand as an SD59x18 number.\\n/// @param y The multiplier as an SD59x18 number.\\n/// @return result The product as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x and y.\\n uint256 xAbs;\\n uint256 yAbs;\\n unchecked {\\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\\n }\\n\\n // Compute the absolute value (x*y\\u00f7UNIT). The resulting value must fit in SD59x18.\\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\\n }\\n\\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\\n // negative, 0 for positive or zero).\\n bool sameSign = (xInt ^ yInt) > -1;\\n\\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\\n unchecked {\\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\\n }\\n}\\n\\n/// @notice Raises x to the power of y using the following formula:\\n///\\n/// $$\\n/// x^y = 2^{log_2{x} * y}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\\n///\\n/// @param x The base as an SD59x18 number.\\n/// @param y Exponent to raise x to, as an SD59x18 number\\n/// @return result x raised to power y, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n\\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\\n if (xInt == 0) {\\n return yInt == 0 ? UNIT : ZERO;\\n }\\n // If x is `UNIT`, the result is always `UNIT`.\\n else if (xInt == uUNIT) {\\n return UNIT;\\n }\\n\\n // If y is zero, the result is always `UNIT`.\\n if (yInt == 0) {\\n return UNIT;\\n }\\n // If y is `UNIT`, the result is always x.\\n else if (yInt == uUNIT) {\\n return x;\\n }\\n\\n // Calculate the result using the formula.\\n result = exp2(mul(log2(x), y));\\n}\\n\\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\\n/// algorithm \\\"exponentiation by squaring\\\".\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The base as an SD59x18 number.\\n/// @param y The exponent as a uint256.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\\n uint256 xAbs = uint256(abs(x).unwrap());\\n\\n // Calculate the first iteration of the loop in advance.\\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\\n\\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\\n uint256 yAux = y;\\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\\n xAbs = Common.mulDiv18(xAbs, xAbs);\\n\\n // Equivalent to `y % 2 == 1`.\\n if (yAux & 1 > 0) {\\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\\n }\\n }\\n\\n // The result must fit in SD59x18.\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\\n }\\n\\n unchecked {\\n // Is the base negative and the exponent odd? If yes, the result should be negative.\\n int256 resultInt = int256(resultAbs);\\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\\n if (isNegative) {\\n resultInt = -resultInt;\\n }\\n result = wrap(resultInt);\\n }\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - Only the positive root is returned.\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x cannot be negative, since complex numbers are not supported.\\n/// - x must be less than `MAX_SD59x18 / UNIT`.\\n///\\n/// @param x The SD59x18 number for which to calculate the square root.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\\n }\\n if (xInt > uMAX_SD59x18 / uUNIT) {\\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\\n }\\n\\n unchecked {\\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\\n // In this case, the two numbers are both the square root.\\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\\n result = wrap(int256(resultUint));\\n }\\n}\\n\",\"keccak256\":\"0xa074831139fc89ca0e5a36086b30eb50896bb6770cd5823461b1f2769017d2f0\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\nimport \\\"./Helpers.sol\\\" as Helpers;\\nimport \\\"./Math.sol\\\" as Math;\\n\\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type int256.\\ntype SD59x18 is int256;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoInt256,\\n Casting.intoSD1x18,\\n Casting.intoUD2x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Math.abs,\\n Math.avg,\\n Math.ceil,\\n Math.div,\\n Math.exp,\\n Math.exp2,\\n Math.floor,\\n Math.frac,\\n Math.gm,\\n Math.inv,\\n Math.log10,\\n Math.log2,\\n Math.ln,\\n Math.mul,\\n Math.pow,\\n Math.powu,\\n Math.sqrt\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n HELPER FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Helpers.add,\\n Helpers.and,\\n Helpers.eq,\\n Helpers.gt,\\n Helpers.gte,\\n Helpers.isZero,\\n Helpers.lshift,\\n Helpers.lt,\\n Helpers.lte,\\n Helpers.mod,\\n Helpers.neq,\\n Helpers.not,\\n Helpers.or,\\n Helpers.rshift,\\n Helpers.sub,\\n Helpers.uncheckedAdd,\\n Helpers.uncheckedSub,\\n Helpers.uncheckedUnary,\\n Helpers.xor\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n OPERATORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes it possible to use these operators on the SD59x18 type.\\nusing {\\n Helpers.add as +,\\n Helpers.and2 as &,\\n Math.div as /,\\n Helpers.eq as ==,\\n Helpers.gt as >,\\n Helpers.gte as >=,\\n Helpers.lt as <,\\n Helpers.lte as <=,\\n Helpers.mod as %,\\n Math.mul as *,\\n Helpers.neq as !=,\\n Helpers.not as ~,\\n Helpers.or as |,\\n Helpers.sub as -,\\n Helpers.unary as -,\\n Helpers.xor as ^\\n} for SD59x18 global;\\n\",\"keccak256\":\"0xe03112d145dcd5863aff24e5f381debaae29d446acd5666f3d640e3d9af738d7\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport { uMAX_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts a UD2x18 number into SD1x18.\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\\n uint64 xUint = UD2x18.unwrap(x);\\n if (xUint > uint64(uMAX_SD1x18)) {\\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(xUint));\\n}\\n\\n/// @notice Casts a UD2x18 number into SD59x18.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\\n}\\n\\n/// @notice Casts a UD2x18 number into UD60x18.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint128.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\\n result = uint128(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint256.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\\n result = uint256(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\\n uint64 xUint = UD2x18.unwrap(x);\\n if (xUint > uint64(Common.MAX_UINT40)) {\\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(xUint);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\\n result = UD2x18.wrap(x);\\n}\\n\\n/// @notice Unwrap a UD2x18 number into uint64.\\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\\n result = UD2x18.unwrap(x);\\n}\\n\\n/// @notice Wraps a uint64 number into UD2x18.\\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\\n result = UD2x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x9b1a35d432ef951a415fae8098b3c609a99b630a3d5464b3c8e1efa8893eea07\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @dev Euler's number as a UD2x18 number.\\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum value a UD2x18 number can have.\\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\\n\\n/// @dev PI as a UD2x18 number.\\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of UD2x18.\\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\\nuint64 constant uUNIT = 1e18;\\n\",\"keccak256\":\"0x29b0e050c865899e1fb9022b460a7829cdee248c44c4299f068ba80695eec3fc\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\\n\\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\\n\",\"keccak256\":\"0xdf1e22f0b4c8032bcc8b7f63fe3984e1387f3dc7b2e9ab381822249f75376d33\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\n\\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\\n/// storage.\\ntype UD2x18 is uint64;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD1x18,\\n Casting.intoSD59x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for UD2x18 global;\\n\",\"keccak256\":\"0x2802edc9869db116a0b5c490cc5f8554742f747183fa30ac5e9c80bb967e61a1\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { MAX_UINT128, MAX_UINT40 } from \\\"../Common.sol\\\";\\nimport { uMAX_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { uMAX_SD59x18 } from \\\"../sd59x18/Constants.sol\\\";\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { uMAX_UD2x18 } from \\\"../ud2x18/Constants.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts a UD60x18 number into SD1x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uint256(int256(uMAX_SD1x18))) {\\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(uint64(xUint)));\\n}\\n\\n/// @notice Casts a UD60x18 number into UD2x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_UD2x18`.\\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uMAX_UD2x18) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\\n }\\n result = UD2x18.wrap(uint64(xUint));\\n}\\n\\n/// @notice Casts a UD60x18 number into SD59x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_SD59x18`.\\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uint256(uMAX_SD59x18)) {\\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\\n }\\n result = SD59x18.wrap(int256(xUint));\\n}\\n\\n/// @notice Casts a UD60x18 number into uint128.\\n/// @dev This is basically an alias for {unwrap}.\\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x);\\n}\\n\\n/// @notice Casts a UD60x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT128`.\\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > MAX_UINT128) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\\n }\\n result = uint128(xUint);\\n}\\n\\n/// @notice Casts a UD60x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > MAX_UINT40) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(xUint);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\\n/// @notice Unwraps a UD60x18 number into uint256.\\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x);\\n}\\n\\n/// @notice Wraps a uint256 number into the UD60x18 value type.\\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x5bb532da36921cbdac64d1f16de5d366ef1f664502e3b7c07d0ad06917551f85\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n// NOTICE: the \\\"u\\\" prefix stands for \\\"unwrapped\\\".\\n\\n/// @dev Euler's number as a UD60x18 number.\\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum input permitted in {exp}.\\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\\n\\n/// @dev The maximum input permitted in {exp2}.\\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\\n\\n/// @dev Half the UNIT number.\\nuint256 constant uHALF_UNIT = 0.5e18;\\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\\n\\n/// @dev $log_2(10)$ as a UD60x18 number.\\nuint256 constant uLOG2_10 = 3_321928094887362347;\\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\\n\\n/// @dev $log_2(e)$ as a UD60x18 number.\\nuint256 constant uLOG2_E = 1_442695040888963407;\\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\\n\\n/// @dev The maximum value a UD60x18 number can have.\\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\\n\\n/// @dev The maximum whole value a UD60x18 number can have.\\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\\n\\n/// @dev PI as a UD60x18 number.\\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of UD60x18.\\nuint256 constant uUNIT = 1e18;\\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\\n\\n/// @dev The unit number squared.\\nuint256 constant uUNIT_SQUARED = 1e36;\\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\\n\\n/// @dev Zero as a UD60x18 number.\\nUD60x18 constant ZERO = UD60x18.wrap(0);\\n\",\"keccak256\":\"0x2b80d26153d3fdcfb3a9ca772d9309d31ed1275f5b8b54c3ffb54d3652b37d90\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Conversions.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { uMAX_UD60x18, uUNIT } from \\\"./Constants.sol\\\";\\nimport { PRBMath_UD60x18_Convert_Overflow } from \\\"./Errors.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\\n/// @dev The result is rounded toward zero.\\n/// @param x The UD60x18 number to convert.\\n/// @return result The same number in basic integer form.\\nfunction convert(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x) / uUNIT;\\n}\\n\\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\\n///\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\\n///\\n/// @param x The basic integer to convert.\\n/// @param result The same number converted to UD60x18.\\nfunction convert(uint256 x) pure returns (UD60x18 result) {\\n if (x > uMAX_UD60x18 / uUNIT) {\\n revert PRBMath_UD60x18_Convert_Overflow(x);\\n }\\n unchecked {\\n result = UD60x18.wrap(x * uUNIT);\\n }\\n}\\n\",\"keccak256\":\"0xaf7fc2523413822de3b66ba339fe2884fb3b8c6f6cf38ec90a2c3e3aae71df6b\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when ceiling a number overflows UD60x18.\\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\\n\\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\\n\\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when taking the logarithm of a number less than 1.\\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\\n\\n/// @notice Thrown when calculating the square root overflows UD60x18.\\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\\n\",\"keccak256\":\"0xa8c60d4066248df22c49c882873efbc017344107edabc48c52209abbc39cb1e3\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() + y.unwrap());\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() & bits);\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() & y.unwrap());\\n}\\n\\n/// @notice Implements the equal operation (==) in the UD60x18 type.\\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() == y.unwrap();\\n}\\n\\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() > y.unwrap();\\n}\\n\\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() >= y.unwrap();\\n}\\n\\n/// @notice Implements a zero comparison check function in the UD60x18 type.\\nfunction isZero(UD60x18 x) pure returns (bool result) {\\n // This wouldn't work if x could be negative.\\n result = x.unwrap() == 0;\\n}\\n\\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() << bits);\\n}\\n\\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() < y.unwrap();\\n}\\n\\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() <= y.unwrap();\\n}\\n\\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() % y.unwrap());\\n}\\n\\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() != y.unwrap();\\n}\\n\\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\\n result = wrap(~x.unwrap());\\n}\\n\\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() | y.unwrap());\\n}\\n\\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() >> bits);\\n}\\n\\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() - y.unwrap());\\n}\\n\\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() + y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() - y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() ^ y.unwrap());\\n}\\n\",\"keccak256\":\"0xf5faff881391d2c060029499a666cc5f0bea90a213150bb476fae8f02a5df268\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport {\\n uEXP_MAX_INPUT,\\n uEXP2_MAX_INPUT,\\n uHALF_UNIT,\\n uLOG2_10,\\n uLOG2_E,\\n uMAX_UD60x18,\\n uMAX_WHOLE_UD60x18,\\n UNIT,\\n uUNIT,\\n uUNIT_SQUARED,\\n ZERO\\n} from \\\"./Constants.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Calculates the arithmetic average of x and y using the following formula:\\n///\\n/// $$\\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\\n/// $$\\n///\\n/// In English, this is what this formula does:\\n///\\n/// 1. AND x and y.\\n/// 2. Calculate half of XOR x and y.\\n/// 3. Add the two results together.\\n///\\n/// This technique is known as SWAR, which stands for \\\"SIMD within a register\\\". You can read more about it here:\\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// @param x The first operand as a UD60x18 number.\\n/// @param y The second operand as a UD60x18 number.\\n/// @return result The arithmetic average as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n unchecked {\\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\\n }\\n}\\n\\n/// @notice Yields the smallest whole number greater than or equal to x.\\n///\\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\\n///\\n/// @param x The UD60x18 number to ceil.\\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n if (xUint > uMAX_WHOLE_UD60x18) {\\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\\n }\\n\\n assembly (\\\"memory-safe\\\") {\\n // Equivalent to `x % UNIT`.\\n let remainder := mod(x, uUNIT)\\n\\n // Equivalent to `UNIT - remainder`.\\n let delta := sub(uUNIT, remainder)\\n\\n // Equivalent to `x + remainder > 0 ? delta : 0`.\\n result := add(x, mul(delta, gt(remainder, 0)))\\n }\\n}\\n\\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\\n///\\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n///\\n/// @param x The numerator as a UD60x18 number.\\n/// @param y The denominator as a UD60x18 number.\\n/// @param result The quotient as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\\n}\\n\\n/// @notice Calculates the natural exponent of x using the following formula:\\n///\\n/// $$\\n/// e^x = 2^{x * log_2{e}}\\n/// $$\\n///\\n/// @dev Requirements:\\n/// - x must be less than 133_084258667509499441.\\n///\\n/// @param x The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n // This check prevents values greater than 192e18 from being passed to {exp2}.\\n if (xUint > uEXP_MAX_INPUT) {\\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Inline the fixed-point multiplication to save gas.\\n uint256 doubleUnitProduct = xUint * uLOG2_E;\\n result = exp2(wrap(doubleUnitProduct / uUNIT));\\n }\\n}\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method.\\n///\\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\\n///\\n/// Requirements:\\n/// - x must be less than 192e18.\\n/// - The result must fit in UD60x18.\\n///\\n/// @param x The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\\n if (xUint > uEXP2_MAX_INPUT) {\\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\\n }\\n\\n // Convert x to the 192.64-bit fixed-point format.\\n uint256 x_192x64 = (xUint << 64) / uUNIT;\\n\\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\\n result = wrap(Common.exp2(x_192x64));\\n}\\n\\n/// @notice Yields the greatest whole number less than or equal to x.\\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n/// @param x The UD60x18 number to floor.\\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\\n assembly (\\\"memory-safe\\\") {\\n // Equivalent to `x % UNIT`.\\n let remainder := mod(x, uUNIT)\\n\\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\\n result := sub(x, mul(remainder, gt(remainder, 0)))\\n }\\n}\\n\\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\\n/// @param x The UD60x18 number to get the fractional part of.\\n/// @param result The fractional part of x as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\\n assembly (\\\"memory-safe\\\") {\\n result := mod(x, uUNIT)\\n }\\n}\\n\\n/// @notice Calculates the geometric mean of x and y, i.e. $\\\\sqrt{x * y}$, rounding down.\\n///\\n/// @dev Requirements:\\n/// - x * y must fit in UD60x18.\\n///\\n/// @param x The first operand as a UD60x18 number.\\n/// @param y The second operand as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n if (xUint == 0 || yUint == 0) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Checking for overflow this way is faster than letting Solidity do it.\\n uint256 xyUint = xUint * yUint;\\n if (xyUint / xUint != yUint) {\\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\\n }\\n\\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\\n // during multiplication. See the comments in {Common.sqrt}.\\n result = wrap(Common.sqrt(xyUint));\\n }\\n}\\n\\n/// @notice Calculates the inverse of x.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must not be zero.\\n///\\n/// @param x The UD60x18 number for which to calculate the inverse.\\n/// @return result The inverse as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(uUNIT_SQUARED / x.unwrap());\\n }\\n}\\n\\n/// @notice Calculates the natural logarithm of x using the following formula:\\n///\\n/// $$\\n/// ln{x} = log_2{x} / log_2{e}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\\n/// @return result The natural logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\\n unchecked {\\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\\n // {log2} can return is ~196_205294292027477728.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\\n }\\n}\\n\\n/// @notice Calculates the common logarithm of x using the following formula:\\n///\\n/// $$\\n/// log_{10}{x} = log_2{x} / log_2{10}\\n/// $$\\n///\\n/// However, if x is an exact power of ten, a hard coded value is returned.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The UD60x18 number for which to calculate the common logarithm.\\n/// @return result The common logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n if (xUint < uUNIT) {\\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\\n }\\n\\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\\n // prettier-ignore\\n assembly (\\\"memory-safe\\\") {\\n switch x\\n case 1 { result := mul(uUNIT, sub(0, 18)) }\\n case 10 { result := mul(uUNIT, sub(1, 18)) }\\n case 100 { result := mul(uUNIT, sub(2, 18)) }\\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\\n case 1000000000000000000 { result := 0 }\\n case 10000000000000000000 { result := uUNIT }\\n case 100000000000000000000 { result := mul(uUNIT, 2) }\\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\\n default { result := uMAX_UD60x18 }\\n }\\n\\n if (result.unwrap() == uMAX_UD60x18) {\\n unchecked {\\n // Inline the fixed-point division to save gas.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\\n }\\n }\\n}\\n\\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\\n///\\n/// $$\\n/// log_2{x} = n + log_2{y}, \\\\text{ where } y = x*2^{-n}, \\\\ y \\\\in [1, 2)\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, the input is inverted:\\n///\\n/// $$\\n/// log_2{x} = -log_2{\\\\frac{1}{x}}\\n/// $$\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\\n///\\n/// Notes:\\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\\n///\\n/// Requirements:\\n/// - x must be greater than zero.\\n///\\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\\n/// @return result The binary logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n if (xUint < uUNIT) {\\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\\n }\\n\\n unchecked {\\n // Calculate the integer part of the logarithm.\\n uint256 n = Common.msb(xUint / uUNIT);\\n\\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\\n // n is at most 255 and UNIT is 1e18.\\n uint256 resultUint = n * uUNIT;\\n\\n // Calculate $y = x * 2^{-n}$.\\n uint256 y = xUint >> n;\\n\\n // If y is the unit number, the fractional part is zero.\\n if (y == uUNIT) {\\n return wrap(resultUint);\\n }\\n\\n // Calculate the fractional part via the iterative approximation.\\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\\n uint256 DOUBLE_UNIT = 2e18;\\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\\n y = (y * y) / uUNIT;\\n\\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\\n if (y >= DOUBLE_UNIT) {\\n // Add the 2^{-m} factor to the logarithm.\\n resultUint += delta;\\n\\n // Halve y, which corresponds to z/2 in the Wikipedia article.\\n y >>= 1;\\n }\\n }\\n result = wrap(resultUint);\\n }\\n}\\n\\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\\n///\\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n///\\n/// @dev See the documentation in {Common.mulDiv18}.\\n/// @param x The multiplicand as a UD60x18 number.\\n/// @param y The multiplier as a UD60x18 number.\\n/// @return result The product as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\\n}\\n\\n/// @notice Raises x to the power of y.\\n///\\n/// For $1 \\\\leq x \\\\leq \\\\infty$, the following standard formula is used:\\n///\\n/// $$\\n/// x^y = 2^{log_2{x} * y}\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\\n///\\n/// $$\\n/// i = \\\\frac{1}{x}\\n/// w = 2^{log_2{i} * y}\\n/// x^y = \\\\frac{1}{w}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2} and {mul}.\\n/// - Returns `UNIT` for 0^0.\\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\\n///\\n/// @param x The base as a UD60x18 number.\\n/// @param y The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n\\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\\n if (xUint == 0) {\\n return yUint == 0 ? UNIT : ZERO;\\n }\\n // If x is `UNIT`, the result is always `UNIT`.\\n else if (xUint == uUNIT) {\\n return UNIT;\\n }\\n\\n // If y is zero, the result is always `UNIT`.\\n if (yUint == 0) {\\n return UNIT;\\n }\\n // If y is `UNIT`, the result is always x.\\n else if (yUint == uUNIT) {\\n return x;\\n }\\n\\n // If x is greater than `UNIT`, use the standard formula.\\n if (xUint > uUNIT) {\\n result = exp2(mul(log2(x), y));\\n }\\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\\n else {\\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\\n UD60x18 w = exp2(mul(log2(i), y));\\n result = wrap(uUNIT_SQUARED / w.unwrap());\\n }\\n}\\n\\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\\n/// algorithm \\\"exponentiation by squaring\\\".\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - The result must fit in UD60x18.\\n///\\n/// @param x The base as a UD60x18 number.\\n/// @param y The exponent as a uint256.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\\n // Calculate the first iteration of the loop in advance.\\n uint256 xUint = x.unwrap();\\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\\n\\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\\n for (y >>= 1; y > 0; y >>= 1) {\\n xUint = Common.mulDiv18(xUint, xUint);\\n\\n // Equivalent to `y % 2 == 1`.\\n if (y & 1 > 0) {\\n resultUint = Common.mulDiv18(resultUint, xUint);\\n }\\n }\\n result = wrap(resultUint);\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must be less than `MAX_UD60x18 / UNIT`.\\n///\\n/// @param x The UD60x18 number for which to calculate the square root.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n unchecked {\\n if (xUint > uMAX_UD60x18 / uUNIT) {\\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\\n }\\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\\n // In this case, the two numbers are both the square root.\\n result = wrap(Common.sqrt(xUint * uUNIT));\\n }\\n}\\n\",\"keccak256\":\"0x462144667aac3f96d5f8dba7aa68fe4c5a3f61e1d7bbbc81bee21168817f9c09\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\nimport \\\"./Helpers.sol\\\" as Helpers;\\nimport \\\"./Math.sol\\\" as Math;\\n\\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\\n/// @dev The value type is defined here so it can be imported in all other files.\\ntype UD60x18 is uint256;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD1x18,\\n Casting.intoUD2x18,\\n Casting.intoSD59x18,\\n Casting.intoUint128,\\n Casting.intoUint256,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes the functions in this library callable on the UD60x18 type.\\nusing {\\n Math.avg,\\n Math.ceil,\\n Math.div,\\n Math.exp,\\n Math.exp2,\\n Math.floor,\\n Math.frac,\\n Math.gm,\\n Math.inv,\\n Math.ln,\\n Math.log10,\\n Math.log2,\\n Math.mul,\\n Math.pow,\\n Math.powu,\\n Math.sqrt\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n HELPER FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes the functions in this library callable on the UD60x18 type.\\nusing {\\n Helpers.add,\\n Helpers.and,\\n Helpers.eq,\\n Helpers.gt,\\n Helpers.gte,\\n Helpers.isZero,\\n Helpers.lshift,\\n Helpers.lt,\\n Helpers.lte,\\n Helpers.mod,\\n Helpers.neq,\\n Helpers.not,\\n Helpers.or,\\n Helpers.rshift,\\n Helpers.sub,\\n Helpers.uncheckedAdd,\\n Helpers.uncheckedSub,\\n Helpers.xor\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n OPERATORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes it possible to use these operators on the UD60x18 type.\\nusing {\\n Helpers.add as +,\\n Helpers.and2 as &,\\n Math.div as /,\\n Helpers.eq as ==,\\n Helpers.gt as >,\\n Helpers.gte as >=,\\n Helpers.lt as <,\\n Helpers.lte as <=,\\n Helpers.or as |,\\n Helpers.mod as %,\\n Math.mul as *,\\n Helpers.neq as !=,\\n Helpers.not as ~,\\n Helpers.sub as -,\\n Helpers.xor as ^\\n} for UD60x18 global;\\n\",\"keccak256\":\"0xdd873b5124180d9b71498b3a7fe93b1c08c368bec741f7d5f8e17f78a0b70f31\",\"license\":\"MIT\"},\"contracts/DecentSablierStreamManagement.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.28;\\n\\nimport {Enum} from \\\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\\\";\\nimport {IAvatar} from \\\"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\\\";\\nimport {ISablierV2Lockup} from \\\"./interfaces/sablier/full/ISablierV2Lockup.sol\\\";\\nimport {Lockup} from \\\"./interfaces/sablier/full/types/DataTypes.sol\\\";\\n\\ncontract DecentSablierStreamManagement {\\n string public constant NAME = \\\"DecentSablierStreamManagement\\\";\\n\\n function withdrawMaxFromStream(\\n ISablierV2Lockup sablier,\\n address recipientHatAccount,\\n uint256 streamId,\\n address to\\n ) public {\\n // Check if there are funds to withdraw\\n uint128 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\\n if (withdrawableAmount == 0) {\\n return;\\n }\\n\\n // Proxy the Sablier withdrawMax call through IAvatar (Safe)\\n IAvatar(msg.sender).execTransactionFromModule(\\n recipientHatAccount,\\n 0,\\n abi.encodeWithSignature(\\n \\\"execute(address,uint256,bytes,uint8)\\\",\\n address(sablier),\\n 0,\\n abi.encodeWithSignature(\\n \\\"withdrawMax(uint256,address)\\\",\\n streamId,\\n to\\n ),\\n 0\\n ),\\n Enum.Operation.Call\\n );\\n }\\n\\n function cancelStream(ISablierV2Lockup sablier, uint256 streamId) public {\\n // Check if the stream can be cancelled\\n Lockup.Status streamStatus = sablier.statusOf(streamId);\\n if (\\n streamStatus != Lockup.Status.PENDING &&\\n streamStatus != Lockup.Status.STREAMING\\n ) {\\n return;\\n }\\n\\n IAvatar(msg.sender).execTransactionFromModule(\\n address(sablier),\\n 0,\\n abi.encodeWithSignature(\\\"cancel(uint256)\\\", streamId),\\n Enum.Operation.Call\\n );\\n }\\n}\\n\",\"keccak256\":\"0xf36be7e97936d82de0035b8bda2c53dbc52b9ca3b8efe305540a7632cb6fe6ab\",\"license\":\"MIT\"},\"contracts/interfaces/sablier/full/IAdminable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\n/// @title IAdminable\\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\\n/// in the constructor.\\ninterface IAdminable {\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin is transferred.\\n /// @param oldAdmin The address of the old admin.\\n /// @param newAdmin The address of the new admin.\\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice The address of the admin account or contract.\\n function admin() external view returns (address);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Transfers the contract admin to a new address.\\n ///\\n /// @dev Notes:\\n /// - Does not revert if the admin is the same.\\n /// - This function can potentially leave the contract without an admin, thereby removing any\\n /// functionality that is only available to the admin.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newAdmin The address of the new admin.\\n function transferAdmin(address newAdmin) external;\\n}\\n\",\"keccak256\":\"0xa279c49e51228b571329164e36250e82b2c1378e8b549194ab7dd90fca9c3b2b\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/IERC4096.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4906.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC165} from \\\"@openzeppelin/contracts/interfaces/IERC165.sol\\\";\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\n/// @title ERC-721 Metadata Update Extension\\ninterface IERC4906 is IERC165, IERC721 {\\n /// @dev This event emits when the metadata of a token is changed.\\n /// So that the third-party platforms such as NFT market could\\n /// timely update the images and related attributes of the NFT.\\n event MetadataUpdate(uint256 _tokenId);\\n\\n /// @dev This event emits when the metadata of a range of tokens is changed.\\n /// So that the third-party platforms such as NFT market could\\n /// timely update the images and related attributes of the NFTs.\\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\\n}\\n\",\"keccak256\":\"0xa34b9c52cbe36be860244f52256f1b05badf0cb797d208664b87337610d0e82d\",\"license\":\"MIT\"},\"contracts/interfaces/sablier/full/ISablierV2Lockup.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC4906} from \\\"./IERC4096.sol\\\";\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {IERC721Metadata} from \\\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\\\";\\nimport {UD60x18} from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\nimport {Lockup} from \\\"./types/DataTypes.sol\\\";\\nimport {IAdminable} from \\\"./IAdminable.sol\\\";\\nimport {ISablierV2NFTDescriptor} from \\\"./ISablierV2NFTDescriptor.sol\\\";\\n\\n/// @title ISablierV2Lockup\\n/// @notice Common logic between all Sablier V2 Lockup contracts.\\ninterface ISablierV2Lockup is\\n IAdminable, // 0 inherited components\\n IERC4906, // 2 inherited components\\n IERC721Metadata // 2 inherited components\\n{\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin allows a new recipient contract to hook to Sablier.\\n /// @param admin The address of the current contract admin.\\n /// @param recipient The address of the recipient contract put on the allowlist.\\n event AllowToHook(address indexed admin, address recipient);\\n\\n /// @notice Emitted when a stream is canceled.\\n /// @param streamId The ID of the stream.\\n /// @param sender The address of the stream's sender.\\n /// @param recipient The address of the stream's recipient.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\\n /// decimals.\\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\\n /// asset's decimals.\\n event CancelLockupStream(\\n uint256 streamId,\\n address indexed sender,\\n address indexed recipient,\\n IERC20 indexed asset,\\n uint128 senderAmount,\\n uint128 recipientAmount\\n );\\n\\n /// @notice Emitted when a sender gives up the right to cancel a stream.\\n /// @param streamId The ID of the stream.\\n event RenounceLockupStream(uint256 indexed streamId);\\n\\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\\n /// @param admin The address of the current contract admin.\\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\\n event SetNFTDescriptor(\\n address indexed admin,\\n ISablierV2NFTDescriptor oldNFTDescriptor,\\n ISablierV2NFTDescriptor newNFTDescriptor\\n );\\n\\n /// @notice Emitted when assets are withdrawn from a stream.\\n /// @param streamId The ID of the stream.\\n /// @param to The address that has received the withdrawn assets.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\\n event WithdrawFromLockupStream(\\n uint256 indexed streamId,\\n address indexed to,\\n IERC20 indexed asset,\\n uint128 amount\\n );\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Retrieves the address of the ERC-20 asset to be distributed.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\\n\\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getDepositedAmount(\\n uint256 streamId\\n ) external view returns (uint128 depositedAmount);\\n\\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getEndTime(\\n uint256 streamId\\n ) external view returns (uint40 endTime);\\n\\n /// @notice Retrieves the stream's recipient.\\n /// @dev Reverts if the NFT has been burned.\\n /// @param streamId The stream ID for the query.\\n function getRecipient(\\n uint256 streamId\\n ) external view returns (address recipient);\\n\\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\\n /// decimals. This amount is always zero unless the stream was canceled.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getRefundedAmount(\\n uint256 streamId\\n ) external view returns (uint128 refundedAmount);\\n\\n /// @notice Retrieves the stream's sender.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getSender(uint256 streamId) external view returns (address sender);\\n\\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getStartTime(\\n uint256 streamId\\n ) external view returns (uint40 startTime);\\n\\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getWithdrawnAmount(\\n uint256 streamId\\n ) external view returns (uint128 withdrawnAmount);\\n\\n /// @notice Retrieves a flag indicating whether the provided address is a contract allowed to hook to Sablier\\n /// when a stream is canceled or when assets are withdrawn.\\n /// @dev See {ISablierLockupRecipient} for more information.\\n function isAllowedToHook(\\n address recipient\\n ) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\\n /// flag is always `false`.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isCancelable(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isCold(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is depleted.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isDepleted(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream exists.\\n /// @dev Does not revert if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isStream(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isTransferable(\\n uint256 streamId\\n ) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isWarm(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves the maximum broker fee that can be charged by the broker, denoted as a fixed-point\\n /// number where 1e18 is 100%.\\n /// @dev This value is hard coded as a constant.\\n function MAX_BROKER_FEE() external view returns (UD60x18);\\n\\n /// @notice Counter for stream IDs, used in the create functions.\\n function nextStreamId() external view returns (uint256);\\n\\n /// @notice Contract that generates the non-fungible token URI.\\n function nftDescriptor() external view returns (ISablierV2NFTDescriptor);\\n\\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\\n /// of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function refundableAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 refundableAmount);\\n\\n /// @notice Retrieves the stream's status.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function statusOf(\\n uint256 streamId\\n ) external view returns (Lockup.Status status);\\n\\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n ///\\n /// Notes:\\n /// - Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\\n /// to the total amount withdrawn.\\n ///\\n /// @param streamId The stream ID for the query.\\n function streamedAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 streamedAmount);\\n\\n /// @notice Retrieves a flag indicating whether the stream was canceled.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function wasCanceled(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\\n /// decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function withdrawableAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 withdrawableAmount);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Allows a recipient contract to hook to Sablier when a stream is canceled or when assets are withdrawn.\\n /// Useful for implementing contracts that hold streams on behalf of users, such as vaults or staking contracts.\\n ///\\n /// @dev Emits an {AllowToHook} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the contract is already on the allowlist.\\n /// - This is an irreversible operation. The contract cannot be removed from the allowlist.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n /// - `recipient` must have a non-zero code size.\\n /// - `recipient` must implement {ISablierLockupRecipient}.\\n ///\\n /// @param recipient The address of the contract to allow for hooks.\\n function allowToHook(address recipient) external;\\n\\n /// @notice Burns the NFT associated with the stream.\\n ///\\n /// @dev Emits a {Transfer} event.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must reference a depleted stream.\\n /// - The NFT must exist.\\n /// - `msg.sender` must be either the NFT owner or an approved third party.\\n ///\\n /// @param streamId The ID of the stream NFT to burn.\\n function burn(uint256 streamId) external;\\n\\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\\n ///\\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\\n /// stream is marked as depleted.\\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - The stream must be warm and cancelable.\\n /// - `msg.sender` must be the stream's sender.\\n ///\\n /// @param streamId The ID of the stream to cancel.\\n function cancel(uint256 streamId) external;\\n\\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\\n ///\\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\\n ///\\n /// Notes:\\n /// - Refer to the notes in {cancel}.\\n ///\\n /// Requirements:\\n /// - All requirements from {cancel} must be met for each stream.\\n ///\\n /// @param streamIds The IDs of the streams to cancel.\\n function cancelMultiple(uint256[] calldata streamIds) external;\\n\\n /// @notice Removes the right of the stream's sender to cancel the stream.\\n ///\\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - This is an irreversible operation.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must reference a warm stream.\\n /// - `msg.sender` must be the stream's sender.\\n /// - The stream must be cancelable.\\n ///\\n /// @param streamId The ID of the stream to renounce.\\n function renounce(uint256 streamId) external;\\n\\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\\n ///\\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the NFT descriptor is the same.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\\n function setNFTDescriptor(\\n ISablierV2NFTDescriptor newNFTDescriptor\\n ) external;\\n\\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\\n ///\\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - This function attempts to call a hook on the recipient of the stream, unless `msg.sender` is the recipient.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must not reference a null or depleted stream.\\n /// - `to` must not be the zero address.\\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\\n /// - `to` must be the recipient if `msg.sender` is not the stream's recipient or an approved third party.\\n ///\\n /// @param streamId The ID of the stream to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\\n function withdraw(uint256 streamId, address to, uint128 amount) external;\\n\\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\\n ///\\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - Refer to the notes in {withdraw}.\\n ///\\n /// Requirements:\\n /// - Refer to the requirements in {withdraw}.\\n ///\\n /// @param streamId The ID of the stream to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\\n function withdrawMax(\\n uint256 streamId,\\n address to\\n ) external returns (uint128 withdrawnAmount);\\n\\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\\n /// NFT to `newRecipient`.\\n ///\\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\\n ///\\n /// Notes:\\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\\n /// - Refer to the notes in {withdraw}.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the stream's recipient.\\n /// - Refer to the requirements in {withdraw}.\\n /// - Refer to the requirements in {IERC721.transferFrom}.\\n ///\\n /// @param streamId The ID of the stream NFT to transfer.\\n /// @param newRecipient The address of the new owner of the stream NFT.\\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\\n function withdrawMaxAndTransfer(\\n uint256 streamId,\\n address newRecipient\\n ) external returns (uint128 withdrawnAmount);\\n\\n /// @notice Withdraws assets from streams to the recipient of each stream.\\n ///\\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\\n ///\\n /// Notes:\\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - There must be an equal number of `streamIds` and `amounts`.\\n /// - Each stream ID in the array must not reference a null or depleted stream.\\n /// - Each amount in the array must be greater than zero and must not exceed the withdrawable amount.\\n ///\\n /// @param streamIds The IDs of the streams to withdraw from.\\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\\n function withdrawMultiple(\\n uint256[] calldata streamIds,\\n uint128[] calldata amounts\\n ) external;\\n}\\n\",\"keccak256\":\"0x3e5541c38a901637bd310965deb5bbde73ef07fe4ee3c752cbec330c6b9d62a3\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/ISablierV2NFTDescriptor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC721Metadata} from \\\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\\\";\\n\\n/// @title ISablierV2NFTDescriptor\\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\\n/// @dev Inspired by Uniswap V3 Positions NFTs.\\ninterface ISablierV2NFTDescriptor {\\n /// @notice Produces the URI describing a particular stream NFT.\\n /// @dev This is a data URI with the JSON contents directly inlined.\\n /// @param sablier The address of the Sablier contract the stream was created in.\\n /// @param streamId The ID of the stream for which to produce a description.\\n /// @return uri The URI of the ERC721-compliant metadata.\\n function tokenURI(\\n IERC721Metadata sablier,\\n uint256 streamId\\n ) external view returns (string memory uri);\\n}\\n\",\"keccak256\":\"0x4ed430e553d14161e93efdaaacd1a502f49b38969c9d714b45d2e682a74fa0bc\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/types/DataTypes.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {UD2x18} from \\\"@prb/math/src/UD2x18.sol\\\";\\nimport {UD60x18} from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\n// DataTypes.sol\\n//\\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\\n//\\n// - Lockup\\n// - LockupDynamic\\n// - LockupLinear\\n// - LockupTranched\\n//\\n// You will notice that some structs contain \\\"slot\\\" annotations - they are used to indicate the\\n// storage layout of the struct. It is more gas efficient to group small data types together so\\n// that they fit in a single 32-byte slot.\\n\\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\\n/// @param account The address receiving the broker's fee.\\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\\nstruct Broker {\\n address account;\\n UD60x18 fee;\\n}\\n\\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\\nlibrary Lockup {\\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the asset's\\n /// decimals.\\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in the same slot\\n /// saves gas.\\n /// @param deposited The initial amount deposited in the stream, net of broker fee.\\n /// @param withdrawn The cumulative amount withdrawn from the stream.\\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\\n struct Amounts {\\n // slot 0\\n uint128 deposited;\\n uint128 withdrawn;\\n // slot 1\\n uint128 refunded;\\n }\\n\\n /// @notice Struct encapsulating (i) the deposit amount and (ii) the broker fee amount, both denoted in units of the\\n /// asset's decimals.\\n /// @param deposit The amount to deposit in the stream.\\n /// @param brokerFee The broker fee amount.\\n struct CreateAmounts {\\n uint128 deposit;\\n uint128 brokerFee;\\n }\\n\\n /// @notice Enum representing the different statuses of a stream.\\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\\n enum Status {\\n PENDING,\\n STREAMING,\\n SETTLED,\\n CANCELED,\\n DEPLETED\\n }\\n\\n /// @notice A common data structure to be stored in all {SablierV2Lockup} models.\\n /// @dev The fields are arranged like this to save gas via tight variable packing.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param endTime The Unix timestamp indicating the stream's end.\\n /// @param isCancelable Boolean indicating if the stream is cancelable.\\n /// @param wasCanceled Boolean indicating if the stream was canceled.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param isDepleted Boolean indicating if the stream is depleted.\\n /// @param isStream Boolean indicating if the struct entity exists.\\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\\n /// @param amounts Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the\\n /// asset's decimals.\\n struct Stream {\\n // slot 0\\n address sender;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n // slot 1\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n // slot 2 and 3\\n Lockup.Amounts amounts;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\\nlibrary LockupDynamic {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param segments Segments with durations used to compose the dynamic distribution function. Timestamps are\\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n SegmentWithDuration[] segments;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param segments Segments used to compose the dynamic distribution function.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n uint40 startTime;\\n Segment[] segments;\\n Broker broker;\\n }\\n\\n /// @notice Segment struct used in the Lockup Dynamic stream.\\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\\n /// @param timestamp The Unix timestamp indicating the segment's end.\\n struct Segment {\\n // slot 0\\n uint128 amount;\\n UD2x18 exponent;\\n uint40 timestamp;\\n }\\n\\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDurations}.\\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\\n /// @param duration The time difference in seconds between the segment and the previous one.\\n struct SegmentWithDuration {\\n uint128 amount;\\n UD2x18 exponent;\\n uint40 duration;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the segments.\\n struct StreamLD {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n Segment[] segments;\\n }\\n\\n /// @notice Struct encapsulating the LockupDynamic timestamps.\\n /// @param start The Unix timestamp indicating the stream's start.\\n /// @param end The Unix timestamp indicating the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 end;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\\nlibrary LockupLinear {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param durations Struct encapsulating (i) cliff period duration and (ii) total stream duration, both in seconds.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n Durations durations;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param timestamps Struct encapsulating (i) the stream's start time, (ii) cliff time, and (iii) end time, all as\\n /// Unix timestamps.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n Timestamps timestamps;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the cliff duration and the total duration.\\n /// @param cliff The cliff duration in seconds.\\n /// @param total The total duration in seconds.\\n struct Durations {\\n uint40 cliff;\\n uint40 total;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the cliff time.\\n struct StreamLL {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n uint40 endTime;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n uint40 cliffTime;\\n }\\n\\n /// @notice Struct encapsulating the LockupLinear timestamps.\\n /// @param start The Unix timestamp for the stream's start.\\n /// @param cliff The Unix timestamp for the cliff period's end. A value of zero means there is no cliff.\\n /// @param end The Unix timestamp for the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 cliff;\\n uint40 end;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupTranched}.\\nlibrary LockupTranched {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param tranches Tranches with durations used to compose the tranched distribution function. Timestamps are\\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n TrancheWithDuration[] tranches;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param tranches Tranches used to compose the tranched distribution function.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n uint40 startTime;\\n Tranche[] tranches;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the tranches.\\n struct StreamLT {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n Tranche[] tranches;\\n }\\n\\n /// @notice Struct encapsulating the LockupTranched timestamps.\\n /// @param start The Unix timestamp indicating the stream's start.\\n /// @param end The Unix timestamp indicating the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 end;\\n }\\n\\n /// @notice Tranche struct used in the Lockup Tranched stream.\\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\\n /// @param timestamp The Unix timestamp indicating the tranche's end.\\n struct Tranche {\\n // slot 0\\n uint128 amount;\\n uint40 timestamp;\\n }\\n\\n /// @notice Tranche struct used at runtime in {SablierV2LockupTranched.createWithDurations}.\\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\\n /// @param duration The time difference in seconds between the tranche and the previous one.\\n struct TrancheWithDuration {\\n uint128 amount;\\n uint40 duration;\\n }\\n}\\n\",\"keccak256\":\"0x727722c0ec71a76a947b935c9dfcac8fd846d6c3547dfbc8739c7109f3b95068\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", + "bytecode": "0x6080604052348015600f57600080fd5b506105fe8061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80636778d4b0146100465780637dc14a8e1461005b578063a3f4df7e1461006e575b600080fd5b6100596100543660046103d0565b6100c0565b005b610059610069366004610423565b610256565b6100aa6040518060400160405280601d81526020017f446563656e745361626c69657253747265616d4d616e6167656d656e7400000081525081565b6040516100b79190610495565b60405180910390f35b60405163d975dfed60e01b8152600481018390526000906001600160a01b0386169063d975dfed90602401602060405180830381865afa158015610108573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012c91906104af565b9050806001600160801b03166000036101455750610250565b336001600160a01b031663468721a7856000886000888860405160240161017f9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529181526020820180516001600160e01b031663ea5ead1960e01b179052516101bc939291906000906024016104d8565b60408051601f198184030181529181526020820180516001600160e01b0316635194544760e01b1790525160e085901b6001600160e01b031916815261020a9392919060009060040161052f565b6020604051808303816000875af1158015610229573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024d9190610585565b50505b50505050565b604051632b4d7bf560e21b8152600481018290526000906001600160a01b0384169063ad35efd490602401602060405180830381865afa15801561029e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c291906105a7565b905060008160048111156102d8576102d8610519565b141580156102f8575060018160048111156102f5576102f5610519565b14155b1561030257505050565b336001600160a01b031663468721a78460008560405160240161032791815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166340e58ee560e01b1790525160e085901b6001600160e01b03191681526103759392919060009060040161052f565b6020604051808303816000875af1158015610394573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102509190610585565b6001600160a01b03811681146103cd57600080fd5b50565b600080600080608085870312156103e657600080fd5b84356103f1816103b8565b93506020850135610401816103b8565b9250604085013591506060850135610418816103b8565b939692955090935050565b6000806040838503121561043657600080fd5b8235610441816103b8565b946020939093013593505050565b6000815180845260005b8181101561047557602081850181015186830182015201610459565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006104a8602083018461044f565b9392505050565b6000602082840312156104c157600080fd5b81516001600160801b03811681146104a857600080fd5b6001600160a01b038516815260ff841660208201526080604082018190526000906105059083018561044f565b905060ff8316606083015295945050505050565b634e487b7160e01b600052602160045260246000fd5b60018060a01b0385168152836020820152608060408201526000610556608083018561044f565b90506002831061057657634e487b7160e01b600052602160045260246000fd5b82606083015295945050505050565b60006020828403121561059757600080fd5b815180151581146104a857600080fd5b6000602082840312156105b957600080fd5b8151600581106104a857600080fdfea2646970667358221220c473750d62fe01ec9f421a499df8738e767b4a5341626c81a992fcdb3ee192de64736f6c634300081c0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80636778d4b0146100465780637dc14a8e1461005b578063a3f4df7e1461006e575b600080fd5b6100596100543660046103d0565b6100c0565b005b610059610069366004610423565b610256565b6100aa6040518060400160405280601d81526020017f446563656e745361626c69657253747265616d4d616e6167656d656e7400000081525081565b6040516100b79190610495565b60405180910390f35b60405163d975dfed60e01b8152600481018390526000906001600160a01b0386169063d975dfed90602401602060405180830381865afa158015610108573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012c91906104af565b9050806001600160801b03166000036101455750610250565b336001600160a01b031663468721a7856000886000888860405160240161017f9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529181526020820180516001600160e01b031663ea5ead1960e01b179052516101bc939291906000906024016104d8565b60408051601f198184030181529181526020820180516001600160e01b0316635194544760e01b1790525160e085901b6001600160e01b031916815261020a9392919060009060040161052f565b6020604051808303816000875af1158015610229573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024d9190610585565b50505b50505050565b604051632b4d7bf560e21b8152600481018290526000906001600160a01b0384169063ad35efd490602401602060405180830381865afa15801561029e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c291906105a7565b905060008160048111156102d8576102d8610519565b141580156102f8575060018160048111156102f5576102f5610519565b14155b1561030257505050565b336001600160a01b031663468721a78460008560405160240161032791815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166340e58ee560e01b1790525160e085901b6001600160e01b03191681526103759392919060009060040161052f565b6020604051808303816000875af1158015610394573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102509190610585565b6001600160a01b03811681146103cd57600080fd5b50565b600080600080608085870312156103e657600080fd5b84356103f1816103b8565b93506020850135610401816103b8565b9250604085013591506060850135610418816103b8565b939692955090935050565b6000806040838503121561043657600080fd5b8235610441816103b8565b946020939093013593505050565b6000815180845260005b8181101561047557602081850181015186830182015201610459565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006104a8602083018461044f565b9392505050565b6000602082840312156104c157600080fd5b81516001600160801b03811681146104a857600080fd5b6001600160a01b038516815260ff841660208201526080604082018190526000906105059083018561044f565b905060ff8316606083015295945050505050565b634e487b7160e01b600052602160045260246000fd5b60018060a01b0385168152836020820152608060408201526000610556608083018561044f565b90506002831061057657634e487b7160e01b600052602160045260246000fd5b82606083015295945050505050565b60006020828403121561059757600080fd5b815180151581146104a857600080fd5b6000602082840312156105b957600080fd5b8151600581106104a857600080fdfea2646970667358221220c473750d62fe01ec9f421a499df8738e767b4a5341626c81a992fcdb3ee192de64736f6c634300081c0033", + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/deployments/base/solcInputs/4511b61209438ca20d2458493e70bb24.json b/deployments/base/solcInputs/4511b61209438ca20d2458493e70bb24.json new file mode 100644 index 00000000..c068a9c4 --- /dev/null +++ b/deployments/base/solcInputs/4511b61209438ca20d2458493e70bb24.json @@ -0,0 +1,351 @@ +{ + "language": "Solidity", + "sources": { + "@gnosis.pm/safe-contracts/contracts/base/Executor.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\n\n/// @title Executor - A contract that can execute transactions\n/// @author Richard Meissner - \ncontract Executor {\n function execute(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 txGas\n ) internal returns (bool success) {\n if (operation == Enum.Operation.DelegateCall) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n success := delegatecall(txGas, to, add(data, 0x20), mload(data), 0, 0)\n }\n } else {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n success := call(txGas, to, value, add(data, 0x20), mload(data), 0, 0)\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/FallbackManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../common/SelfAuthorized.sol\";\n\n/// @title Fallback Manager - A contract that manages fallback calls made to this contract\n/// @author Richard Meissner - \ncontract FallbackManager is SelfAuthorized {\n event ChangedFallbackHandler(address handler);\n\n // keccak256(\"fallback_manager.handler.address\")\n bytes32 internal constant FALLBACK_HANDLER_STORAGE_SLOT = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5;\n\n function internalSetFallbackHandler(address handler) internal {\n bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, handler)\n }\n }\n\n /// @dev Allows to add a contract to handle fallback calls.\n /// Only fallback calls without value and with data will be forwarded.\n /// This can only be done via a Safe transaction.\n /// @param handler contract to handle fallbacks calls.\n function setFallbackHandler(address handler) public authorized {\n internalSetFallbackHandler(handler);\n emit ChangedFallbackHandler(handler);\n }\n\n // solhint-disable-next-line payable-fallback,no-complex-fallback\n fallback() external {\n bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let handler := sload(slot)\n if iszero(handler) {\n return(0, 0)\n }\n calldatacopy(0, 0, calldatasize())\n // The msg.sender address is shifted to the left by 12 bytes to remove the padding\n // Then the address without padding is stored right after the calldata\n mstore(calldatasize(), shl(96, caller()))\n // Add 20 bytes for the address appended add the end\n let success := call(gas(), handler, 0, 0, add(calldatasize(), 20), 0, 0)\n returndatacopy(0, 0, returndatasize())\n if iszero(success) {\n revert(0, returndatasize())\n }\n return(0, returndatasize())\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/GuardManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\n\ninterface Guard {\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external;\n\n function checkAfterExecution(bytes32 txHash, bool success) external;\n}\n\n/// @title Fallback Manager - A contract that manages fallback calls made to this contract\n/// @author Richard Meissner - \ncontract GuardManager is SelfAuthorized {\n event ChangedGuard(address guard);\n // keccak256(\"guard_manager.guard.address\")\n bytes32 internal constant GUARD_STORAGE_SLOT = 0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8;\n\n /// @dev Set a guard that checks transactions before execution\n /// @param guard The address of the guard to be used or the 0 address to disable the guard\n function setGuard(address guard) external authorized {\n bytes32 slot = GUARD_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, guard)\n }\n emit ChangedGuard(guard);\n }\n\n function getGuard() internal view returns (address guard) {\n bytes32 slot = GUARD_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n guard := sload(slot)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/ModuleManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\nimport \"./Executor.sol\";\n\n/// @title Module Manager - A contract that manages modules that can execute transactions via this contract\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract ModuleManager is SelfAuthorized, Executor {\n event EnabledModule(address module);\n event DisabledModule(address module);\n event ExecutionFromModuleSuccess(address indexed module);\n event ExecutionFromModuleFailure(address indexed module);\n\n address internal constant SENTINEL_MODULES = address(0x1);\n\n mapping(address => address) internal modules;\n\n function setupModules(address to, bytes memory data) internal {\n require(modules[SENTINEL_MODULES] == address(0), \"GS100\");\n modules[SENTINEL_MODULES] = SENTINEL_MODULES;\n if (to != address(0))\n // Setup has to complete successfully or transaction fails.\n require(execute(to, 0, data, Enum.Operation.DelegateCall, gasleft()), \"GS000\");\n }\n\n /// @dev Allows to add a module to the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Enables the module `module` for the Safe.\n /// @param module Module to be whitelisted.\n function enableModule(address module) public authorized {\n // Module address cannot be null or sentinel.\n require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n // Module cannot be added twice.\n require(modules[module] == address(0), \"GS102\");\n modules[module] = modules[SENTINEL_MODULES];\n modules[SENTINEL_MODULES] = module;\n emit EnabledModule(module);\n }\n\n /// @dev Allows to remove a module from the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Disables the module `module` for the Safe.\n /// @param prevModule Module that pointed to the module to be removed in the linked list\n /// @param module Module to be removed.\n function disableModule(address prevModule, address module) public authorized {\n // Validate module address and check that it corresponds to module index.\n require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n require(modules[prevModule] == module, \"GS103\");\n modules[prevModule] = modules[module];\n modules[module] = address(0);\n emit DisabledModule(module);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public virtual returns (bool success) {\n // Only whitelisted modules are allowed.\n require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), \"GS104\");\n // Execute transaction without further confirmations.\n success = execute(to, value, data, operation, gasleft());\n if (success) emit ExecutionFromModuleSuccess(msg.sender);\n else emit ExecutionFromModuleFailure(msg.sender);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModuleReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public returns (bool success, bytes memory returnData) {\n success = execTransactionFromModule(to, value, data, operation);\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // Load free memory location\n let ptr := mload(0x40)\n // We allocate memory for the return data by setting the free memory location to\n // current free memory location + data size + 32 bytes for data size value\n mstore(0x40, add(ptr, add(returndatasize(), 0x20)))\n // Store the size\n mstore(ptr, returndatasize())\n // Store the data\n returndatacopy(add(ptr, 0x20), 0, returndatasize())\n // Point the return data to the correct memory location\n returnData := ptr\n }\n }\n\n /// @dev Returns if an module is enabled\n /// @return True if the module is enabled\n function isModuleEnabled(address module) public view returns (bool) {\n return SENTINEL_MODULES != module && modules[module] != address(0);\n }\n\n /// @dev Returns array of modules.\n /// @param start Start of the page.\n /// @param pageSize Maximum number of modules that should be returned.\n /// @return array Array of modules.\n /// @return next Start of the next page.\n function getModulesPaginated(address start, uint256 pageSize) external view returns (address[] memory array, address next) {\n // Init array with max page size\n array = new address[](pageSize);\n\n // Populate return array\n uint256 moduleCount = 0;\n address currentModule = modules[start];\n while (currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {\n array[moduleCount] = currentModule;\n currentModule = modules[currentModule];\n moduleCount++;\n }\n next = currentModule;\n // Set correct size of returned array\n // solhint-disable-next-line no-inline-assembly\n assembly {\n mstore(array, moduleCount)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/OwnerManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/SelfAuthorized.sol\";\n\n/// @title OwnerManager - Manages a set of owners and a threshold to perform actions.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract OwnerManager is SelfAuthorized {\n event AddedOwner(address owner);\n event RemovedOwner(address owner);\n event ChangedThreshold(uint256 threshold);\n\n address internal constant SENTINEL_OWNERS = address(0x1);\n\n mapping(address => address) internal owners;\n uint256 internal ownerCount;\n uint256 internal threshold;\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n function setupOwners(address[] memory _owners, uint256 _threshold) internal {\n // Threshold can only be 0 at initialization.\n // Check ensures that setup function can only be called once.\n require(threshold == 0, \"GS200\");\n // Validate that threshold is smaller than number of added owners.\n require(_threshold <= _owners.length, \"GS201\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"GS202\");\n // Initializing Safe owners.\n address currentOwner = SENTINEL_OWNERS;\n for (uint256 i = 0; i < _owners.length; i++) {\n // Owner address cannot be null.\n address owner = _owners[i];\n require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, \"GS203\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"GS204\");\n owners[currentOwner] = owner;\n currentOwner = owner;\n }\n owners[currentOwner] = SENTINEL_OWNERS;\n ownerCount = _owners.length;\n threshold = _threshold;\n }\n\n /// @dev Allows to add a new owner to the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.\n /// @param owner New owner address.\n /// @param _threshold New threshold.\n function addOwnerWithThreshold(address owner, uint256 _threshold) public authorized {\n // Owner address cannot be null, the sentinel or the Safe itself.\n require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), \"GS203\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"GS204\");\n owners[owner] = owners[SENTINEL_OWNERS];\n owners[SENTINEL_OWNERS] = owner;\n ownerCount++;\n emit AddedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold) changeThreshold(_threshold);\n }\n\n /// @dev Allows to remove an owner from the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.\n /// @param prevOwner Owner that pointed to the owner to be removed in the linked list\n /// @param owner Owner address to be removed.\n /// @param _threshold New threshold.\n function removeOwner(\n address prevOwner,\n address owner,\n uint256 _threshold\n ) public authorized {\n // Only allow to remove an owner, if threshold can still be reached.\n require(ownerCount - 1 >= _threshold, \"GS201\");\n // Validate owner address and check that it corresponds to owner index.\n require(owner != address(0) && owner != SENTINEL_OWNERS, \"GS203\");\n require(owners[prevOwner] == owner, \"GS205\");\n owners[prevOwner] = owners[owner];\n owners[owner] = address(0);\n ownerCount--;\n emit RemovedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold) changeThreshold(_threshold);\n }\n\n /// @dev Allows to swap/replace an owner from the Safe with another address.\n /// This can only be done via a Safe transaction.\n /// @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.\n /// @param prevOwner Owner that pointed to the owner to be replaced in the linked list\n /// @param oldOwner Owner address to be replaced.\n /// @param newOwner New owner address.\n function swapOwner(\n address prevOwner,\n address oldOwner,\n address newOwner\n ) public authorized {\n // Owner address cannot be null, the sentinel or the Safe itself.\n require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), \"GS203\");\n // No duplicate owners allowed.\n require(owners[newOwner] == address(0), \"GS204\");\n // Validate oldOwner address and check that it corresponds to owner index.\n require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, \"GS203\");\n require(owners[prevOwner] == oldOwner, \"GS205\");\n owners[newOwner] = owners[oldOwner];\n owners[prevOwner] = newOwner;\n owners[oldOwner] = address(0);\n emit RemovedOwner(oldOwner);\n emit AddedOwner(newOwner);\n }\n\n /// @dev Allows to update the number of required confirmations by Safe owners.\n /// This can only be done via a Safe transaction.\n /// @notice Changes the threshold of the Safe to `_threshold`.\n /// @param _threshold New threshold.\n function changeThreshold(uint256 _threshold) public authorized {\n // Validate that threshold is smaller than number of owners.\n require(_threshold <= ownerCount, \"GS201\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"GS202\");\n threshold = _threshold;\n emit ChangedThreshold(threshold);\n }\n\n function getThreshold() public view returns (uint256) {\n return threshold;\n }\n\n function isOwner(address owner) public view returns (bool) {\n return owner != SENTINEL_OWNERS && owners[owner] != address(0);\n }\n\n /// @dev Returns array of owners.\n /// @return Array of Safe owners.\n function getOwners() public view returns (address[] memory) {\n address[] memory array = new address[](ownerCount);\n\n // populate return array\n uint256 index = 0;\n address currentOwner = owners[SENTINEL_OWNERS];\n while (currentOwner != SENTINEL_OWNERS) {\n array[index] = currentOwner;\n currentOwner = owners[currentOwner];\n index++;\n }\n return array;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/Enum.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Enum - Collection of enums\n/// @author Richard Meissner - \ncontract Enum {\n enum Operation {Call, DelegateCall}\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/EtherPaymentFallback.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title EtherPaymentFallback - A contract that has a fallback to accept ether payments\n/// @author Richard Meissner - \ncontract EtherPaymentFallback {\n event SafeReceived(address indexed sender, uint256 value);\n\n /// @dev Fallback function accepts Ether transactions.\n receive() external payable {\n emit SafeReceived(msg.sender, msg.value);\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SecuredTokenTransfer.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SecuredTokenTransfer - Secure token transfer\n/// @author Richard Meissner - \ncontract SecuredTokenTransfer {\n /// @dev Transfers a token and returns if it was a success\n /// @param token Token that should be transferred\n /// @param receiver Receiver to whom the token should be transferred\n /// @param amount The amount of tokens that should be transferred\n function transferToken(\n address token,\n address receiver,\n uint256 amount\n ) internal returns (bool transferred) {\n // 0xa9059cbb - keccack(\"transfer(address,uint256)\")\n bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // We write the return value to scratch space.\n // See https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory\n let success := call(sub(gas(), 10000), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n switch returndatasize()\n case 0 {\n transferred := success\n }\n case 0x20 {\n transferred := iszero(or(iszero(success), iszero(mload(0))))\n }\n default {\n transferred := 0\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SelfAuthorized.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SelfAuthorized - authorizes current contract to perform actions\n/// @author Richard Meissner - \ncontract SelfAuthorized {\n function requireSelfCall() private view {\n require(msg.sender == address(this), \"GS031\");\n }\n\n modifier authorized() {\n // This is a function call as it minimized the bytecode size\n requireSelfCall();\n _;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SignatureDecoder.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SignatureDecoder - Decodes signatures that a encoded as bytes\n/// @author Richard Meissner - \ncontract SignatureDecoder {\n /// @dev divides bytes signature into `uint8 v, bytes32 r, bytes32 s`.\n /// @notice Make sure to peform a bounds check for @param pos, to avoid out of bounds access on @param signatures\n /// @param pos which signature to read. A prior bounds check of this parameter should be performed, to avoid out of bounds access\n /// @param signatures concatenated rsv signatures\n function signatureSplit(bytes memory signatures, uint256 pos)\n internal\n pure\n returns (\n uint8 v,\n bytes32 r,\n bytes32 s\n )\n {\n // The signature format is a compact form of:\n // {bytes32 r}{bytes32 s}{uint8 v}\n // Compact means, uint8 is not padded to 32 bytes.\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let signaturePos := mul(0x41, pos)\n r := mload(add(signatures, add(signaturePos, 0x20)))\n s := mload(add(signatures, add(signaturePos, 0x40)))\n // Here we are loading the last 32 bytes, including 31 bytes\n // of 's'. There is no 'mload8' to do this.\n //\n // 'byte' is not working due to the Solidity parser, so lets\n // use the second best option, 'and'\n v := and(mload(add(signatures, add(signaturePos, 0x41))), 0xff)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/Singleton.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Singleton - Base for singleton contracts (should always be first super contract)\n/// This contract is tightly coupled to our proxy contract (see `proxies/GnosisSafeProxy.sol`)\n/// @author Richard Meissner - \ncontract Singleton {\n // singleton always needs to be first declared variable, to ensure that it is at the same location as in the Proxy contract.\n // It should also always be ensured that the address is stored alone (uses a full word)\n address private singleton;\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/StorageAccessible.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title StorageAccessible - generic base contract that allows callers to access all internal storage.\n/// @notice See https://github.com/gnosis/util-contracts/blob/bb5fe5fb5df6d8400998094fb1b32a178a47c3a1/contracts/StorageAccessible.sol\ncontract StorageAccessible {\n /**\n * @dev Reads `length` bytes of storage in the currents contract\n * @param offset - the offset in the current contract's storage in words to start reading from\n * @param length - the number of words (32 bytes) of data to read\n * @return the bytes that were read.\n */\n function getStorageAt(uint256 offset, uint256 length) public view returns (bytes memory) {\n bytes memory result = new bytes(length * 32);\n for (uint256 index = 0; index < length; index++) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let word := sload(add(offset, index))\n mstore(add(add(result, 0x20), mul(index, 0x20)), word)\n }\n }\n return result;\n }\n\n /**\n * @dev Performs a delegetecall on a targetContract in the context of self.\n * Internally reverts execution to avoid side effects (making it static).\n *\n * This method reverts with data equal to `abi.encode(bool(success), bytes(response))`.\n * Specifically, the `returndata` after a call to this method will be:\n * `success:bool || response.length:uint256 || response:bytes`.\n *\n * @param targetContract Address of the contract containing the code to execute.\n * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).\n */\n function simulateAndRevert(address targetContract, bytes memory calldataPayload) external {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let success := delegatecall(gas(), targetContract, add(calldataPayload, 0x20), mload(calldataPayload), 0, 0)\n\n mstore(0x00, success)\n mstore(0x20, returndatasize())\n returndatacopy(0x40, 0, returndatasize())\n revert(0, add(returndatasize(), 0x40))\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/external/GnosisSafeMath.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title GnosisSafeMath\n * @dev Math operations with safety checks that revert on error\n * Renamed from SafeMath to GnosisSafeMath to avoid conflicts\n * TODO: remove once open zeppelin update to solc 0.5.0\n */\nlibrary GnosisSafeMath {\n /**\n * @dev Multiplies two numbers, reverts on overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b);\n\n return c;\n }\n\n /**\n * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Adds two numbers, reverts on overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a);\n\n return c;\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 a >= b ? a : b;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/GnosisSafe.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./base/ModuleManager.sol\";\nimport \"./base/OwnerManager.sol\";\nimport \"./base/FallbackManager.sol\";\nimport \"./base/GuardManager.sol\";\nimport \"./common/EtherPaymentFallback.sol\";\nimport \"./common/Singleton.sol\";\nimport \"./common/SignatureDecoder.sol\";\nimport \"./common/SecuredTokenTransfer.sol\";\nimport \"./common/StorageAccessible.sol\";\nimport \"./interfaces/ISignatureValidator.sol\";\nimport \"./external/GnosisSafeMath.sol\";\n\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafe is\n EtherPaymentFallback,\n Singleton,\n ModuleManager,\n OwnerManager,\n SignatureDecoder,\n SecuredTokenTransfer,\n ISignatureValidatorConstants,\n FallbackManager,\n StorageAccessible,\n GuardManager\n{\n using GnosisSafeMath for uint256;\n\n string public constant VERSION = \"1.3.0\";\n\n // keccak256(\n // \"EIP712Domain(uint256 chainId,address verifyingContract)\"\n // );\n bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;\n\n // keccak256(\n // \"SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)\"\n // );\n bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;\n\n event SafeSetup(address indexed initiator, address[] owners, uint256 threshold, address initializer, address fallbackHandler);\n event ApproveHash(bytes32 indexed approvedHash, address indexed owner);\n event SignMsg(bytes32 indexed msgHash);\n event ExecutionFailure(bytes32 txHash, uint256 payment);\n event ExecutionSuccess(bytes32 txHash, uint256 payment);\n\n uint256 public nonce;\n bytes32 private _deprecatedDomainSeparator;\n // Mapping to keep track of all message hashes that have been approve by ALL REQUIRED owners\n mapping(bytes32 => uint256) public signedMessages;\n // Mapping to keep track of all hashes (message or transaction) that have been approve by ANY owners\n mapping(address => mapping(bytes32 => uint256)) public approvedHashes;\n\n // This constructor ensures that this contract can only be used as a master copy for Proxy contracts\n constructor() {\n // By setting the threshold it is not possible to call setup anymore,\n // so we create a Safe with 0 owners and threshold 1.\n // This is an unusable Safe, perfect for the singleton\n threshold = 1;\n }\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n /// @param to Contract address for optional delegate call.\n /// @param data Data payload for optional delegate call.\n /// @param fallbackHandler Handler for fallback calls to this contract\n /// @param paymentToken Token that should be used for the payment (0 is ETH)\n /// @param payment Value that should be paid\n /// @param paymentReceiver Adddress that should receive the payment (or 0 if tx.origin)\n function setup(\n address[] calldata _owners,\n uint256 _threshold,\n address to,\n bytes calldata data,\n address fallbackHandler,\n address paymentToken,\n uint256 payment,\n address payable paymentReceiver\n ) external {\n // setupOwners checks if the Threshold is already set, therefore preventing that this method is called twice\n setupOwners(_owners, _threshold);\n if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);\n // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules\n setupModules(to, data);\n\n if (payment > 0) {\n // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)\n // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment\n handlePayment(payment, 0, 1, paymentToken, paymentReceiver);\n }\n emit SafeSetup(msg.sender, _owners, _threshold, to, fallbackHandler);\n }\n\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\n /// Note: The fees are always transferred, even if the user transaction fails.\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @param safeTxGas Gas that should be used for the Safe transaction.\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Gas price that should be used for the payment calculation.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\n function execTransaction(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures\n ) public payable virtual returns (bool success) {\n bytes32 txHash;\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n bytes memory txHashData =\n encodeTransactionData(\n // Transaction info\n to,\n value,\n data,\n operation,\n safeTxGas,\n // Payment info\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n // Signature info\n nonce\n );\n // Increase nonce and execute transaction.\n nonce++;\n txHash = keccak256(txHashData);\n checkSignatures(txHash, txHashData, signatures);\n }\n address guard = getGuard();\n {\n if (guard != address(0)) {\n Guard(guard).checkTransaction(\n // Transaction info\n to,\n value,\n data,\n operation,\n safeTxGas,\n // Payment info\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n // Signature info\n signatures,\n msg.sender\n );\n }\n }\n // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)\n // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150\n require(gasleft() >= ((safeTxGas * 64) / 63).max(safeTxGas + 2500) + 500, \"GS010\");\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n uint256 gasUsed = gasleft();\n // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)\n // We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas\n success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);\n gasUsed = gasUsed.sub(gasleft());\n // If no safeTxGas and no gasPrice was set (e.g. both are 0), then the internal tx is required to be successful\n // This makes it possible to use `estimateGas` without issues, as it searches for the minimum gas where the tx doesn't revert\n require(success || safeTxGas != 0 || gasPrice != 0, \"GS013\");\n // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls\n uint256 payment = 0;\n if (gasPrice > 0) {\n payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);\n }\n if (success) emit ExecutionSuccess(txHash, payment);\n else emit ExecutionFailure(txHash, payment);\n }\n {\n if (guard != address(0)) {\n Guard(guard).checkAfterExecution(txHash, success);\n }\n }\n }\n\n function handlePayment(\n uint256 gasUsed,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver\n ) private returns (uint256 payment) {\n // solhint-disable-next-line avoid-tx-origin\n address payable receiver = refundReceiver == address(0) ? payable(tx.origin) : refundReceiver;\n if (gasToken == address(0)) {\n // For ETH we will only adjust the gas price to not be higher than the actual used gas price\n payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);\n require(receiver.send(payment), \"GS011\");\n } else {\n payment = gasUsed.add(baseGas).mul(gasPrice);\n require(transferToken(gasToken, receiver, payment), \"GS012\");\n }\n }\n\n /**\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n * @param data That should be signed (this is passed to an external validator contract)\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\n */\n function checkSignatures(\n bytes32 dataHash,\n bytes memory data,\n bytes memory signatures\n ) public view {\n // Load threshold to avoid multiple storage loads\n uint256 _threshold = threshold;\n // Check that a threshold is set\n require(_threshold > 0, \"GS001\");\n checkNSignatures(dataHash, data, signatures, _threshold);\n }\n\n /**\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n * @param data That should be signed (this is passed to an external validator contract)\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\n * @param requiredSignatures Amount of required valid signatures.\n */\n function checkNSignatures(\n bytes32 dataHash,\n bytes memory data,\n bytes memory signatures,\n uint256 requiredSignatures\n ) public view {\n // Check that the provided signature data is not too short\n require(signatures.length >= requiredSignatures.mul(65), \"GS020\");\n // There cannot be an owner with address 0.\n address lastOwner = address(0);\n address currentOwner;\n uint8 v;\n bytes32 r;\n bytes32 s;\n uint256 i;\n for (i = 0; i < requiredSignatures; i++) {\n (v, r, s) = signatureSplit(signatures, i);\n if (v == 0) {\n // If v is 0 then it is a contract signature\n // When handling contract signatures the address of the contract is encoded into r\n currentOwner = address(uint160(uint256(r)));\n\n // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes\n // This check is not completely accurate, since it is possible that more signatures than the threshold are send.\n // Here we only check that the pointer is not pointing inside the part that is being processed\n require(uint256(s) >= requiredSignatures.mul(65), \"GS021\");\n\n // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)\n require(uint256(s).add(32) <= signatures.length, \"GS022\");\n\n // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length\n uint256 contractSignatureLen;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n contractSignatureLen := mload(add(add(signatures, s), 0x20))\n }\n require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, \"GS023\");\n\n // Check signature\n bytes memory contractSignature;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s\n contractSignature := add(add(signatures, s), 0x20)\n }\n require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, \"GS024\");\n } else if (v == 1) {\n // If v is 1 then it is an approved hash\n // When handling approved hashes the address of the approver is encoded into r\n currentOwner = address(uint160(uint256(r)));\n // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction\n require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, \"GS025\");\n } else if (v > 30) {\n // If v > 30 then default va (27,28) has been adjusted for eth_sign flow\n // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover\n currentOwner = ecrecover(keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", dataHash)), v - 4, r, s);\n } else {\n // Default is the ecrecover flow with the provided data hash\n // Use ecrecover with the messageHash for EOA signatures\n currentOwner = ecrecover(dataHash, v, r, s);\n }\n require(currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS, \"GS026\");\n lastOwner = currentOwner;\n }\n }\n\n /// @dev Allows to estimate a Safe transaction.\n /// This method is only meant for estimation purpose, therefore the call will always revert and encode the result in the revert data.\n /// Since the `estimateGas` function includes refunds, call this method to get an estimated of the costs that are deducted from the safe with `execTransaction`\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @return Estimate without refunds and overhead fees (base transaction and payload data gas costs).\n /// @notice Deprecated in favor of common/StorageAccessible.sol and will be removed in next version.\n function requiredTxGas(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation\n ) external returns (uint256) {\n uint256 startGas = gasleft();\n // We don't provide an error message here, as we use it to return the estimate\n require(execute(to, value, data, operation, gasleft()));\n uint256 requiredGas = startGas - gasleft();\n // Convert response to string and return via error message\n revert(string(abi.encodePacked(requiredGas)));\n }\n\n /**\n * @dev Marks a hash as approved. This can be used to validate a hash that is used by a signature.\n * @param hashToApprove The hash that should be marked as approved for signatures that are verified by this contract.\n */\n function approveHash(bytes32 hashToApprove) external {\n require(owners[msg.sender] != address(0), \"GS030\");\n approvedHashes[msg.sender][hashToApprove] = 1;\n emit ApproveHash(hashToApprove, msg.sender);\n }\n\n /// @dev Returns the chain id used by this contract.\n function getChainId() public view returns (uint256) {\n uint256 id;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n id := chainid()\n }\n return id;\n }\n\n function domainSeparator() public view returns (bytes32) {\n return keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, getChainId(), this));\n }\n\n /// @dev Returns the bytes that are hashed to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Gas that should be used for the safe transaction.\n /// @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash bytes.\n function encodeTransactionData(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n ) public view returns (bytes memory) {\n bytes32 safeTxHash =\n keccak256(\n abi.encode(\n SAFE_TX_TYPEHASH,\n to,\n value,\n keccak256(data),\n operation,\n safeTxGas,\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n _nonce\n )\n );\n return abi.encodePacked(bytes1(0x19), bytes1(0x01), domainSeparator(), safeTxHash);\n }\n\n /// @dev Returns hash to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Fas that should be used for the safe transaction.\n /// @param baseGas Gas costs for data used to trigger the safe transaction.\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash.\n function getTransactionHash(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n ) public view returns (bytes32) {\n return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./GnosisSafe.sol\";\n\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafeL2 is GnosisSafe {\n event SafeMultiSigTransaction(\n address to,\n uint256 value,\n bytes data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes signatures,\n // We combine nonce, sender and threshold into one to avoid stack too deep\n // Dev note: additionalInfo should not contain `bytes`, as this complicates decoding\n bytes additionalInfo\n );\n\n event SafeModuleTransaction(address module, address to, uint256 value, bytes data, Enum.Operation operation);\n\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\n /// Note: The fees are always transferred, even if the user transaction fails.\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @param safeTxGas Gas that should be used for the Safe transaction.\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Gas price that should be used for the payment calculation.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\n function execTransaction(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures\n ) public payable override returns (bool) {\n bytes memory additionalInfo;\n {\n additionalInfo = abi.encode(nonce, msg.sender, threshold);\n }\n emit SafeMultiSigTransaction(\n to,\n value,\n data,\n operation,\n safeTxGas,\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n signatures,\n additionalInfo\n );\n return super.execTransaction(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, signatures);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public override returns (bool success) {\n emit SafeModuleTransaction(msg.sender, to, value, data, operation);\n success = super.execTransactionFromModule(to, value, data, operation);\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/interfaces/ISignatureValidator.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\ncontract ISignatureValidatorConstants {\n // bytes4(keccak256(\"isValidSignature(bytes,bytes)\")\n bytes4 internal constant EIP1271_MAGIC_VALUE = 0x20c13b0b;\n}\n\nabstract contract ISignatureValidator is ISignatureValidatorConstants {\n /**\n * @dev Should return whether the signature provided is valid for the provided data\n * @param _data Arbitrary length data signed on the behalf of address(this)\n * @param _signature Signature byte array associated with _data\n *\n * MUST return the bytes4 magic value 0x20c13b0b when function passes.\n * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)\n * MUST allow external calls\n */\n function isValidSignature(bytes memory _data, bytes memory _signature) public view virtual returns (bytes4);\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Multi Send Call Only - Allows to batch multiple transactions into one, but only calls\n/// @author Stefan George - \n/// @author Richard Meissner - \n/// @notice The guard logic is not required here as this contract doesn't support nested delegate calls\ncontract MultiSendCallOnly {\n /// @dev Sends multiple transactions and reverts all if one fails.\n /// @param transactions Encoded transactions. Each transaction is encoded as a packed bytes of\n /// operation has to be uint8(0) in this version (=> 1 byte),\n /// to as a address (=> 20 bytes),\n /// value as a uint256 (=> 32 bytes),\n /// data length as a uint256 (=> 32 bytes),\n /// data as bytes.\n /// see abi.encodePacked for more information on packed encoding\n /// @notice The code is for most part the same as the normal MultiSend (to keep compatibility),\n /// but reverts if a transaction tries to use a delegatecall.\n /// @notice This method is payable as delegatecalls keep the msg.value from the previous call\n /// If the calling method (e.g. execTransaction) received ETH this would revert otherwise\n function multiSend(bytes memory transactions) public payable {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let length := mload(transactions)\n let i := 0x20\n for {\n // Pre block is not used in \"while mode\"\n } lt(i, length) {\n // Post block is not used in \"while mode\"\n } {\n // First byte of the data is the operation.\n // We shift by 248 bits (256 - 8 [operation byte]) it right since mload will always load 32 bytes (a word).\n // This will also zero out unused data.\n let operation := shr(0xf8, mload(add(transactions, i)))\n // We offset the load address by 1 byte (operation byte)\n // We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data.\n let to := shr(0x60, mload(add(transactions, add(i, 0x01))))\n // We offset the load address by 21 byte (operation byte + 20 address bytes)\n let value := mload(add(transactions, add(i, 0x15)))\n // We offset the load address by 53 byte (operation byte + 20 address bytes + 32 value bytes)\n let dataLength := mload(add(transactions, add(i, 0x35)))\n // We offset the load address by 85 byte (operation byte + 20 address bytes + 32 value bytes + 32 data length bytes)\n let data := add(transactions, add(i, 0x55))\n let success := 0\n switch operation\n case 0 {\n success := call(gas(), to, value, data, dataLength, 0, 0)\n }\n // This version does not allow delegatecalls\n case 1 {\n revert(0, 0)\n }\n if eq(success, 0) {\n revert(0, 0)\n }\n // Next entry starts at 85 byte + data length\n i := add(i, add(0x55, dataLength))\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxy.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain\n/// @author Richard Meissner - \ninterface IProxy {\n function masterCopy() external view returns (address);\n}\n\n/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafeProxy {\n // singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.\n // To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`\n address internal singleton;\n\n /// @dev Constructor function sets address of singleton contract.\n /// @param _singleton Singleton address.\n constructor(address _singleton) {\n require(_singleton != address(0), \"Invalid singleton address provided\");\n singleton = _singleton;\n }\n\n /// @dev Fallback function forwards all transactions and returns all received return data.\n fallback() external payable {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)\n // 0xa619486e == keccak(\"masterCopy()\"). The value is right padded to 32-bytes with 0s\n if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {\n mstore(0, _singleton)\n return(0, 0x20)\n }\n calldatacopy(0, 0, calldatasize())\n let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)\n returndatacopy(0, 0, returndatasize())\n if eq(success, 0) {\n revert(0, returndatasize())\n }\n return(0, returndatasize())\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./GnosisSafeProxy.sol\";\nimport \"./IProxyCreationCallback.sol\";\n\n/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n/// @author Stefan George - \ncontract GnosisSafeProxyFactory {\n event ProxyCreation(GnosisSafeProxy proxy, address singleton);\n\n /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n /// @param singleton Address of singleton contract.\n /// @param data Payload for message call sent to new proxy contract.\n function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {\n proxy = new GnosisSafeProxy(singleton);\n if (data.length > 0)\n // solhint-disable-next-line no-inline-assembly\n assembly {\n if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {\n revert(0, 0)\n }\n }\n emit ProxyCreation(proxy, singleton);\n }\n\n /// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.\n function proxyRuntimeCode() public pure returns (bytes memory) {\n return type(GnosisSafeProxy).runtimeCode;\n }\n\n /// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.\n function proxyCreationCode() public pure returns (bytes memory) {\n return type(GnosisSafeProxy).creationCode;\n }\n\n /// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.\n /// This method is only meant as an utility to be called from other methods\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function deployProxyWithNonce(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce\n ) internal returns (GnosisSafeProxy proxy) {\n // If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it\n bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));\n bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));\n // solhint-disable-next-line no-inline-assembly\n assembly {\n proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)\n }\n require(address(proxy) != address(0), \"Create2 call failed\");\n }\n\n /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function createProxyWithNonce(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce\n ) public returns (GnosisSafeProxy proxy) {\n proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);\n if (initializer.length > 0)\n // solhint-disable-next-line no-inline-assembly\n assembly {\n if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {\n revert(0, 0)\n }\n }\n emit ProxyCreation(proxy, _singleton);\n }\n\n /// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n /// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.\n function createProxyWithCallback(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce,\n IProxyCreationCallback callback\n ) public returns (GnosisSafeProxy proxy) {\n uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));\n proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);\n if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);\n }\n\n /// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`\n /// This method is only meant for address calculation purpose when you use an initializer that would revert,\n /// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function calculateCreateProxyWithNonceAddress(\n address _singleton,\n bytes calldata initializer,\n uint256 saltNonce\n ) external returns (GnosisSafeProxy proxy) {\n proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);\n revert(string(abi.encodePacked(proxy)));\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/IProxyCreationCallback.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"./GnosisSafeProxy.sol\";\n\ninterface IProxyCreationCallback {\n function proxyCreated(\n GnosisSafeProxy proxy,\n address _singleton,\n bytes calldata initializer,\n uint256 saltNonce\n ) external;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/core/Module.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Module Interface - A contract that can pass messages to a Module Manager contract if enabled by that contract.\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../interfaces/IAvatar.sol\";\nimport \"../factory/FactoryFriendly.sol\";\nimport \"../guard/Guardable.sol\";\n\nabstract contract Module is FactoryFriendly, Guardable {\n /// @dev Address that will ultimately execute function calls.\n address public avatar;\n /// @dev Address that this module will pass transactions to.\n address public target;\n\n /// @dev Emitted each time the avatar is set.\n event AvatarSet(address indexed previousAvatar, address indexed newAvatar);\n /// @dev Emitted each time the Target is set.\n event TargetSet(address indexed previousTarget, address indexed newTarget);\n\n /// @dev Sets the avatar to a new avatar (`newAvatar`).\n /// @notice Can only be called by the current owner.\n function setAvatar(address _avatar) public onlyOwner {\n address previousAvatar = avatar;\n avatar = _avatar;\n emit AvatarSet(previousAvatar, _avatar);\n }\n\n /// @dev Sets the target to a new target (`newTarget`).\n /// @notice Can only be called by the current owner.\n function setTarget(address _target) public onlyOwner {\n address previousTarget = target;\n target = _target;\n emit TargetSet(previousTarget, _target);\n }\n\n /// @dev Passes a transaction to be executed by the avatar.\n /// @notice Can only be called by this contract.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function exec(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) internal returns (bool success) {\n /// Check if a transactioon guard is enabled.\n if (guard != address(0)) {\n IGuard(guard).checkTransaction(\n /// Transaction info used by module transactions.\n to,\n value,\n data,\n operation,\n /// Zero out the redundant transaction information only used for Safe multisig transctions.\n 0,\n 0,\n 0,\n address(0),\n payable(0),\n bytes(\"0x\"),\n msg.sender\n );\n }\n success = IAvatar(target).execTransactionFromModule(\n to,\n value,\n data,\n operation\n );\n if (guard != address(0)) {\n IGuard(guard).checkAfterExecution(bytes32(\"0x\"), success);\n }\n return success;\n }\n\n /// @dev Passes a transaction to be executed by the target and returns data.\n /// @notice Can only be called by this contract.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execAndReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) internal returns (bool success, bytes memory returnData) {\n /// Check if a transactioon guard is enabled.\n if (guard != address(0)) {\n IGuard(guard).checkTransaction(\n /// Transaction info used by module transactions.\n to,\n value,\n data,\n operation,\n /// Zero out the redundant transaction information only used for Safe multisig transctions.\n 0,\n 0,\n 0,\n address(0),\n payable(0),\n bytes(\"0x\"),\n msg.sender\n );\n }\n (success, returnData) = IAvatar(target)\n .execTransactionFromModuleReturnData(to, value, data, operation);\n if (guard != address(0)) {\n IGuard(guard).checkAfterExecution(bytes32(\"0x\"), success);\n }\n return (success, returnData);\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/factory/FactoryFriendly.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Zodiac FactoryFriendly - A contract that allows other contracts to be initializable and pass bytes as arguments to define contract state\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nabstract contract FactoryFriendly is OwnableUpgradeable {\n function setUp(bytes memory initializeParams) public virtual;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.8.0;\n\ncontract ModuleProxyFactory {\n event ModuleProxyCreation(\n address indexed proxy,\n address indexed masterCopy\n );\n\n /// `target` can not be zero.\n error ZeroAddress(address target);\n\n /// `address_` is already taken.\n error TakenAddress(address address_);\n\n /// @notice Initialization failed.\n error FailedInitialization();\n\n function createProxy(address target, bytes32 salt)\n internal\n returns (address result)\n {\n if (address(target) == address(0)) revert ZeroAddress(target);\n bytes memory deployment = abi.encodePacked(\n hex\"602d8060093d393df3363d3d373d3d3d363d73\",\n target,\n hex\"5af43d82803e903d91602b57fd5bf3\"\n );\n // solhint-disable-next-line no-inline-assembly\n assembly {\n result := create2(0, add(deployment, 0x20), mload(deployment), salt)\n }\n if (result == address(0)) revert TakenAddress(result);\n }\n\n function deployModule(\n address masterCopy,\n bytes memory initializer,\n uint256 saltNonce\n ) public returns (address proxy) {\n proxy = createProxy(\n masterCopy,\n keccak256(abi.encodePacked(keccak256(initializer), saltNonce))\n );\n (bool success, ) = proxy.call(initializer);\n if (!success) revert FailedInitialization();\n\n emit ModuleProxyCreation(proxy, masterCopy);\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/guard/BaseGuard.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport \"../interfaces/IGuard.sol\";\n\nabstract contract BaseGuard is IERC165 {\n function supportsInterface(bytes4 interfaceId)\n external\n pure\n override\n returns (bool)\n {\n return\n interfaceId == type(IGuard).interfaceId || // 0xe6d7a83a\n interfaceId == type(IERC165).interfaceId; // 0x01ffc9a7\n }\n\n /// @dev Module transactions only use the first four parameters: to, value, data, and operation.\n /// Module.sol hardcodes the remaining parameters as 0 since they are not used for module transactions.\n /// @notice This interface is used to maintain compatibilty with Gnosis Safe transaction guards.\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external virtual;\n\n function checkAfterExecution(bytes32 txHash, bool success) external virtual;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/guard/Guardable.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"./BaseGuard.sol\";\n\n/// @title Guardable - A contract that manages fallback calls made to this contract\ncontract Guardable is OwnableUpgradeable {\n address public guard;\n\n event ChangedGuard(address guard);\n\n /// `guard_` does not implement IERC165.\n error NotIERC165Compliant(address guard_);\n\n /// @dev Set a guard that checks transactions before execution.\n /// @param _guard The address of the guard to be used or the 0 address to disable the guard.\n function setGuard(address _guard) external onlyOwner {\n if (_guard != address(0)) {\n if (!BaseGuard(_guard).supportsInterface(type(IGuard).interfaceId))\n revert NotIERC165Compliant(_guard);\n }\n guard = _guard;\n emit ChangedGuard(guard);\n }\n\n function getGuard() external view returns (address _guard) {\n return guard;\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Zodiac Avatar - A contract that manages modules that can execute transactions via this contract.\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\n\ninterface IAvatar {\n event EnabledModule(address module);\n event DisabledModule(address module);\n event ExecutionFromModuleSuccess(address indexed module);\n event ExecutionFromModuleFailure(address indexed module);\n\n /// @dev Enables a module on the avatar.\n /// @notice Can only be called by the avatar.\n /// @notice Modules should be stored as a linked list.\n /// @notice Must emit EnabledModule(address module) if successful.\n /// @param module Module to be enabled.\n function enableModule(address module) external;\n\n /// @dev Disables a module on the avatar.\n /// @notice Can only be called by the avatar.\n /// @notice Must emit DisabledModule(address module) if successful.\n /// @param prevModule Address that pointed to the module to be removed in the linked list\n /// @param module Module to be removed.\n function disableModule(address prevModule, address module) external;\n\n /// @dev Allows a Module to execute a transaction.\n /// @notice Can only be called by an enabled module.\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) external returns (bool success);\n\n /// @dev Allows a Module to execute a transaction and return data\n /// @notice Can only be called by an enabled module.\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execTransactionFromModuleReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) external returns (bool success, bytes memory returnData);\n\n /// @dev Returns if an module is enabled\n /// @return True if the module is enabled\n function isModuleEnabled(address module) external view returns (bool);\n\n /// @dev Returns array of modules.\n /// @param start Start of the page.\n /// @param pageSize Maximum number of modules that should be returned.\n /// @return array Array of modules.\n /// @return next Start of the next page.\n function getModulesPaginated(address start, uint256 pageSize)\n external\n view\n returns (address[] memory array, address next);\n}\n" + }, + "@gnosis.pm/zodiac/contracts/interfaces/IGuard.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\n\ninterface IGuard {\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external;\n\n function checkAfterExecution(bytes32 txHash, bool success) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 * By default, the owner account will be the one that deploys the contract. This\n * can 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 OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\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 require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing 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 require(newOwner != address(0), \"Ownable: new owner is the zero address\");\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/governance/utils/IVotesUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotesUpgradeable {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\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 * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\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 Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 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. Equivalent to `reinitializer(1)`.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\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 * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\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 modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\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 require(_initializing, \"Initializable: contract is not initializing\");\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 function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20Upgradeable.sol\";\nimport \"./extensions/IERC20MetadataUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC20_init_unchained(name_, symbol_);\n }\n\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[45] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20PermitUpgradeable.sol\";\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/cryptography/draft-EIP712Upgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {\n using CountersUpgradeable for CountersUpgradeable.Counter;\n\n mapping(address => CountersUpgradeable.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n function __ERC20Permit_init(string memory name) internal onlyInitializing {\n __EIP712_init_unchained(name, \"1\");\n }\n\n function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSAUpgradeable.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n CountersUpgradeable.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20SnapshotUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC20Snapshot.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/ArraysUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances and\n * total supply at the time are recorded for later access.\n *\n * This can be used to safely create mechanisms based on token balances such as trustless dividends or weighted voting.\n * In naive implementations it's possible to perform a \"double spend\" attack by reusing the same balance from different\n * accounts. By using snapshots to calculate dividends or voting power, those attacks no longer apply. It can also be\n * used to create an efficient ERC20 forking mechanism.\n *\n * Snapshots are created by the internal {_snapshot} function, which will emit the {Snapshot} event and return a\n * snapshot id. To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with the snapshot\n * id. To get the balance of an account at the time of a snapshot, call the {balanceOfAt} function with the snapshot id\n * and the account address.\n *\n * NOTE: Snapshot policy can be customized by overriding the {_getCurrentSnapshotId} method. For example, having it\n * return `block.number` will trigger the creation of snapshot at the beginning of each new block. When overriding this\n * function, be careful about the monotonicity of its result. Non-monotonic snapshot ids will break the contract.\n *\n * Implementing snapshots for every block using this method will incur significant gas costs. For a gas-efficient\n * alternative consider {ERC20Votes}.\n *\n * ==== Gas Costs\n *\n * Snapshots are efficient. Snapshot creation is _O(1)_. Retrieval of balances or total supply from a snapshot is _O(log\n * n)_ in the number of snapshots that have been created, although _n_ for a specific account will generally be much\n * smaller since identical balances in subsequent snapshots are stored as a single entry.\n *\n * There is a constant overhead for normal ERC20 transfers due to the additional snapshot bookkeeping. This overhead is\n * only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent\n * transfers will have normal cost until the next snapshot, and so on.\n */\n\nabstract contract ERC20SnapshotUpgradeable is Initializable, ERC20Upgradeable {\n function __ERC20Snapshot_init() internal onlyInitializing {\n }\n\n function __ERC20Snapshot_init_unchained() internal onlyInitializing {\n }\n // Inspired by Jordi Baylina's MiniMeToken to record historical balances:\n // https://github.com/Giveth/minime/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol\n\n using ArraysUpgradeable for uint256[];\n using CountersUpgradeable for CountersUpgradeable.Counter;\n\n // Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a\n // Snapshot struct, but that would impede usage of functions that work on an array.\n struct Snapshots {\n uint256[] ids;\n uint256[] values;\n }\n\n mapping(address => Snapshots) private _accountBalanceSnapshots;\n Snapshots private _totalSupplySnapshots;\n\n // Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid.\n CountersUpgradeable.Counter private _currentSnapshotId;\n\n /**\n * @dev Emitted by {_snapshot} when a snapshot identified by `id` is created.\n */\n event Snapshot(uint256 id);\n\n /**\n * @dev Creates a new snapshot and returns its snapshot id.\n *\n * Emits a {Snapshot} event that contains the same id.\n *\n * {_snapshot} is `internal` and you have to decide how to expose it externally. Its usage may be restricted to a\n * set of accounts, for example using {AccessControl}, or it may be open to the public.\n *\n * [WARNING]\n * ====\n * While an open way of calling {_snapshot} is required for certain trust minimization mechanisms such as forking,\n * you must consider that it can potentially be used by attackers in two ways.\n *\n * First, it can be used to increase the cost of retrieval of values from snapshots, although it will grow\n * logarithmically thus rendering this attack ineffective in the long term. Second, it can be used to target\n * specific accounts and increase the cost of ERC20 transfers for them, in the ways specified in the Gas Costs\n * section above.\n *\n * We haven't measured the actual numbers; if this is something you're interested in please reach out to us.\n * ====\n */\n function _snapshot() internal virtual returns (uint256) {\n _currentSnapshotId.increment();\n\n uint256 currentId = _getCurrentSnapshotId();\n emit Snapshot(currentId);\n return currentId;\n }\n\n /**\n * @dev Get the current snapshotId\n */\n function _getCurrentSnapshotId() internal view virtual returns (uint256) {\n return _currentSnapshotId.current();\n }\n\n /**\n * @dev Retrieves the balance of `account` at the time `snapshotId` was created.\n */\n function balanceOfAt(address account, uint256 snapshotId) public view virtual returns (uint256) {\n (bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]);\n\n return snapshotted ? value : balanceOf(account);\n }\n\n /**\n * @dev Retrieves the total supply at the time `snapshotId` was created.\n */\n function totalSupplyAt(uint256 snapshotId) public view virtual returns (uint256) {\n (bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots);\n\n return snapshotted ? value : totalSupply();\n }\n\n // Update balance and/or total supply snapshots before the values are modified. This is implemented\n // in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations.\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n if (from == address(0)) {\n // mint\n _updateAccountSnapshot(to);\n _updateTotalSupplySnapshot();\n } else if (to == address(0)) {\n // burn\n _updateAccountSnapshot(from);\n _updateTotalSupplySnapshot();\n } else {\n // transfer\n _updateAccountSnapshot(from);\n _updateAccountSnapshot(to);\n }\n }\n\n function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) {\n require(snapshotId > 0, \"ERC20Snapshot: id is 0\");\n require(snapshotId <= _getCurrentSnapshotId(), \"ERC20Snapshot: nonexistent id\");\n\n // When a valid snapshot is queried, there are three possibilities:\n // a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was never\n // created for this id, and all stored snapshot ids are smaller than the requested one. The value that corresponds\n // to this id is the current one.\n // b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with the\n // requested id, and its value is the one to return.\n // c) More snapshots were created after the requested one, and the queried value was later modified. There will be\n // no entry for the requested id: the value that corresponds to it is that of the smallest snapshot id that is\n // larger than the requested one.\n //\n // In summary, we need to find an element in an array, returning the index of the smallest value that is larger if\n // it is not found, unless said value doesn't exist (e.g. when all values are smaller). Arrays.findUpperBound does\n // exactly this.\n\n uint256 index = snapshots.ids.findUpperBound(snapshotId);\n\n if (index == snapshots.ids.length) {\n return (false, 0);\n } else {\n return (true, snapshots.values[index]);\n }\n }\n\n function _updateAccountSnapshot(address account) private {\n _updateSnapshot(_accountBalanceSnapshots[account], balanceOf(account));\n }\n\n function _updateTotalSupplySnapshot() private {\n _updateSnapshot(_totalSupplySnapshots, totalSupply());\n }\n\n function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private {\n uint256 currentId = _getCurrentSnapshotId();\n if (_lastSnapshotId(snapshots.ids) < currentId) {\n snapshots.ids.push(currentId);\n snapshots.values.push(currentValue);\n }\n }\n\n function _lastSnapshotId(uint256[] storage ids) private view returns (uint256) {\n if (ids.length == 0) {\n return 0;\n } else {\n return ids[ids.length - 1];\n }\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[46] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Votes.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-ERC20PermitUpgradeable.sol\";\nimport \"../../../utils/math/MathUpgradeable.sol\";\nimport \"../../../governance/utils/IVotesUpgradeable.sol\";\nimport \"../../../utils/math/SafeCastUpgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's,\n * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1.\n *\n * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module.\n *\n * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either\n * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting\n * power can be queried through the public accessors {getVotes} and {getPastVotes}.\n *\n * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it\n * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.\n *\n * _Available since v4.2._\n */\nabstract contract ERC20VotesUpgradeable is Initializable, IVotesUpgradeable, ERC20PermitUpgradeable {\n function __ERC20Votes_init() internal onlyInitializing {\n }\n\n function __ERC20Votes_init_unchained() internal onlyInitializing {\n }\n struct Checkpoint {\n uint32 fromBlock;\n uint224 votes;\n }\n\n bytes32 private constant _DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n mapping(address => address) private _delegates;\n mapping(address => Checkpoint[]) private _checkpoints;\n Checkpoint[] private _totalSupplyCheckpoints;\n\n /**\n * @dev Get the `pos`-th checkpoint for `account`.\n */\n function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) {\n return _checkpoints[account][pos];\n }\n\n /**\n * @dev Get number of checkpoints for `account`.\n */\n function numCheckpoints(address account) public view virtual returns (uint32) {\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\n }\n\n /**\n * @dev Get the address `account` is currently delegating to.\n */\n function delegates(address account) public view virtual override returns (address) {\n return _delegates[account];\n }\n\n /**\n * @dev Gets the current votes balance for `account`\n */\n function getVotes(address account) public view virtual override returns (uint256) {\n uint256 pos = _checkpoints[account].length;\n return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;\n }\n\n /**\n * @dev Retrieve the number of votes for `account` at the end of `blockNumber`.\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_checkpoints[account], blockNumber);\n }\n\n /**\n * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances.\n * It is but NOT the sum of all the delegated votes!\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastTotalSupply(uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber);\n }\n\n /**\n * @dev Lookup a value in a list of (sorted) checkpoints.\n */\n function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) {\n // We run a binary search to look for the earliest checkpoint taken after `blockNumber`.\n //\n // During the loop, the index of the wanted checkpoint remains in the range [low-1, high).\n // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.\n // - If the middle checkpoint is after `blockNumber`, we look in [low, mid)\n // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high)\n // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not\n // out of bounds (in which case we're looking too far in the past and the result is 0).\n // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is\n // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out\n // the same.\n uint256 high = ckpts.length;\n uint256 low = 0;\n while (low < high) {\n uint256 mid = MathUpgradeable.average(low, high);\n if (ckpts[mid].fromBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n return high == 0 ? 0 : ckpts[high - 1].votes;\n }\n\n /**\n * @dev Delegate votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) public virtual override {\n _delegate(_msgSender(), delegatee);\n }\n\n /**\n * @dev Delegates votes from signer to `delegatee`\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= expiry, \"ERC20Votes: signature expired\");\n address signer = ECDSAUpgradeable.recover(\n _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))),\n v,\n r,\n s\n );\n require(nonce == _useNonce(signer), \"ERC20Votes: invalid nonce\");\n _delegate(signer, delegatee);\n }\n\n /**\n * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).\n */\n function _maxSupply() internal view virtual returns (uint224) {\n return type(uint224).max;\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been increased.\n */\n function _mint(address account, uint256 amount) internal virtual override {\n super._mint(account, amount);\n require(totalSupply() <= _maxSupply(), \"ERC20Votes: total supply risks overflowing votes\");\n\n _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been decreased.\n */\n function _burn(address account, uint256 amount) internal virtual override {\n super._burn(account, amount);\n\n _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);\n }\n\n /**\n * @dev Move voting power when tokens are transferred.\n *\n * Emits a {DelegateVotesChanged} event.\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._afterTokenTransfer(from, to, amount);\n\n _moveVotingPower(delegates(from), delegates(to), amount);\n }\n\n /**\n * @dev Change delegation for `delegator` to `delegatee`.\n *\n * Emits events {DelegateChanged} and {DelegateVotesChanged}.\n */\n function _delegate(address delegator, address delegatee) internal virtual {\n address currentDelegate = delegates(delegator);\n uint256 delegatorBalance = balanceOf(delegator);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _moveVotingPower(\n address src,\n address dst,\n uint256 amount\n ) private {\n if (src != dst && amount > 0) {\n if (src != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);\n emit DelegateVotesChanged(src, oldWeight, newWeight);\n }\n\n if (dst != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\n }\n }\n }\n\n function _writeCheckpoint(\n Checkpoint[] storage ckpts,\n function(uint256, uint256) view returns (uint256) op,\n uint256 delta\n ) private returns (uint256 oldWeight, uint256 newWeight) {\n uint256 pos = ckpts.length;\n oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes;\n newWeight = op(oldWeight, delta);\n\n if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {\n ckpts[pos - 1].votes = SafeCastUpgradeable.toUint224(newWeight);\n } else {\n ckpts.push(Checkpoint({fromBlock: SafeCastUpgradeable.toUint32(block.number), votes: SafeCastUpgradeable.toUint224(newWeight)}));\n }\n }\n\n function _add(uint256 a, uint256 b) private pure returns (uint256) {\n return a + b;\n }\n\n function _subtract(uint256 a, uint256 b) private pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[47] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20WrapperUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/ERC20Wrapper.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../utils/SafeERC20Upgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Extension of the ERC20 token contract to support token wrapping.\n *\n * Users can deposit and withdraw \"underlying tokens\" and receive a matching number of \"wrapped tokens\". This is useful\n * in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the\n * wrapping of an existing \"basic\" ERC20 into a governance token.\n *\n * _Available since v4.2._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20WrapperUpgradeable is Initializable, ERC20Upgradeable {\n IERC20Upgradeable public underlying;\n\n function __ERC20Wrapper_init(IERC20Upgradeable underlyingToken) internal onlyInitializing {\n __ERC20Wrapper_init_unchained(underlyingToken);\n }\n\n function __ERC20Wrapper_init_unchained(IERC20Upgradeable underlyingToken) internal onlyInitializing {\n underlying = underlyingToken;\n }\n\n /**\n * @dev See {ERC20-decimals}.\n */\n function decimals() public view virtual override returns (uint8) {\n try IERC20MetadataUpgradeable(address(underlying)).decimals() returns (uint8 value) {\n return value;\n } catch {\n return super.decimals();\n }\n }\n\n /**\n * @dev Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.\n */\n function depositFor(address account, uint256 amount) public virtual returns (bool) {\n SafeERC20Upgradeable.safeTransferFrom(underlying, _msgSender(), address(this), amount);\n _mint(account, amount);\n return true;\n }\n\n /**\n * @dev Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.\n */\n function withdrawTo(address account, uint256 amount) public virtual returns (bool) {\n _burn(_msgSender(), amount);\n SafeERC20Upgradeable.safeTransfer(underlying, account, amount);\n return true;\n }\n\n /**\n * @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal\n * function that can be exposed with access control if desired.\n */\n function _recover(address account) internal virtual returns (uint256) {\n uint256 value = underlying.balanceOf(address(this)) - totalSupply();\n _mint(account, value);\n return value;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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 function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\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 /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ArraysUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Arrays.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\n\n/**\n * @dev Collection of functions related to array types.\n */\nlibrary ArraysUpgradeable {\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 * `array` is expected to be sorted in ascending order, and to contain no\n * repeated elements.\n */\n function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {\n if (array.length == 0) {\n return 0;\n }\n\n uint256 low = 0;\n uint256 high = array.length;\n\n while (low < high) {\n uint256 mid = MathUpgradeable.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 down (it does integer division with truncation).\n if (array[mid] > 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 && array[low - 1] == element) {\n return low - 1;\n } else {\n return low;\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary CountersUpgradeable {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSAUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 52\n */\nabstract contract EIP712Upgradeable is Initializable {\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n __EIP712_init_unchained(name, version);\n }\n\n function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev The hash of the name parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712NameHash() internal virtual view returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /**\n * @dev The hash of the version parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712VersionHash() internal virtual view returns (bytes32) {\n return _HASHED_VERSION;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\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 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 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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / 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 prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\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 works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\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^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`.\n // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.\n // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.\n // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a\n // good first aproximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1;\n uint256 x = a;\n if (x >> 128 > 0) {\n x >>= 128;\n result <<= 64;\n }\n if (x >> 64 > 0) {\n x >>= 64;\n result <<= 32;\n }\n if (x >> 32 > 0) {\n x >>= 32;\n result <<= 16;\n }\n if (x >> 16 > 0) {\n x >>= 16;\n result <<= 8;\n }\n if (x >> 8 > 0) {\n x >>= 8;\n result <<= 4;\n }\n if (x >> 4 > 0) {\n x >>= 4;\n result <<= 2;\n }\n if (x >> 2 > 0) {\n result <<= 1;\n }\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n uint256 result = sqrt(a);\n if (rounding == Rounding.Up && result * result < a) {\n result += 1;\n }\n return result;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX 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 *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\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 * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\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 * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\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 * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\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 * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\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 * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\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 * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\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 * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\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 * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\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 * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\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 * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\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 * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\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 * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\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 * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\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 * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\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 * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\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 * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\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 * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\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 * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\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 * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\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 * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\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 * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\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 * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\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 * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\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 * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\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 * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\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 * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\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 * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\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 * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\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 * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\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 * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\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 * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\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 * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\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 * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248) {\n require(value >= type(int248).min && value <= type(int248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return int248(value);\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 * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240) {\n require(value >= type(int240).min && value <= type(int240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return int240(value);\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 * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232) {\n require(value >= type(int232).min && value <= type(int232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return int232(value);\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 * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224) {\n require(value >= type(int224).min && value <= type(int224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return int224(value);\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 * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216) {\n require(value >= type(int216).min && value <= type(int216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return int216(value);\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 * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208) {\n require(value >= type(int208).min && value <= type(int208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return int208(value);\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 * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200) {\n require(value >= type(int200).min && value <= type(int200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return int200(value);\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 * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192) {\n require(value >= type(int192).min && value <= type(int192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return int192(value);\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 * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184) {\n require(value >= type(int184).min && value <= type(int184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return int184(value);\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 * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176) {\n require(value >= type(int176).min && value <= type(int176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return int176(value);\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 * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168) {\n require(value >= type(int168).min && value <= type(int168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return int168(value);\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 * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160) {\n require(value >= type(int160).min && value <= type(int160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return int160(value);\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 * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152) {\n require(value >= type(int152).min && value <= type(int152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return int152(value);\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 * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144) {\n require(value >= type(int144).min && value <= type(int144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return int144(value);\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 * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136) {\n require(value >= type(int136).min && value <= type(int136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return int136(value);\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 * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128) {\n require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return int128(value);\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 * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120) {\n require(value >= type(int120).min && value <= type(int120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return int120(value);\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 * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112) {\n require(value >= type(int112).min && value <= type(int112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return int112(value);\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 * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104) {\n require(value >= type(int104).min && value <= type(int104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return int104(value);\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 * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96) {\n require(value >= type(int96).min && value <= type(int96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return int96(value);\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 * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88) {\n require(value >= type(int88).min && value <= type(int88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return int88(value);\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 * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80) {\n require(value >= type(int80).min && value <= type(int80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return int80(value);\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 * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72) {\n require(value >= type(int72).min && value <= type(int72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return int72(value);\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 * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64) {\n require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return int64(value);\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 * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56) {\n require(value >= type(int56).min && value <= type(int56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return int56(value);\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 * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48) {\n require(value >= type(int48).min && value <= type(int48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return int48(value);\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 * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40) {\n require(value >= type(int40).min && value <= type(int40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return int40(value);\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 * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32) {\n require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return int32(value);\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 * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24) {\n require(value >= type(int24).min && value <= type(int24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return int24(value);\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 * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16) {\n require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return int16(value);\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 * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8) {\n require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return int8(value);\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 * _Available since v3.0._\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 require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@openzeppelin/contracts/governance/utils/IVotes.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotes {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/ERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\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 /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\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" + }, + "@openzeppelin/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 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 *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165Storage.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Storage.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ERC165.sol\";\n\n/**\n * @dev Storage based implementation of the {IERC165} interface.\n *\n * Contracts may inherit from this and call {_registerInterface} to declare\n * their support of an interface.\n */\nabstract contract ERC165Storage is ERC165 {\n /**\n * @dev Mapping of interface ids to whether or not it's supported.\n */\n mapping(bytes4 => bool) private _supportedInterfaces;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return super.supportsInterface(interfaceId) || _supportedInterfaces[interfaceId];\n }\n\n /**\n * @dev Registers the contract as an implementer of the interface defined by\n * `interfaceId`. Support of the actual ERC165 interface is automatic and\n * registering its interface id is not required.\n *\n * See {IERC165-supportsInterface}.\n *\n * Requirements:\n *\n * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).\n */\n function _registerInterface(bytes4 interfaceId) internal virtual {\n require(interfaceId != 0xffffffff, \"ERC165: invalid interface id\");\n _supportedInterfaces[interfaceId] = true;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\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[EIP 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" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@prb/math/src/Common.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\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 works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\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^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n" + }, + "@prb/math/src/sd1x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n" + }, + "@prb/math/src/sd1x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint64 constant uUNIT = 1e18;\n" + }, + "@prb/math/src/sd1x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n" + }, + "@prb/math/src/sd1x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n" + }, + "@prb/math/src/sd59x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n" + }, + "@prb/math/src/sd59x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev Any value less than this returns 0 in {exp}.\nint256 constant uEXP_MIN_THRESHOLD = -41_446531673892822322;\nSD59x18 constant EXP_MIN_THRESHOLD = SD59x18.wrap(uEXP_MIN_THRESHOLD);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Any value less than this returns 0 in {exp2}.\nint256 constant uEXP2_MIN_THRESHOLD = -59_794705707972522261;\nSD59x18 constant EXP2_MIN_THRESHOLD = SD59x18.wrap(uEXP2_MIN_THRESHOLD);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n" + }, + "@prb/math/src/sd59x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n" + }, + "@prb/math/src/sd59x18/Helpers.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" + }, + "@prb/math/src/sd59x18/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uEXP_MIN_THRESHOLD,\n uEXP2_MIN_THRESHOLD,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // Any input less than the threshold returns zero.\n // This check also prevents an overflow for very small numbers.\n if (xInt < uEXP_MIN_THRESHOLD) {\n return ZERO;\n }\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than the threshold is truncated to zero.\n if (xInt < uEXP2_MIN_THRESHOLD) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n" + }, + "@prb/math/src/sd59x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n" + }, + "@prb/math/src/UD2x18.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗╚════██╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║ █████╔╝ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══╝ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud2x18/Casting.sol\";\nimport \"./ud2x18/Constants.sol\";\nimport \"./ud2x18/Errors.sol\";\nimport \"./ud2x18/ValueType.sol\";\n" + }, + "@prb/math/src/ud2x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n" + }, + "@prb/math/src/ud2x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\nuint64 constant uUNIT = 1e18;\n" + }, + "@prb/math/src/ud2x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n" + }, + "@prb/math/src/ud2x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n" + }, + "@prb/math/src/UD60x18.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n" + }, + "@prb/math/src/ud60x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n" + }, + "@prb/math/src/ud60x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n" + }, + "@prb/math/src/ud60x18/Conversions.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n" + }, + "@prb/math/src/ud60x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n" + }, + "@prb/math/src/ud60x18/Helpers.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" + }, + "@prb/math/src/ud60x18/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n///\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n" + }, + "@prb/math/src/ud60x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n" + }, + "contracts/DecentSablierStreamManagement.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.28;\n\nimport {Enum} from \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport {IAvatar} from \"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\";\nimport {ISablierV2Lockup} from \"./interfaces/sablier/full/ISablierV2Lockup.sol\";\nimport {Lockup} from \"./interfaces/sablier/full/types/DataTypes.sol\";\n\ncontract DecentSablierStreamManagement {\n string public constant NAME = \"DecentSablierStreamManagement\";\n\n function withdrawMaxFromStream(\n ISablierV2Lockup sablier,\n address recipientHatAccount,\n uint256 streamId,\n address to\n ) public {\n // Check if there are funds to withdraw\n uint128 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\n if (withdrawableAmount == 0) {\n return;\n }\n\n // Proxy the Sablier withdrawMax call through IAvatar (Safe)\n IAvatar(msg.sender).execTransactionFromModule(\n recipientHatAccount,\n 0,\n abi.encodeWithSignature(\n \"execute(address,uint256,bytes,uint8)\",\n address(sablier),\n 0,\n abi.encodeWithSignature(\n \"withdrawMax(uint256,address)\",\n streamId,\n to\n ),\n 0\n ),\n Enum.Operation.Call\n );\n }\n\n function cancelStream(ISablierV2Lockup sablier, uint256 streamId) public {\n // Check if the stream can be cancelled\n Lockup.Status streamStatus = sablier.statusOf(streamId);\n if (\n streamStatus != Lockup.Status.PENDING &&\n streamStatus != Lockup.Status.STREAMING\n ) {\n return;\n }\n\n IAvatar(msg.sender).execTransactionFromModule(\n address(sablier),\n 0,\n abi.encodeWithSignature(\"cancel(uint256)\", streamId),\n Enum.Operation.Call\n );\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol';\n" + }, + "contracts/interfaces/hats/IHats.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0\n// Copyright (C) 2023 Haberdasher Labs\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see .\n\npragma solidity >=0.8.13;\n\ninterface IHats {\n function mintTopHat(\n address _target,\n string memory _details,\n string memory _imageURI\n ) external returns (uint256 topHatId);\n\n function createHat(\n uint256 _admin,\n string calldata _details,\n uint32 _maxSupply,\n address _eligibility,\n address _toggle,\n bool _mutable,\n string calldata _imageURI\n ) external returns (uint256 newHatId);\n\n function mintHat(\n uint256 _hatId,\n address _wearer\n ) external returns (bool success);\n\n function transferHat(uint256 _hatId, address _from, address _to) external;\n}\n" + }, + "contracts/interfaces/IERC6551Registry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IERC6551Registry {\n /**\n * @dev Creates a token bound account for a non-fungible token.\n *\n * If account has already been created, returns the account address without calling create2.\n *\n * Emits ERC6551AccountCreated event.\n *\n * @return account The address of the token bound account\n */\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address account);\n}\n" + }, + "contracts/interfaces/sablier/full/IAdminable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\n/// @title IAdminable\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\n/// in the constructor.\ninterface IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin is transferred.\n /// @param oldAdmin The address of the old admin.\n /// @param newAdmin The address of the new admin.\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice The address of the admin account or contract.\n function admin() external view returns (address);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Transfers the contract admin to a new address.\n ///\n /// @dev Notes:\n /// - Does not revert if the admin is the same.\n /// - This function can potentially leave the contract without an admin, thereby removing any\n /// functionality that is only available to the admin.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newAdmin The address of the new admin.\n function transferAdmin(address newAdmin) external;\n}\n" + }, + "contracts/interfaces/sablier/full/IERC4096.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4906.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\n/// @title ERC-721 Metadata Update Extension\ninterface IERC4906 is IERC165, IERC721 {\n /// @dev This event emits when the metadata of a token is changed.\n /// So that the third-party platforms such as NFT market could\n /// timely update the images and related attributes of the NFT.\n event MetadataUpdate(uint256 _tokenId);\n\n /// @dev This event emits when the metadata of a range of tokens is changed.\n /// So that the third-party platforms such as NFT market could\n /// timely update the images and related attributes of the NFTs.\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n}\n" + }, + "contracts/interfaces/sablier/full/ISablierV2Lockup.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC4906} from \"./IERC4096.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IERC721Metadata} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\nimport {UD60x18} from \"@prb/math/src/UD60x18.sol\";\n\nimport {Lockup} from \"./types/DataTypes.sol\";\nimport {IAdminable} from \"./IAdminable.sol\";\nimport {ISablierV2NFTDescriptor} from \"./ISablierV2NFTDescriptor.sol\";\n\n/// @title ISablierV2Lockup\n/// @notice Common logic between all Sablier V2 Lockup contracts.\ninterface ISablierV2Lockup is\n IAdminable, // 0 inherited components\n IERC4906, // 2 inherited components\n IERC721Metadata // 2 inherited components\n{\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin allows a new recipient contract to hook to Sablier.\n /// @param admin The address of the current contract admin.\n /// @param recipient The address of the recipient contract put on the allowlist.\n event AllowToHook(address indexed admin, address recipient);\n\n /// @notice Emitted when a stream is canceled.\n /// @param streamId The ID of the stream.\n /// @param sender The address of the stream's sender.\n /// @param recipient The address of the stream's recipient.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\n /// decimals.\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\n /// asset's decimals.\n event CancelLockupStream(\n uint256 streamId,\n address indexed sender,\n address indexed recipient,\n IERC20 indexed asset,\n uint128 senderAmount,\n uint128 recipientAmount\n );\n\n /// @notice Emitted when a sender gives up the right to cancel a stream.\n /// @param streamId The ID of the stream.\n event RenounceLockupStream(uint256 indexed streamId);\n\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\n /// @param admin The address of the current contract admin.\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n event SetNFTDescriptor(\n address indexed admin,\n ISablierV2NFTDescriptor oldNFTDescriptor,\n ISablierV2NFTDescriptor newNFTDescriptor\n );\n\n /// @notice Emitted when assets are withdrawn from a stream.\n /// @param streamId The ID of the stream.\n /// @param to The address that has received the withdrawn assets.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\n event WithdrawFromLockupStream(\n uint256 indexed streamId,\n address indexed to,\n IERC20 indexed asset,\n uint128 amount\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the address of the ERC-20 asset to be distributed.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\n\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getDepositedAmount(\n uint256 streamId\n ) external view returns (uint128 depositedAmount);\n\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getEndTime(\n uint256 streamId\n ) external view returns (uint40 endTime);\n\n /// @notice Retrieves the stream's recipient.\n /// @dev Reverts if the NFT has been burned.\n /// @param streamId The stream ID for the query.\n function getRecipient(\n uint256 streamId\n ) external view returns (address recipient);\n\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\n /// decimals. This amount is always zero unless the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getRefundedAmount(\n uint256 streamId\n ) external view returns (uint128 refundedAmount);\n\n /// @notice Retrieves the stream's sender.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getSender(uint256 streamId) external view returns (address sender);\n\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getStartTime(\n uint256 streamId\n ) external view returns (uint40 startTime);\n\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getWithdrawnAmount(\n uint256 streamId\n ) external view returns (uint128 withdrawnAmount);\n\n /// @notice Retrieves a flag indicating whether the provided address is a contract allowed to hook to Sablier\n /// when a stream is canceled or when assets are withdrawn.\n /// @dev See {ISablierLockupRecipient} for more information.\n function isAllowedToHook(\n address recipient\n ) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\n /// flag is always `false`.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isCancelable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isCold(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isDepleted(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream exists.\n /// @dev Does not revert if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isStream(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isTransferable(\n uint256 streamId\n ) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isWarm(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves the maximum broker fee that can be charged by the broker, denoted as a fixed-point\n /// number where 1e18 is 100%.\n /// @dev This value is hard coded as a constant.\n function MAX_BROKER_FEE() external view returns (UD60x18);\n\n /// @notice Counter for stream IDs, used in the create functions.\n function nextStreamId() external view returns (uint256);\n\n /// @notice Contract that generates the non-fungible token URI.\n function nftDescriptor() external view returns (ISablierV2NFTDescriptor);\n\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\n /// of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function refundableAmountOf(\n uint256 streamId\n ) external view returns (uint128 refundableAmount);\n\n /// @notice Retrieves the stream's status.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function statusOf(\n uint256 streamId\n ) external view returns (Lockup.Status status);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n ///\n /// Notes:\n /// - Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\n /// to the total amount withdrawn.\n ///\n /// @param streamId The stream ID for the query.\n function streamedAmountOf(\n uint256 streamId\n ) external view returns (uint128 streamedAmount);\n\n /// @notice Retrieves a flag indicating whether the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function wasCanceled(uint256 streamId) external view returns (bool result);\n\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\n /// decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function withdrawableAmountOf(\n uint256 streamId\n ) external view returns (uint128 withdrawableAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Allows a recipient contract to hook to Sablier when a stream is canceled or when assets are withdrawn.\n /// Useful for implementing contracts that hold streams on behalf of users, such as vaults or staking contracts.\n ///\n /// @dev Emits an {AllowToHook} event.\n ///\n /// Notes:\n /// - Does not revert if the contract is already on the allowlist.\n /// - This is an irreversible operation. The contract cannot be removed from the allowlist.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n /// - `recipient` must have a non-zero code size.\n /// - `recipient` must implement {ISablierLockupRecipient}.\n ///\n /// @param recipient The address of the contract to allow for hooks.\n function allowToHook(address recipient) external;\n\n /// @notice Burns the NFT associated with the stream.\n ///\n /// @dev Emits a {Transfer} event.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a depleted stream.\n /// - The NFT must exist.\n /// - `msg.sender` must be either the NFT owner or an approved third party.\n ///\n /// @param streamId The ID of the stream NFT to burn.\n function burn(uint256 streamId) external;\n\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\n ///\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\n /// stream is marked as depleted.\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - The stream must be warm and cancelable.\n /// - `msg.sender` must be the stream's sender.\n ///\n /// @param streamId The ID of the stream to cancel.\n function cancel(uint256 streamId) external;\n\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\n ///\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - Refer to the notes in {cancel}.\n ///\n /// Requirements:\n /// - All requirements from {cancel} must be met for each stream.\n ///\n /// @param streamIds The IDs of the streams to cancel.\n function cancelMultiple(uint256[] calldata streamIds) external;\n\n /// @notice Removes the right of the stream's sender to cancel the stream.\n ///\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This is an irreversible operation.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a warm stream.\n /// - `msg.sender` must be the stream's sender.\n /// - The stream must be cancelable.\n ///\n /// @param streamId The ID of the stream to renounce.\n function renounce(uint256 streamId) external;\n\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\n ///\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\n ///\n /// Notes:\n /// - Does not revert if the NFT descriptor is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n function setNFTDescriptor(\n ISablierV2NFTDescriptor newNFTDescriptor\n ) external;\n\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of the stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must not reference a null or depleted stream.\n /// - `to` must not be the zero address.\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\n /// - `to` must be the recipient if `msg.sender` is not the stream's recipient or an approved third party.\n ///\n /// @param streamId The ID of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\n function withdraw(uint256 streamId, address to, uint128 amount) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - Refer to the requirements in {withdraw}.\n ///\n /// @param streamId The ID of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\n function withdrawMax(\n uint256 streamId,\n address to\n ) external returns (uint128 withdrawnAmount);\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\n /// NFT to `newRecipient`.\n ///\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\n ///\n /// Notes:\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - `msg.sender` must be the stream's recipient.\n /// - Refer to the requirements in {withdraw}.\n /// - Refer to the requirements in {IERC721.transferFrom}.\n ///\n /// @param streamId The ID of the stream NFT to transfer.\n /// @param newRecipient The address of the new owner of the stream NFT.\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\n function withdrawMaxAndTransfer(\n uint256 streamId,\n address newRecipient\n ) external returns (uint128 withdrawnAmount);\n\n /// @notice Withdraws assets from streams to the recipient of each stream.\n ///\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - There must be an equal number of `streamIds` and `amounts`.\n /// - Each stream ID in the array must not reference a null or depleted stream.\n /// - Each amount in the array must be greater than zero and must not exceed the withdrawable amount.\n ///\n /// @param streamIds The IDs of the streams to withdraw from.\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\n function withdrawMultiple(\n uint256[] calldata streamIds,\n uint128[] calldata amounts\n ) external;\n}\n" + }, + "contracts/interfaces/sablier/full/ISablierV2NFTDescriptor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC721Metadata} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\n/// @title ISablierV2NFTDescriptor\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\n/// @dev Inspired by Uniswap V3 Positions NFTs.\ninterface ISablierV2NFTDescriptor {\n /// @notice Produces the URI describing a particular stream NFT.\n /// @dev This is a data URI with the JSON contents directly inlined.\n /// @param sablier The address of the Sablier contract the stream was created in.\n /// @param streamId The ID of the stream for which to produce a description.\n /// @return uri The URI of the ERC721-compliant metadata.\n function tokenURI(\n IERC721Metadata sablier,\n uint256 streamId\n ) external view returns (string memory uri);\n}\n" + }, + "contracts/interfaces/sablier/full/types/DataTypes.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {UD2x18} from \"@prb/math/src/UD2x18.sol\";\nimport {UD60x18} from \"@prb/math/src/UD60x18.sol\";\n\n// DataTypes.sol\n//\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\n//\n// - Lockup\n// - LockupDynamic\n// - LockupLinear\n// - LockupTranched\n//\n// You will notice that some structs contain \"slot\" annotations - they are used to indicate the\n// storage layout of the struct. It is more gas efficient to group small data types together so\n// that they fit in a single 32-byte slot.\n\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\n/// @param account The address receiving the broker's fee.\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\nstruct Broker {\n address account;\n UD60x18 fee;\n}\n\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\nlibrary Lockup {\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the asset's\n /// decimals.\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in the same slot\n /// saves gas.\n /// @param deposited The initial amount deposited in the stream, net of broker fee.\n /// @param withdrawn The cumulative amount withdrawn from the stream.\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\n struct Amounts {\n // slot 0\n uint128 deposited;\n uint128 withdrawn;\n // slot 1\n uint128 refunded;\n }\n\n /// @notice Struct encapsulating (i) the deposit amount and (ii) the broker fee amount, both denoted in units of the\n /// asset's decimals.\n /// @param deposit The amount to deposit in the stream.\n /// @param brokerFee The broker fee amount.\n struct CreateAmounts {\n uint128 deposit;\n uint128 brokerFee;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING,\n STREAMING,\n SETTLED,\n CANCELED,\n DEPLETED\n }\n\n /// @notice A common data structure to be stored in all {SablierV2Lockup} models.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address distributing the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\nlibrary LockupDynamic {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param segments Segments with durations used to compose the dynamic distribution function. Timestamps are\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n SegmentWithDuration[] segments;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param segments Segments used to compose the dynamic distribution function.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n uint40 startTime;\n Segment[] segments;\n Broker broker;\n }\n\n /// @notice Segment struct used in the Lockup Dynamic stream.\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\n /// @param timestamp The Unix timestamp indicating the segment's end.\n struct Segment {\n // slot 0\n uint128 amount;\n UD2x18 exponent;\n uint40 timestamp;\n }\n\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDurations}.\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\n /// @param duration The time difference in seconds between the segment and the previous one.\n struct SegmentWithDuration {\n uint128 amount;\n UD2x18 exponent;\n uint40 duration;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the segments.\n struct StreamLD {\n address sender;\n address recipient;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n Segment[] segments;\n }\n\n /// @notice Struct encapsulating the LockupDynamic timestamps.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 end;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\nlibrary LockupLinear {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param durations Struct encapsulating (i) cliff period duration and (ii) total stream duration, both in seconds.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Durations durations;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param timestamps Struct encapsulating (i) the stream's start time, (ii) cliff time, and (iii) end time, all as\n /// Unix timestamps.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the cliff duration and the total duration.\n /// @param cliff The cliff duration in seconds.\n /// @param total The total duration in seconds.\n struct Durations {\n uint40 cliff;\n uint40 total;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the cliff time.\n struct StreamLL {\n address sender;\n address recipient;\n uint40 startTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n uint40 endTime;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n uint40 cliffTime;\n }\n\n /// @notice Struct encapsulating the LockupLinear timestamps.\n /// @param start The Unix timestamp for the stream's start.\n /// @param cliff The Unix timestamp for the cliff period's end. A value of zero means there is no cliff.\n /// @param end The Unix timestamp for the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupTranched}.\nlibrary LockupTranched {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param tranches Tranches with durations used to compose the tranched distribution function. Timestamps are\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n TrancheWithDuration[] tranches;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param tranches Tranches used to compose the tranched distribution function.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n uint40 startTime;\n Tranche[] tranches;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the tranches.\n struct StreamLT {\n address sender;\n address recipient;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n Tranche[] tranches;\n }\n\n /// @notice Struct encapsulating the LockupTranched timestamps.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 end;\n }\n\n /// @notice Tranche struct used in the Lockup Tranched stream.\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\n /// @param timestamp The Unix timestamp indicating the tranche's end.\n struct Tranche {\n // slot 0\n uint128 amount;\n uint40 timestamp;\n }\n\n /// @notice Tranche struct used at runtime in {SablierV2LockupTranched.createWithDurations}.\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\n /// @param duration The time difference in seconds between the tranche and the previous one.\n struct TrancheWithDuration {\n uint128 amount;\n uint40 duration;\n }\n}\n" + }, + "contracts/interfaces/sablier/ISablierV2LockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {LockupLinear} from \"./LockupLinear.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface ISablierV2LockupLinear {\n function createWithTimestamps(\n LockupLinear.CreateWithTimestamps calldata params\n ) external returns (uint256 streamId);\n}\n" + }, + "contracts/interfaces/sablier/LockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nlibrary LockupLinear {\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n struct Broker {\n address account;\n uint256 fee;\n }\n}\n" + }, + "contracts/mocks/ERC6551Registry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IERC6551Registry {\n /**\n * @dev The registry MUST emit the ERC6551AccountCreated event upon successful account creation.\n */\n event ERC6551AccountCreated(\n address account,\n address indexed implementation,\n bytes32 salt,\n uint256 chainId,\n address indexed tokenContract,\n uint256 indexed tokenId\n );\n\n /**\n * @dev The registry MUST revert with AccountCreationFailed error if the create2 operation fails.\n */\n error AccountCreationFailed();\n\n /**\n * @dev Creates a token bound account for a non-fungible token.\n *\n * If account has already been created, returns the account address without calling create2.\n *\n * Emits ERC6551AccountCreated event.\n *\n * @return account The address of the token bound account\n */\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address account);\n\n /**\n * @dev Returns the computed token bound account address for a non-fungible token.\n *\n * @return account The address of the token bound account\n */\n function account(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external view returns (address account);\n}\n\ncontract ERC6551Registry is IERC6551Registry {\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address) {\n assembly {\n // Memory Layout:\n // ----\n // 0x00 0xff (1 byte)\n // 0x01 registry (address) (20 bytes)\n // 0x15 salt (bytes32) (32 bytes)\n // 0x35 Bytecode Hash (bytes32) (32 bytes)\n // ----\n // 0x55 ERC-1167 Constructor + Header (20 bytes)\n // 0x69 implementation (address) (20 bytes)\n // 0x5D ERC-1167 Footer (15 bytes)\n // 0x8C salt (uint256) (32 bytes)\n // 0xAC chainId (uint256) (32 bytes)\n // 0xCC tokenContract (address) (32 bytes)\n // 0xEC tokenId (uint256) (32 bytes)\n\n // Silence unused variable warnings\n pop(chainId)\n\n // Copy bytecode + constant data to memory\n calldatacopy(0x8c, 0x24, 0x80) // salt, chainId, tokenContract, tokenId\n mstore(0x6c, 0x5af43d82803e903d91602b57fd5bf3) // ERC-1167 footer\n mstore(0x5d, implementation) // implementation\n mstore(0x49, 0x3d60ad80600a3d3981f3363d3d373d3d3d363d73) // ERC-1167 constructor + header\n\n // Copy create2 computation data to memory\n mstore8(0x00, 0xff) // 0xFF\n mstore(0x35, keccak256(0x55, 0xb7)) // keccak256(bytecode)\n mstore(0x01, shl(96, address())) // registry address\n mstore(0x15, salt) // salt\n\n // Compute account address\n let computed := keccak256(0x00, 0x55)\n\n // If the account has not yet been deployed\n if iszero(extcodesize(computed)) {\n // Deploy account contract\n let deployed := create2(0, 0x55, 0xb7, salt)\n\n // Revert if the deployment fails\n if iszero(deployed) {\n mstore(0x00, 0x20188a59) // `AccountCreationFailed()`\n revert(0x1c, 0x04)\n }\n\n // Store account address in memory before salt and chainId\n mstore(0x6c, deployed)\n\n // Emit the ERC6551AccountCreated event\n log4(\n 0x6c,\n 0x60,\n // `ERC6551AccountCreated(address,address,bytes32,uint256,address,uint256)`\n 0x79f19b3655ee38b1ce526556b7731a20c8f218fbda4a3990b6cc4172fdf88722,\n implementation,\n tokenContract,\n tokenId\n )\n\n // Return the account address\n return(0x6c, 0x20)\n }\n\n // Otherwise, return the computed account address\n mstore(0x00, shr(96, shl(96, computed)))\n return(0x00, 0x20)\n }\n }\n\n function account(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external view returns (address) {\n assembly {\n // Silence unused variable warnings\n pop(chainId)\n pop(tokenContract)\n pop(tokenId)\n\n // Copy bytecode + constant data to memory\n calldatacopy(0x8c, 0x24, 0x80) // salt, chainId, tokenContract, tokenId\n mstore(0x6c, 0x5af43d82803e903d91602b57fd5bf3) // ERC-1167 footer\n mstore(0x5d, implementation) // implementation\n mstore(0x49, 0x3d60ad80600a3d3981f3363d3d373d3d3d363d73) // ERC-1167 constructor + header\n\n // Copy create2 computation data to memory\n mstore8(0x00, 0xff) // 0xFF\n mstore(0x35, keccak256(0x55, 0xb7)) // keccak256(bytecode)\n mstore(0x01, shl(96, address())) // registry address\n mstore(0x15, salt) // salt\n\n // Store computed account address in memory\n mstore(0x00, shr(96, shl(96, keccak256(0x00, 0x55))))\n\n // Return computed account address\n return(0x00, 0x20)\n }\n }\n}\n" + }, + "contracts/mocks/MockContract.sol": { + "content": "//SPDX-License-Identifier: Unlicense\n\npragma solidity ^0.8.19;\n\n/**\n * Mock contract for testing\n */\ncontract MockContract {\n event DidSomething(string message);\n\n error Reverting();\n\n function doSomething() public {\n doSomethingWithParam(\"doSomething()\");\n }\n\n function doSomethingWithParam(string memory _message) public {\n emit DidSomething(_message);\n }\n\n function returnSomething(string memory _s)\n external\n pure\n returns (string memory)\n {\n return _s;\n }\n\n function revertSomething() external pure {\n revert Reverting();\n }\n}\n" + }, + "contracts/mocks/MockLockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nlibrary MockLockupLinear {\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n struct Broker {\n address account;\n uint256 fee;\n }\n\n struct Stream {\n address sender;\n uint40 startTime;\n uint40 endTime;\n uint40 cliffTime;\n bool cancelable;\n bool wasCanceled;\n address asset;\n bool transferable;\n uint128 totalAmount;\n address recipient;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING,\n STREAMING,\n SETTLED,\n CANCELED,\n DEPLETED\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/mainnet/DecentSablierStreamManagement.json b/deployments/mainnet/DecentSablierStreamManagement.json new file mode 100644 index 00000000..19664031 --- /dev/null +++ b/deployments/mainnet/DecentSablierStreamManagement.json @@ -0,0 +1,100 @@ +{ + "address": "0x84D96C7cD9F1Ea7da6d37054b0A6762be949df2B", + "abi": [ + { + "inputs": [], + "name": "NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ISablierV2Lockup", + "name": "sablier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + } + ], + "name": "cancelStream", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ISablierV2Lockup", + "name": "sablier", + "type": "address" + }, + { + "internalType": "address", + "name": "recipientHatAccount", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "withdrawMaxFromStream", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x1b8f61e0172a4044a4021ccd9ce6fd30095c568778c829d2d16959fd894cf7aa", + "receipt": { + "to": null, + "from": "0xb5Ca125166C1987A35EDD550E16846Fa1e1D9bB3", + "contractAddress": "0x84D96C7cD9F1Ea7da6d37054b0A6762be949df2B", + "transactionIndex": 94, + "gasUsed": "384441", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xdde1b87de37ca61887609fd8695e07b689dfd85acc88755aca2b61aeae22ded2", + "transactionHash": "0x1b8f61e0172a4044a4021ccd9ce6fd30095c568778c829d2d16959fd894cf7aa", + "logs": [], + "blockNumber": 20936434, + "cumulativeGasUsed": "8659131", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4511b61209438ca20d2458493e70bb24", + "metadata": "{\"compiler\":{\"version\":\"0.8.28+commit.7893614a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"NAME\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISablierV2Lockup\",\"name\":\"sablier\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"streamId\",\"type\":\"uint256\"}],\"name\":\"cancelStream\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISablierV2Lockup\",\"name\":\"sablier\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipientHatAccount\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"streamId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"withdrawMaxFromStream\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/DecentSablierStreamManagement.sol\":\"DecentSablierStreamManagement\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only\\npragma solidity >=0.7.0 <0.9.0;\\n\\n/// @title Enum - Collection of enums\\n/// @author Richard Meissner - \\ncontract Enum {\\n enum Operation {Call, DelegateCall}\\n}\\n\",\"keccak256\":\"0x473e45b1a5cc47be494b0e123c9127f0c11c1e0992a321ae5a644c0bfdb2c14f\",\"license\":\"LGPL-3.0-only\"},\"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only\\n\\n/// @title Zodiac Avatar - A contract that manages modules that can execute transactions via this contract.\\npragma solidity >=0.7.0 <0.9.0;\\n\\nimport \\\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\\\";\\n\\ninterface IAvatar {\\n event EnabledModule(address module);\\n event DisabledModule(address module);\\n event ExecutionFromModuleSuccess(address indexed module);\\n event ExecutionFromModuleFailure(address indexed module);\\n\\n /// @dev Enables a module on the avatar.\\n /// @notice Can only be called by the avatar.\\n /// @notice Modules should be stored as a linked list.\\n /// @notice Must emit EnabledModule(address module) if successful.\\n /// @param module Module to be enabled.\\n function enableModule(address module) external;\\n\\n /// @dev Disables a module on the avatar.\\n /// @notice Can only be called by the avatar.\\n /// @notice Must emit DisabledModule(address module) if successful.\\n /// @param prevModule Address that pointed to the module to be removed in the linked list\\n /// @param module Module to be removed.\\n function disableModule(address prevModule, address module) external;\\n\\n /// @dev Allows a Module to execute a transaction.\\n /// @notice Can only be called by an enabled module.\\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\\n function execTransactionFromModule(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation\\n ) external returns (bool success);\\n\\n /// @dev Allows a Module to execute a transaction and return data\\n /// @notice Can only be called by an enabled module.\\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\\n function execTransactionFromModuleReturnData(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation\\n ) external returns (bool success, bytes memory returnData);\\n\\n /// @dev Returns if an module is enabled\\n /// @return True if the module is enabled\\n function isModuleEnabled(address module) external view returns (bool);\\n\\n /// @dev Returns array of modules.\\n /// @param start Start of the page.\\n /// @param pageSize Maximum number of modules that should be returned.\\n /// @return array Array of modules.\\n /// @return next Start of the next page.\\n function getModulesPaginated(address start, uint256 pageSize)\\n external\\n view\\n returns (address[] memory array, address next);\\n}\\n\",\"keccak256\":\"0xcd5508ffe596eef8fbccfd5fc4f10a34397773547ce64e212d48b5212865ec1f\",\"license\":\"LGPL-3.0-only\"},\"@openzeppelin/contracts/interfaces/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/introspection/IERC165.sol\\\";\\n\",\"keccak256\":\"0xd04b0f06e0666f29cf7cccc82894de541e19bb30a765b107b1e40bb7fe5f7d7a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xed6a749c5373af398105ce6ee3ac4763aa450ea7285d268c85d9eeca809cdb1f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Metadata is IERC721 {\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x75b829ff2f26c14355d1cba20e16fe7b29ca58eb5fef665ede48bc0f9c6c74b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\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[EIP 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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@prb/math/src/Common.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n// Common.sol\\n//\\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\\n// always operate with SD59x18 and UD60x18 numbers.\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CUSTOM ERRORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\\n\\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\\n\\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\\nerror PRBMath_MulDivSigned_InputTooSmall();\\n\\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CONSTANTS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @dev The maximum value a uint128 number can have.\\nuint128 constant MAX_UINT128 = type(uint128).max;\\n\\n/// @dev The maximum value a uint40 number can have.\\nuint40 constant MAX_UINT40 = type(uint40).max;\\n\\n/// @dev The unit number, which the decimal precision of the fixed-point types.\\nuint256 constant UNIT = 1e18;\\n\\n/// @dev The unit number inverted mod 2^256.\\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\\n\\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\\n/// bit in the binary representation of `UNIT`.\\nuint256 constant UNIT_LPOTD = 262144;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method.\\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(uint256 x) pure returns (uint256 result) {\\n unchecked {\\n // Start from 0.5 in the 192.64-bit fixed-point format.\\n result = 0x800000000000000000000000000000000000000000000000;\\n\\n // The following logic multiplies the result by $\\\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\\n //\\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\\n // we know that `x & 0xFF` is also 1.\\n if (x & 0xFF00000000000000 > 0) {\\n if (x & 0x8000000000000000 > 0) {\\n result = (result * 0x16A09E667F3BCC909) >> 64;\\n }\\n if (x & 0x4000000000000000 > 0) {\\n result = (result * 0x1306FE0A31B7152DF) >> 64;\\n }\\n if (x & 0x2000000000000000 > 0) {\\n result = (result * 0x1172B83C7D517ADCE) >> 64;\\n }\\n if (x & 0x1000000000000000 > 0) {\\n result = (result * 0x10B5586CF9890F62A) >> 64;\\n }\\n if (x & 0x800000000000000 > 0) {\\n result = (result * 0x1059B0D31585743AE) >> 64;\\n }\\n if (x & 0x400000000000000 > 0) {\\n result = (result * 0x102C9A3E778060EE7) >> 64;\\n }\\n if (x & 0x200000000000000 > 0) {\\n result = (result * 0x10163DA9FB33356D8) >> 64;\\n }\\n if (x & 0x100000000000000 > 0) {\\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\\n }\\n }\\n\\n if (x & 0xFF000000000000 > 0) {\\n if (x & 0x80000000000000 > 0) {\\n result = (result * 0x10058C86DA1C09EA2) >> 64;\\n }\\n if (x & 0x40000000000000 > 0) {\\n result = (result * 0x1002C605E2E8CEC50) >> 64;\\n }\\n if (x & 0x20000000000000 > 0) {\\n result = (result * 0x100162F3904051FA1) >> 64;\\n }\\n if (x & 0x10000000000000 > 0) {\\n result = (result * 0x1000B175EFFDC76BA) >> 64;\\n }\\n if (x & 0x8000000000000 > 0) {\\n result = (result * 0x100058BA01FB9F96D) >> 64;\\n }\\n if (x & 0x4000000000000 > 0) {\\n result = (result * 0x10002C5CC37DA9492) >> 64;\\n }\\n if (x & 0x2000000000000 > 0) {\\n result = (result * 0x1000162E525EE0547) >> 64;\\n }\\n if (x & 0x1000000000000 > 0) {\\n result = (result * 0x10000B17255775C04) >> 64;\\n }\\n }\\n\\n if (x & 0xFF0000000000 > 0) {\\n if (x & 0x800000000000 > 0) {\\n result = (result * 0x1000058B91B5BC9AE) >> 64;\\n }\\n if (x & 0x400000000000 > 0) {\\n result = (result * 0x100002C5C89D5EC6D) >> 64;\\n }\\n if (x & 0x200000000000 > 0) {\\n result = (result * 0x10000162E43F4F831) >> 64;\\n }\\n if (x & 0x100000000000 > 0) {\\n result = (result * 0x100000B1721BCFC9A) >> 64;\\n }\\n if (x & 0x80000000000 > 0) {\\n result = (result * 0x10000058B90CF1E6E) >> 64;\\n }\\n if (x & 0x40000000000 > 0) {\\n result = (result * 0x1000002C5C863B73F) >> 64;\\n }\\n if (x & 0x20000000000 > 0) {\\n result = (result * 0x100000162E430E5A2) >> 64;\\n }\\n if (x & 0x10000000000 > 0) {\\n result = (result * 0x1000000B172183551) >> 64;\\n }\\n }\\n\\n if (x & 0xFF00000000 > 0) {\\n if (x & 0x8000000000 > 0) {\\n result = (result * 0x100000058B90C0B49) >> 64;\\n }\\n if (x & 0x4000000000 > 0) {\\n result = (result * 0x10000002C5C8601CC) >> 64;\\n }\\n if (x & 0x2000000000 > 0) {\\n result = (result * 0x1000000162E42FFF0) >> 64;\\n }\\n if (x & 0x1000000000 > 0) {\\n result = (result * 0x10000000B17217FBB) >> 64;\\n }\\n if (x & 0x800000000 > 0) {\\n result = (result * 0x1000000058B90BFCE) >> 64;\\n }\\n if (x & 0x400000000 > 0) {\\n result = (result * 0x100000002C5C85FE3) >> 64;\\n }\\n if (x & 0x200000000 > 0) {\\n result = (result * 0x10000000162E42FF1) >> 64;\\n }\\n if (x & 0x100000000 > 0) {\\n result = (result * 0x100000000B17217F8) >> 64;\\n }\\n }\\n\\n if (x & 0xFF000000 > 0) {\\n if (x & 0x80000000 > 0) {\\n result = (result * 0x10000000058B90BFC) >> 64;\\n }\\n if (x & 0x40000000 > 0) {\\n result = (result * 0x1000000002C5C85FE) >> 64;\\n }\\n if (x & 0x20000000 > 0) {\\n result = (result * 0x100000000162E42FF) >> 64;\\n }\\n if (x & 0x10000000 > 0) {\\n result = (result * 0x1000000000B17217F) >> 64;\\n }\\n if (x & 0x8000000 > 0) {\\n result = (result * 0x100000000058B90C0) >> 64;\\n }\\n if (x & 0x4000000 > 0) {\\n result = (result * 0x10000000002C5C860) >> 64;\\n }\\n if (x & 0x2000000 > 0) {\\n result = (result * 0x1000000000162E430) >> 64;\\n }\\n if (x & 0x1000000 > 0) {\\n result = (result * 0x10000000000B17218) >> 64;\\n }\\n }\\n\\n if (x & 0xFF0000 > 0) {\\n if (x & 0x800000 > 0) {\\n result = (result * 0x1000000000058B90C) >> 64;\\n }\\n if (x & 0x400000 > 0) {\\n result = (result * 0x100000000002C5C86) >> 64;\\n }\\n if (x & 0x200000 > 0) {\\n result = (result * 0x10000000000162E43) >> 64;\\n }\\n if (x & 0x100000 > 0) {\\n result = (result * 0x100000000000B1721) >> 64;\\n }\\n if (x & 0x80000 > 0) {\\n result = (result * 0x10000000000058B91) >> 64;\\n }\\n if (x & 0x40000 > 0) {\\n result = (result * 0x1000000000002C5C8) >> 64;\\n }\\n if (x & 0x20000 > 0) {\\n result = (result * 0x100000000000162E4) >> 64;\\n }\\n if (x & 0x10000 > 0) {\\n result = (result * 0x1000000000000B172) >> 64;\\n }\\n }\\n\\n if (x & 0xFF00 > 0) {\\n if (x & 0x8000 > 0) {\\n result = (result * 0x100000000000058B9) >> 64;\\n }\\n if (x & 0x4000 > 0) {\\n result = (result * 0x10000000000002C5D) >> 64;\\n }\\n if (x & 0x2000 > 0) {\\n result = (result * 0x1000000000000162E) >> 64;\\n }\\n if (x & 0x1000 > 0) {\\n result = (result * 0x10000000000000B17) >> 64;\\n }\\n if (x & 0x800 > 0) {\\n result = (result * 0x1000000000000058C) >> 64;\\n }\\n if (x & 0x400 > 0) {\\n result = (result * 0x100000000000002C6) >> 64;\\n }\\n if (x & 0x200 > 0) {\\n result = (result * 0x10000000000000163) >> 64;\\n }\\n if (x & 0x100 > 0) {\\n result = (result * 0x100000000000000B1) >> 64;\\n }\\n }\\n\\n if (x & 0xFF > 0) {\\n if (x & 0x80 > 0) {\\n result = (result * 0x10000000000000059) >> 64;\\n }\\n if (x & 0x40 > 0) {\\n result = (result * 0x1000000000000002C) >> 64;\\n }\\n if (x & 0x20 > 0) {\\n result = (result * 0x10000000000000016) >> 64;\\n }\\n if (x & 0x10 > 0) {\\n result = (result * 0x1000000000000000B) >> 64;\\n }\\n if (x & 0x8 > 0) {\\n result = (result * 0x10000000000000006) >> 64;\\n }\\n if (x & 0x4 > 0) {\\n result = (result * 0x10000000000000003) >> 64;\\n }\\n if (x & 0x2 > 0) {\\n result = (result * 0x10000000000000001) >> 64;\\n }\\n if (x & 0x1 > 0) {\\n result = (result * 0x10000000000000001) >> 64;\\n }\\n }\\n\\n // In the code snippet below, two operations are executed simultaneously:\\n //\\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\\n //\\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\\n // integer part, $2^n$.\\n result *= UNIT;\\n result >>= (191 - (x >> 64));\\n }\\n}\\n\\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\\n///\\n/// @dev See the note on \\\"msb\\\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\\n///\\n/// Each step in this implementation is equivalent to this high-level code:\\n///\\n/// ```solidity\\n/// if (x >= 2 ** 128) {\\n/// x >>= 128;\\n/// result += 128;\\n/// }\\n/// ```\\n///\\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\\n///\\n/// The Yul instructions used below are:\\n///\\n/// - \\\"gt\\\" is \\\"greater than\\\"\\n/// - \\\"or\\\" is the OR bitwise operator\\n/// - \\\"shl\\\" is \\\"shift left\\\"\\n/// - \\\"shr\\\" is \\\"shift right\\\"\\n///\\n/// @param x The uint256 number for which to find the index of the most significant bit.\\n/// @return result The index of the most significant bit as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction msb(uint256 x) pure returns (uint256 result) {\\n // 2^128\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^64\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^32\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(5, gt(x, 0xFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^16\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(4, gt(x, 0xFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^8\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(3, gt(x, 0xFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^4\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(2, gt(x, 0xF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^2\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(1, gt(x, 0x3))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^1\\n // No need to shift x any more.\\n assembly (\\\"memory-safe\\\") {\\n let factor := gt(x, 0x1)\\n result := or(result, factor)\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f7denominator with 512-bit precision.\\n///\\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - The denominator must not be zero.\\n/// - The result must fit in uint256.\\n///\\n/// @param x The multiplicand as a uint256.\\n/// @param y The multiplier as a uint256.\\n/// @param denominator The divisor as a uint256.\\n/// @return result The result as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly (\\\"memory-safe\\\") {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n unchecked {\\n return prod0 / denominator;\\n }\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n if (prod1 >= denominator) {\\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\\n }\\n\\n ////////////////////////////////////////////////////////////////////////////\\n // 512 by 256 division\\n ////////////////////////////////////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly (\\\"memory-safe\\\") {\\n // Compute remainder using the mulmod Yul instruction.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512-bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n unchecked {\\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\\n uint256 lpotdod = denominator & (~denominator + 1);\\n uint256 flippedLpotdod;\\n\\n assembly (\\\"memory-safe\\\") {\\n // Factor powers of two out of denominator.\\n denominator := div(denominator, lpotdod)\\n\\n // Divide [prod1 prod0] by lpotdod.\\n prod0 := div(prod0, lpotdod)\\n\\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * flippedLpotdod;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\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 works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\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^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f71e18 with 512-bit precision.\\n///\\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\\n///\\n/// Notes:\\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\\n/// - The result is rounded toward zero.\\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\\n///\\n/// $$\\n/// \\\\begin{cases}\\n/// x * y = MAX\\\\_UINT256 * UNIT \\\\\\\\\\n/// (x * y) \\\\% UNIT \\\\geq \\\\frac{UNIT}{2}\\n/// \\\\end{cases}\\n/// $$\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {mulDiv}.\\n/// - The result must fit in uint256.\\n///\\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\\n uint256 prod0;\\n uint256 prod1;\\n assembly (\\\"memory-safe\\\") {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n if (prod1 == 0) {\\n unchecked {\\n return prod0 / UNIT;\\n }\\n }\\n\\n if (prod1 >= UNIT) {\\n revert PRBMath_MulDiv18_Overflow(x, y);\\n }\\n\\n uint256 remainder;\\n assembly (\\\"memory-safe\\\") {\\n remainder := mulmod(x, y, UNIT)\\n result :=\\n mul(\\n or(\\n div(sub(prod0, remainder), UNIT_LPOTD),\\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\\n ),\\n UNIT_INVERSE\\n )\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f7denominator with 512-bit precision.\\n///\\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {mulDiv}.\\n/// - None of the inputs can be `type(int256).min`.\\n/// - The result must fit in int256.\\n///\\n/// @param x The multiplicand as an int256.\\n/// @param y The multiplier as an int256.\\n/// @param denominator The divisor as an int256.\\n/// @return result The result as an int256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\\n revert PRBMath_MulDivSigned_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x, y and the denominator.\\n uint256 xAbs;\\n uint256 yAbs;\\n uint256 dAbs;\\n unchecked {\\n xAbs = x < 0 ? uint256(-x) : uint256(x);\\n yAbs = y < 0 ? uint256(-y) : uint256(y);\\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\\n }\\n\\n // Compute the absolute value of x*y\\u00f7denominator. The result must fit in int256.\\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\\n if (resultAbs > uint256(type(int256).max)) {\\n revert PRBMath_MulDivSigned_Overflow(x, y);\\n }\\n\\n // Get the signs of x, y and the denominator.\\n uint256 sx;\\n uint256 sy;\\n uint256 sd;\\n assembly (\\\"memory-safe\\\") {\\n // \\\"sgt\\\" is the \\\"signed greater than\\\" assembly instruction and \\\"sub(0,1)\\\" is -1 in two's complement.\\n sx := sgt(x, sub(0, 1))\\n sy := sgt(y, sub(0, 1))\\n sd := sgt(denominator, sub(0, 1))\\n }\\n\\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\\n // If there are, the result should be negative. Otherwise, it should be positive.\\n unchecked {\\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\\n }\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - If x is not a perfect square, the result is rounded down.\\n/// - Credits to OpenZeppelin for the explanations in comments below.\\n///\\n/// @param x The uint256 number for which to calculate the square root.\\n/// @return result The result as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(uint256 x) pure returns (uint256 result) {\\n if (x == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of x is a power of 2 such that we have:\\n //\\n // $$\\n // msb(x) <= x <= 2*msb(x)$\\n // $$\\n //\\n // We write $msb(x)$ as $2^k$, and we get:\\n //\\n // $$\\n // k = log_2(x)\\n // $$\\n //\\n // Thus, we can write the initial inequality as:\\n //\\n // $$\\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\\\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\\\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\\n // $$\\n //\\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\\n uint256 xAux = uint256(x);\\n result = 1;\\n if (xAux >= 2 ** 128) {\\n xAux >>= 128;\\n result <<= 64;\\n }\\n if (xAux >= 2 ** 64) {\\n xAux >>= 64;\\n result <<= 32;\\n }\\n if (xAux >= 2 ** 32) {\\n xAux >>= 32;\\n result <<= 16;\\n }\\n if (xAux >= 2 ** 16) {\\n xAux >>= 16;\\n result <<= 8;\\n }\\n if (xAux >= 2 ** 8) {\\n xAux >>= 8;\\n result <<= 4;\\n }\\n if (xAux >= 2 ** 4) {\\n xAux >>= 4;\\n result <<= 2;\\n }\\n if (xAux >= 2 ** 2) {\\n result <<= 1;\\n }\\n\\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\\n // precision into the expected uint128 result.\\n unchecked {\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n\\n // If x is not a perfect square, round the result toward zero.\\n uint256 roundedResult = x / result;\\n if (result >= roundedResult) {\\n result = roundedResult;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaa374e2c26cc93e8c22a6953804ee05f811597ef5fa82f76824378b22944778b\",\"license\":\"MIT\"},\"@prb/math/src/UD2x18.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n/*\\n\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2588\\u2588\\u2554\\u2550\\u2550\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u2588\\u2588\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u255a\\u2550\\u255d \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\n\\n\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u255d\\n\\n*/\\n\\nimport \\\"./ud2x18/Casting.sol\\\";\\nimport \\\"./ud2x18/Constants.sol\\\";\\nimport \\\"./ud2x18/Errors.sol\\\";\\nimport \\\"./ud2x18/ValueType.sol\\\";\\n\",\"keccak256\":\"0xfb624e24cd8bb790fa08e7827819de85504a86e20e961fa4ad126c65b6d90641\",\"license\":\"MIT\"},\"@prb/math/src/UD60x18.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n/*\\n\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2588\\u2588\\u2554\\u2550\\u2550\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u2588\\u2588\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u255a\\u2550\\u255d \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\n\\n\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2588\\u2588\\u2588\\u2588\\u2557\\u255a\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551 \\u255a\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u255d \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u255d\\n\\n*/\\n\\nimport \\\"./ud60x18/Casting.sol\\\";\\nimport \\\"./ud60x18/Constants.sol\\\";\\nimport \\\"./ud60x18/Conversions.sol\\\";\\nimport \\\"./ud60x18/Errors.sol\\\";\\nimport \\\"./ud60x18/Helpers.sol\\\";\\nimport \\\"./ud60x18/Math.sol\\\";\\nimport \\\"./ud60x18/ValueType.sol\\\";\\n\",\"keccak256\":\"0xb98c6f74275914d279e8af6c502c2b1f50d5f6e1ed418d3b0153f5a193206c48\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts an SD1x18 number into SD59x18.\\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\\n}\\n\\n/// @notice Casts an SD1x18 number into UD2x18.\\n/// - x must be positive.\\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\\n }\\n result = UD2x18.wrap(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into UD60x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\\n }\\n result = UD60x18.wrap(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint256.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\\n }\\n result = uint256(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\\n }\\n result = uint128(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\\n }\\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\\n }\\n result = uint40(uint64(xInt));\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\\n result = SD1x18.wrap(x);\\n}\\n\\n/// @notice Unwraps an SD1x18 number into int64.\\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\\n result = SD1x18.unwrap(x);\\n}\\n\\n/// @notice Wraps an int64 number into SD1x18.\\nfunction wrap(int64 x) pure returns (SD1x18 result) {\\n result = SD1x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x9e49e2b37c1bb845861740805edaaef3fe951a7b96eef16ce84fbf76e8278670\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @dev Euler's number as an SD1x18 number.\\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum value an SD1x18 number can have.\\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\\n\\n/// @dev The maximum value an SD1x18 number can have.\\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\\n\\n/// @dev PI as an SD1x18 number.\\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of SD1x18.\\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\\nint64 constant uUNIT = 1e18;\\n\",\"keccak256\":\"0x6496165b80552785a4b65a239b96e2a5fedf62fe54f002eeed72d75e566d7585\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\\n\",\"keccak256\":\"0x836cb42ba619ca369fd4765bc47fefc3c3621369c5861882af14660aca5057ee\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\n\\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\\n/// storage.\\ntype SD1x18 is int64;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD59x18,\\n Casting.intoUD2x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for SD1x18 global;\\n\",\"keccak256\":\"0x2f86f1aa9fca42f40808b51a879b406ac51817647bdb9642f8a79dd8fdb754a7\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { MAX_UINT128, MAX_UINT40 } from \\\"../Common.sol\\\";\\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { uMAX_UD2x18 } from \\\"../ud2x18/Constants.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts an SD59x18 number into int256.\\n/// @dev This is basically a functional alias for {unwrap}.\\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\\n result = SD59x18.unwrap(x);\\n}\\n\\n/// @notice Casts an SD59x18 number into SD1x18.\\n/// @dev Requirements:\\n/// - x must be greater than or equal to `uMIN_SD1x18`.\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < uMIN_SD1x18) {\\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\\n }\\n if (xInt > uMAX_SD1x18) {\\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into UD2x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `uMAX_UD2x18`.\\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\\n }\\n if (xInt > int256(uint256(uMAX_UD2x18))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\\n }\\n result = UD2x18.wrap(uint64(uint256(xInt)));\\n}\\n\\n/// @notice Casts an SD59x18 number into UD60x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\\n }\\n result = UD60x18.wrap(uint256(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into uint256.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\\n }\\n result = uint256(xInt);\\n}\\n\\n/// @notice Casts an SD59x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `uMAX_UINT128`.\\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\\n }\\n if (xInt > int256(uint256(MAX_UINT128))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\\n }\\n result = uint128(uint256(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\\n }\\n if (xInt > int256(uint256(MAX_UINT40))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(uint256(xInt));\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\\n/// @notice Unwraps an SD59x18 number into int256.\\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\\n result = SD59x18.unwrap(x);\\n}\\n\\n/// @notice Wraps an int256 number into SD59x18.\\nfunction wrap(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x3b21b60ec2998c3ae32f647412da51d3683b3f183a807198cc8d157499484f99\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n// NOTICE: the \\\"u\\\" prefix stands for \\\"unwrapped\\\".\\n\\n/// @dev Euler's number as an SD59x18 number.\\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum input permitted in {exp}.\\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\\n\\n/// @dev Any value less than this returns 0 in {exp}.\\nint256 constant uEXP_MIN_THRESHOLD = -41_446531673892822322;\\nSD59x18 constant EXP_MIN_THRESHOLD = SD59x18.wrap(uEXP_MIN_THRESHOLD);\\n\\n/// @dev The maximum input permitted in {exp2}.\\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\\n\\n/// @dev Any value less than this returns 0 in {exp2}.\\nint256 constant uEXP2_MIN_THRESHOLD = -59_794705707972522261;\\nSD59x18 constant EXP2_MIN_THRESHOLD = SD59x18.wrap(uEXP2_MIN_THRESHOLD);\\n\\n/// @dev Half the UNIT number.\\nint256 constant uHALF_UNIT = 0.5e18;\\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\\n\\n/// @dev $log_2(10)$ as an SD59x18 number.\\nint256 constant uLOG2_10 = 3_321928094887362347;\\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\\n\\n/// @dev $log_2(e)$ as an SD59x18 number.\\nint256 constant uLOG2_E = 1_442695040888963407;\\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\\n\\n/// @dev The maximum value an SD59x18 number can have.\\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\\n\\n/// @dev The maximum whole value an SD59x18 number can have.\\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\\n\\n/// @dev The minimum value an SD59x18 number can have.\\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\\n\\n/// @dev The minimum whole value an SD59x18 number can have.\\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\\n\\n/// @dev PI as an SD59x18 number.\\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of SD59x18.\\nint256 constant uUNIT = 1e18;\\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\\n\\n/// @dev The unit number squared.\\nint256 constant uUNIT_SQUARED = 1e36;\\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\\n\\n/// @dev Zero as an SD59x18 number.\\nSD59x18 constant ZERO = SD59x18.wrap(0);\\n\",\"keccak256\":\"0x9bcb8dd6b3e886d140ad1c32747a4f6d29a492529ceb835be878ae837aa6cc3a\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Abs_MinSD59x18();\\n\\n/// @notice Thrown when ceiling a number overflows SD59x18.\\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\\n\\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Div_InputTooSmall();\\n\\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\\n\\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\\n\\n/// @notice Thrown when flooring a number underflows SD59x18.\\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\\n\\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Mul_InputTooSmall();\\n\\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\\n\\n/// @notice Thrown when taking the square root of a negative number.\\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\\n\\n/// @notice Thrown when the calculating the square root overflows SD59x18.\\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\\n\",\"keccak256\":\"0xa6d00fe5efa215ac0df25c896e3da99a12fb61e799644b2ec32da947313d3db4\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() + y.unwrap());\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() & bits);\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() & y.unwrap());\\n}\\n\\n/// @notice Implements the equal (=) operation in the SD59x18 type.\\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() == y.unwrap();\\n}\\n\\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() > y.unwrap();\\n}\\n\\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() >= y.unwrap();\\n}\\n\\n/// @notice Implements a zero comparison check function in the SD59x18 type.\\nfunction isZero(SD59x18 x) pure returns (bool result) {\\n result = x.unwrap() == 0;\\n}\\n\\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() << bits);\\n}\\n\\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() < y.unwrap();\\n}\\n\\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() <= y.unwrap();\\n}\\n\\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() % y.unwrap());\\n}\\n\\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() != y.unwrap();\\n}\\n\\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(~x.unwrap());\\n}\\n\\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() | y.unwrap());\\n}\\n\\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() >> bits);\\n}\\n\\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() - y.unwrap());\\n}\\n\\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(-x.unwrap());\\n}\\n\\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() + y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() - y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(-x.unwrap());\\n }\\n}\\n\\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() ^ y.unwrap());\\n}\\n\",\"keccak256\":\"0x208570f1657cf730cb6c3d81aa14030e0d45cf906cdedea5059369d7df4bb716\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport {\\n uEXP_MAX_INPUT,\\n uEXP2_MAX_INPUT,\\n uEXP_MIN_THRESHOLD,\\n uEXP2_MIN_THRESHOLD,\\n uHALF_UNIT,\\n uLOG2_10,\\n uLOG2_E,\\n uMAX_SD59x18,\\n uMAX_WHOLE_SD59x18,\\n uMIN_SD59x18,\\n uMIN_WHOLE_SD59x18,\\n UNIT,\\n uUNIT,\\n uUNIT_SQUARED,\\n ZERO\\n} from \\\"./Constants.sol\\\";\\nimport { wrap } from \\\"./Helpers.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Calculates the absolute value of x.\\n///\\n/// @dev Requirements:\\n/// - x must be greater than `MIN_SD59x18`.\\n///\\n/// @param x The SD59x18 number for which to calculate the absolute value.\\n/// @param result The absolute value of x as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\\n }\\n result = xInt < 0 ? wrap(-xInt) : x;\\n}\\n\\n/// @notice Calculates the arithmetic average of x and y.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// @param x The first operand as an SD59x18 number.\\n/// @param y The second operand as an SD59x18 number.\\n/// @return result The arithmetic average as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n\\n unchecked {\\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\\n int256 sum = (xInt >> 1) + (yInt >> 1);\\n\\n if (sum < 0) {\\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\\n assembly (\\\"memory-safe\\\") {\\n result := add(sum, and(or(xInt, yInt), 1))\\n }\\n } else {\\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\\n result = wrap(sum + (xInt & yInt & 1));\\n }\\n }\\n}\\n\\n/// @notice Yields the smallest whole number greater than or equal to x.\\n///\\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\\n///\\n/// @param x The SD59x18 number to ceil.\\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt > uMAX_WHOLE_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\\n }\\n\\n int256 remainder = xInt % uUNIT;\\n if (remainder == 0) {\\n result = x;\\n } else {\\n unchecked {\\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\\n int256 resultInt = xInt - remainder;\\n if (xInt > 0) {\\n resultInt += uUNIT;\\n }\\n result = wrap(resultInt);\\n }\\n }\\n}\\n\\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\\n///\\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\\n/// values separately.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n/// - None of the inputs can be `MIN_SD59x18`.\\n/// - The denominator must not be zero.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The numerator as an SD59x18 number.\\n/// @param y The denominator as an SD59x18 number.\\n/// @param result The quotient as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x and y.\\n uint256 xAbs;\\n uint256 yAbs;\\n unchecked {\\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\\n }\\n\\n // Compute the absolute value (x*UNIT\\u00f7y). The resulting value must fit in SD59x18.\\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\\n }\\n\\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\\n // negative, 0 for positive or zero).\\n bool sameSign = (xInt ^ yInt) > -1;\\n\\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\\n unchecked {\\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\\n }\\n}\\n\\n/// @notice Calculates the natural exponent of x using the following formula:\\n///\\n/// $$\\n/// e^x = 2^{x * log_2{e}}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {exp2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}.\\n/// - x must be less than 133_084258667509499441.\\n///\\n/// @param x The exponent as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n\\n // Any input less than the threshold returns zero.\\n // This check also prevents an overflow for very small numbers.\\n if (xInt < uEXP_MIN_THRESHOLD) {\\n return ZERO;\\n }\\n\\n // This check prevents values greater than 192e18 from being passed to {exp2}.\\n if (xInt > uEXP_MAX_INPUT) {\\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Inline the fixed-point multiplication to save gas.\\n int256 doubleUnitProduct = xInt * uLOG2_E;\\n result = exp2(wrap(doubleUnitProduct / uUNIT));\\n }\\n}\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\\n///\\n/// $$\\n/// 2^{-x} = \\\\frac{1}{2^x}\\n/// $$\\n///\\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\\n///\\n/// Notes:\\n/// - If x is less than -59_794705707972522261, the result is zero.\\n///\\n/// Requirements:\\n/// - x must be less than 192e18.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The exponent as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n // The inverse of any number less than the threshold is truncated to zero.\\n if (xInt < uEXP2_MIN_THRESHOLD) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Inline the fixed-point inversion to save gas.\\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\\n }\\n } else {\\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\\n if (xInt > uEXP2_MAX_INPUT) {\\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Convert x to the 192.64-bit fixed-point format.\\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\\n\\n // It is safe to cast the result to int256 due to the checks above.\\n result = wrap(int256(Common.exp2(x_192x64)));\\n }\\n }\\n}\\n\\n/// @notice Yields the greatest whole number less than or equal to x.\\n///\\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\\n///\\n/// @param x The SD59x18 number to floor.\\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < uMIN_WHOLE_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\\n }\\n\\n int256 remainder = xInt % uUNIT;\\n if (remainder == 0) {\\n result = x;\\n } else {\\n unchecked {\\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\\n int256 resultInt = xInt - remainder;\\n if (xInt < 0) {\\n resultInt -= uUNIT;\\n }\\n result = wrap(resultInt);\\n }\\n }\\n}\\n\\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\\n/// of the radix point for negative numbers.\\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\\n/// @param x The SD59x18 number to get the fractional part of.\\n/// @param result The fractional part of x as an SD59x18 number.\\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() % uUNIT);\\n}\\n\\n/// @notice Calculates the geometric mean of x and y, i.e. $\\\\sqrt{x * y}$.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x * y must fit in SD59x18.\\n/// - x * y must not be negative, since complex numbers are not supported.\\n///\\n/// @param x The first operand as an SD59x18 number.\\n/// @param y The second operand as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == 0 || yInt == 0) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\\n int256 xyInt = xInt * yInt;\\n if (xyInt / xInt != yInt) {\\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\\n }\\n\\n // The product must not be negative, since complex numbers are not supported.\\n if (xyInt < 0) {\\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\\n }\\n\\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\\n // during multiplication. See the comments in {Common.sqrt}.\\n uint256 resultUint = Common.sqrt(uint256(xyInt));\\n result = wrap(int256(resultUint));\\n }\\n}\\n\\n/// @notice Calculates the inverse of x.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must not be zero.\\n///\\n/// @param x The SD59x18 number for which to calculate the inverse.\\n/// @return result The inverse as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(uUNIT_SQUARED / x.unwrap());\\n}\\n\\n/// @notice Calculates the natural logarithm of x using the following formula:\\n///\\n/// $$\\n/// ln{x} = log_2{x} / log_2{e}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\\n/// @return result The natural logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\\n // {log2} can return is ~195_205294292027477728.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\\n}\\n\\n/// @notice Calculates the common logarithm of x using the following formula:\\n///\\n/// $$\\n/// log_{10}{x} = log_2{x} / log_2{10}\\n/// $$\\n///\\n/// However, if x is an exact power of ten, a hard coded value is returned.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The SD59x18 number for which to calculate the common logarithm.\\n/// @return result The common logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\\n }\\n\\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\\n // prettier-ignore\\n assembly (\\\"memory-safe\\\") {\\n switch x\\n case 1 { result := mul(uUNIT, sub(0, 18)) }\\n case 10 { result := mul(uUNIT, sub(1, 18)) }\\n case 100 { result := mul(uUNIT, sub(2, 18)) }\\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\\n case 1000000000000000000 { result := 0 }\\n case 10000000000000000000 { result := uUNIT }\\n case 100000000000000000000 { result := mul(uUNIT, 2) }\\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\\n default { result := uMAX_SD59x18 }\\n }\\n\\n if (result.unwrap() == uMAX_SD59x18) {\\n unchecked {\\n // Inline the fixed-point division to save gas.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\\n }\\n }\\n}\\n\\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\\n///\\n/// $$\\n/// log_2{x} = n + log_2{y}, \\\\text{ where } y = x*2^{-n}, \\\\ y \\\\in [1, 2)\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, the input is inverted:\\n///\\n/// $$\\n/// log_2{x} = -log_2{\\\\frac{1}{x}}\\n/// $$\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\\n///\\n/// Notes:\\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\\n///\\n/// Requirements:\\n/// - x must be greater than zero.\\n///\\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\\n/// @return result The binary logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt <= 0) {\\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\\n }\\n\\n unchecked {\\n int256 sign;\\n if (xInt >= uUNIT) {\\n sign = 1;\\n } else {\\n sign = -1;\\n // Inline the fixed-point inversion to save gas.\\n xInt = uUNIT_SQUARED / xInt;\\n }\\n\\n // Calculate the integer part of the logarithm.\\n uint256 n = Common.msb(uint256(xInt / uUNIT));\\n\\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\\n int256 resultInt = int256(n) * uUNIT;\\n\\n // Calculate $y = x * 2^{-n}$.\\n int256 y = xInt >> n;\\n\\n // If y is the unit number, the fractional part is zero.\\n if (y == uUNIT) {\\n return wrap(resultInt * sign);\\n }\\n\\n // Calculate the fractional part via the iterative approximation.\\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\\n int256 DOUBLE_UNIT = 2e18;\\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\\n y = (y * y) / uUNIT;\\n\\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\\n if (y >= DOUBLE_UNIT) {\\n // Add the 2^{-m} factor to the logarithm.\\n resultInt = resultInt + delta;\\n\\n // Halve y, which corresponds to z/2 in the Wikipedia article.\\n y >>= 1;\\n }\\n }\\n resultInt *= sign;\\n result = wrap(resultInt);\\n }\\n}\\n\\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv18}.\\n/// - None of the inputs can be `MIN_SD59x18`.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The multiplicand as an SD59x18 number.\\n/// @param y The multiplier as an SD59x18 number.\\n/// @return result The product as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x and y.\\n uint256 xAbs;\\n uint256 yAbs;\\n unchecked {\\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\\n }\\n\\n // Compute the absolute value (x*y\\u00f7UNIT). The resulting value must fit in SD59x18.\\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\\n }\\n\\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\\n // negative, 0 for positive or zero).\\n bool sameSign = (xInt ^ yInt) > -1;\\n\\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\\n unchecked {\\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\\n }\\n}\\n\\n/// @notice Raises x to the power of y using the following formula:\\n///\\n/// $$\\n/// x^y = 2^{log_2{x} * y}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\\n///\\n/// @param x The base as an SD59x18 number.\\n/// @param y Exponent to raise x to, as an SD59x18 number\\n/// @return result x raised to power y, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n\\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\\n if (xInt == 0) {\\n return yInt == 0 ? UNIT : ZERO;\\n }\\n // If x is `UNIT`, the result is always `UNIT`.\\n else if (xInt == uUNIT) {\\n return UNIT;\\n }\\n\\n // If y is zero, the result is always `UNIT`.\\n if (yInt == 0) {\\n return UNIT;\\n }\\n // If y is `UNIT`, the result is always x.\\n else if (yInt == uUNIT) {\\n return x;\\n }\\n\\n // Calculate the result using the formula.\\n result = exp2(mul(log2(x), y));\\n}\\n\\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\\n/// algorithm \\\"exponentiation by squaring\\\".\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The base as an SD59x18 number.\\n/// @param y The exponent as a uint256.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\\n uint256 xAbs = uint256(abs(x).unwrap());\\n\\n // Calculate the first iteration of the loop in advance.\\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\\n\\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\\n uint256 yAux = y;\\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\\n xAbs = Common.mulDiv18(xAbs, xAbs);\\n\\n // Equivalent to `y % 2 == 1`.\\n if (yAux & 1 > 0) {\\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\\n }\\n }\\n\\n // The result must fit in SD59x18.\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\\n }\\n\\n unchecked {\\n // Is the base negative and the exponent odd? If yes, the result should be negative.\\n int256 resultInt = int256(resultAbs);\\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\\n if (isNegative) {\\n resultInt = -resultInt;\\n }\\n result = wrap(resultInt);\\n }\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - Only the positive root is returned.\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x cannot be negative, since complex numbers are not supported.\\n/// - x must be less than `MAX_SD59x18 / UNIT`.\\n///\\n/// @param x The SD59x18 number for which to calculate the square root.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\\n }\\n if (xInt > uMAX_SD59x18 / uUNIT) {\\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\\n }\\n\\n unchecked {\\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\\n // In this case, the two numbers are both the square root.\\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\\n result = wrap(int256(resultUint));\\n }\\n}\\n\",\"keccak256\":\"0xa074831139fc89ca0e5a36086b30eb50896bb6770cd5823461b1f2769017d2f0\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\nimport \\\"./Helpers.sol\\\" as Helpers;\\nimport \\\"./Math.sol\\\" as Math;\\n\\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type int256.\\ntype SD59x18 is int256;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoInt256,\\n Casting.intoSD1x18,\\n Casting.intoUD2x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Math.abs,\\n Math.avg,\\n Math.ceil,\\n Math.div,\\n Math.exp,\\n Math.exp2,\\n Math.floor,\\n Math.frac,\\n Math.gm,\\n Math.inv,\\n Math.log10,\\n Math.log2,\\n Math.ln,\\n Math.mul,\\n Math.pow,\\n Math.powu,\\n Math.sqrt\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n HELPER FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Helpers.add,\\n Helpers.and,\\n Helpers.eq,\\n Helpers.gt,\\n Helpers.gte,\\n Helpers.isZero,\\n Helpers.lshift,\\n Helpers.lt,\\n Helpers.lte,\\n Helpers.mod,\\n Helpers.neq,\\n Helpers.not,\\n Helpers.or,\\n Helpers.rshift,\\n Helpers.sub,\\n Helpers.uncheckedAdd,\\n Helpers.uncheckedSub,\\n Helpers.uncheckedUnary,\\n Helpers.xor\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n OPERATORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes it possible to use these operators on the SD59x18 type.\\nusing {\\n Helpers.add as +,\\n Helpers.and2 as &,\\n Math.div as /,\\n Helpers.eq as ==,\\n Helpers.gt as >,\\n Helpers.gte as >=,\\n Helpers.lt as <,\\n Helpers.lte as <=,\\n Helpers.mod as %,\\n Math.mul as *,\\n Helpers.neq as !=,\\n Helpers.not as ~,\\n Helpers.or as |,\\n Helpers.sub as -,\\n Helpers.unary as -,\\n Helpers.xor as ^\\n} for SD59x18 global;\\n\",\"keccak256\":\"0xe03112d145dcd5863aff24e5f381debaae29d446acd5666f3d640e3d9af738d7\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport { uMAX_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts a UD2x18 number into SD1x18.\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\\n uint64 xUint = UD2x18.unwrap(x);\\n if (xUint > uint64(uMAX_SD1x18)) {\\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(xUint));\\n}\\n\\n/// @notice Casts a UD2x18 number into SD59x18.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\\n}\\n\\n/// @notice Casts a UD2x18 number into UD60x18.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint128.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\\n result = uint128(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint256.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\\n result = uint256(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\\n uint64 xUint = UD2x18.unwrap(x);\\n if (xUint > uint64(Common.MAX_UINT40)) {\\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(xUint);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\\n result = UD2x18.wrap(x);\\n}\\n\\n/// @notice Unwrap a UD2x18 number into uint64.\\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\\n result = UD2x18.unwrap(x);\\n}\\n\\n/// @notice Wraps a uint64 number into UD2x18.\\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\\n result = UD2x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x9b1a35d432ef951a415fae8098b3c609a99b630a3d5464b3c8e1efa8893eea07\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @dev Euler's number as a UD2x18 number.\\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum value a UD2x18 number can have.\\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\\n\\n/// @dev PI as a UD2x18 number.\\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of UD2x18.\\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\\nuint64 constant uUNIT = 1e18;\\n\",\"keccak256\":\"0x29b0e050c865899e1fb9022b460a7829cdee248c44c4299f068ba80695eec3fc\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\\n\\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\\n\",\"keccak256\":\"0xdf1e22f0b4c8032bcc8b7f63fe3984e1387f3dc7b2e9ab381822249f75376d33\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\n\\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\\n/// storage.\\ntype UD2x18 is uint64;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD1x18,\\n Casting.intoSD59x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for UD2x18 global;\\n\",\"keccak256\":\"0x2802edc9869db116a0b5c490cc5f8554742f747183fa30ac5e9c80bb967e61a1\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { MAX_UINT128, MAX_UINT40 } from \\\"../Common.sol\\\";\\nimport { uMAX_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { uMAX_SD59x18 } from \\\"../sd59x18/Constants.sol\\\";\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { uMAX_UD2x18 } from \\\"../ud2x18/Constants.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts a UD60x18 number into SD1x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uint256(int256(uMAX_SD1x18))) {\\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(uint64(xUint)));\\n}\\n\\n/// @notice Casts a UD60x18 number into UD2x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_UD2x18`.\\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uMAX_UD2x18) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\\n }\\n result = UD2x18.wrap(uint64(xUint));\\n}\\n\\n/// @notice Casts a UD60x18 number into SD59x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_SD59x18`.\\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uint256(uMAX_SD59x18)) {\\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\\n }\\n result = SD59x18.wrap(int256(xUint));\\n}\\n\\n/// @notice Casts a UD60x18 number into uint128.\\n/// @dev This is basically an alias for {unwrap}.\\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x);\\n}\\n\\n/// @notice Casts a UD60x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT128`.\\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > MAX_UINT128) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\\n }\\n result = uint128(xUint);\\n}\\n\\n/// @notice Casts a UD60x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > MAX_UINT40) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(xUint);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\\n/// @notice Unwraps a UD60x18 number into uint256.\\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x);\\n}\\n\\n/// @notice Wraps a uint256 number into the UD60x18 value type.\\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x5bb532da36921cbdac64d1f16de5d366ef1f664502e3b7c07d0ad06917551f85\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n// NOTICE: the \\\"u\\\" prefix stands for \\\"unwrapped\\\".\\n\\n/// @dev Euler's number as a UD60x18 number.\\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum input permitted in {exp}.\\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\\n\\n/// @dev The maximum input permitted in {exp2}.\\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\\n\\n/// @dev Half the UNIT number.\\nuint256 constant uHALF_UNIT = 0.5e18;\\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\\n\\n/// @dev $log_2(10)$ as a UD60x18 number.\\nuint256 constant uLOG2_10 = 3_321928094887362347;\\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\\n\\n/// @dev $log_2(e)$ as a UD60x18 number.\\nuint256 constant uLOG2_E = 1_442695040888963407;\\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\\n\\n/// @dev The maximum value a UD60x18 number can have.\\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\\n\\n/// @dev The maximum whole value a UD60x18 number can have.\\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\\n\\n/// @dev PI as a UD60x18 number.\\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of UD60x18.\\nuint256 constant uUNIT = 1e18;\\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\\n\\n/// @dev The unit number squared.\\nuint256 constant uUNIT_SQUARED = 1e36;\\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\\n\\n/// @dev Zero as a UD60x18 number.\\nUD60x18 constant ZERO = UD60x18.wrap(0);\\n\",\"keccak256\":\"0x2b80d26153d3fdcfb3a9ca772d9309d31ed1275f5b8b54c3ffb54d3652b37d90\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Conversions.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { uMAX_UD60x18, uUNIT } from \\\"./Constants.sol\\\";\\nimport { PRBMath_UD60x18_Convert_Overflow } from \\\"./Errors.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\\n/// @dev The result is rounded toward zero.\\n/// @param x The UD60x18 number to convert.\\n/// @return result The same number in basic integer form.\\nfunction convert(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x) / uUNIT;\\n}\\n\\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\\n///\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\\n///\\n/// @param x The basic integer to convert.\\n/// @param result The same number converted to UD60x18.\\nfunction convert(uint256 x) pure returns (UD60x18 result) {\\n if (x > uMAX_UD60x18 / uUNIT) {\\n revert PRBMath_UD60x18_Convert_Overflow(x);\\n }\\n unchecked {\\n result = UD60x18.wrap(x * uUNIT);\\n }\\n}\\n\",\"keccak256\":\"0xaf7fc2523413822de3b66ba339fe2884fb3b8c6f6cf38ec90a2c3e3aae71df6b\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when ceiling a number overflows UD60x18.\\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\\n\\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\\n\\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when taking the logarithm of a number less than 1.\\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\\n\\n/// @notice Thrown when calculating the square root overflows UD60x18.\\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\\n\",\"keccak256\":\"0xa8c60d4066248df22c49c882873efbc017344107edabc48c52209abbc39cb1e3\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() + y.unwrap());\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() & bits);\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() & y.unwrap());\\n}\\n\\n/// @notice Implements the equal operation (==) in the UD60x18 type.\\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() == y.unwrap();\\n}\\n\\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() > y.unwrap();\\n}\\n\\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() >= y.unwrap();\\n}\\n\\n/// @notice Implements a zero comparison check function in the UD60x18 type.\\nfunction isZero(UD60x18 x) pure returns (bool result) {\\n // This wouldn't work if x could be negative.\\n result = x.unwrap() == 0;\\n}\\n\\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() << bits);\\n}\\n\\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() < y.unwrap();\\n}\\n\\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() <= y.unwrap();\\n}\\n\\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() % y.unwrap());\\n}\\n\\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() != y.unwrap();\\n}\\n\\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\\n result = wrap(~x.unwrap());\\n}\\n\\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() | y.unwrap());\\n}\\n\\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() >> bits);\\n}\\n\\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() - y.unwrap());\\n}\\n\\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() + y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() - y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() ^ y.unwrap());\\n}\\n\",\"keccak256\":\"0xf5faff881391d2c060029499a666cc5f0bea90a213150bb476fae8f02a5df268\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport {\\n uEXP_MAX_INPUT,\\n uEXP2_MAX_INPUT,\\n uHALF_UNIT,\\n uLOG2_10,\\n uLOG2_E,\\n uMAX_UD60x18,\\n uMAX_WHOLE_UD60x18,\\n UNIT,\\n uUNIT,\\n uUNIT_SQUARED,\\n ZERO\\n} from \\\"./Constants.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Calculates the arithmetic average of x and y using the following formula:\\n///\\n/// $$\\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\\n/// $$\\n///\\n/// In English, this is what this formula does:\\n///\\n/// 1. AND x and y.\\n/// 2. Calculate half of XOR x and y.\\n/// 3. Add the two results together.\\n///\\n/// This technique is known as SWAR, which stands for \\\"SIMD within a register\\\". You can read more about it here:\\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// @param x The first operand as a UD60x18 number.\\n/// @param y The second operand as a UD60x18 number.\\n/// @return result The arithmetic average as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n unchecked {\\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\\n }\\n}\\n\\n/// @notice Yields the smallest whole number greater than or equal to x.\\n///\\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\\n///\\n/// @param x The UD60x18 number to ceil.\\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n if (xUint > uMAX_WHOLE_UD60x18) {\\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\\n }\\n\\n assembly (\\\"memory-safe\\\") {\\n // Equivalent to `x % UNIT`.\\n let remainder := mod(x, uUNIT)\\n\\n // Equivalent to `UNIT - remainder`.\\n let delta := sub(uUNIT, remainder)\\n\\n // Equivalent to `x + remainder > 0 ? delta : 0`.\\n result := add(x, mul(delta, gt(remainder, 0)))\\n }\\n}\\n\\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\\n///\\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n///\\n/// @param x The numerator as a UD60x18 number.\\n/// @param y The denominator as a UD60x18 number.\\n/// @param result The quotient as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\\n}\\n\\n/// @notice Calculates the natural exponent of x using the following formula:\\n///\\n/// $$\\n/// e^x = 2^{x * log_2{e}}\\n/// $$\\n///\\n/// @dev Requirements:\\n/// - x must be less than 133_084258667509499441.\\n///\\n/// @param x The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n // This check prevents values greater than 192e18 from being passed to {exp2}.\\n if (xUint > uEXP_MAX_INPUT) {\\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Inline the fixed-point multiplication to save gas.\\n uint256 doubleUnitProduct = xUint * uLOG2_E;\\n result = exp2(wrap(doubleUnitProduct / uUNIT));\\n }\\n}\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method.\\n///\\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\\n///\\n/// Requirements:\\n/// - x must be less than 192e18.\\n/// - The result must fit in UD60x18.\\n///\\n/// @param x The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\\n if (xUint > uEXP2_MAX_INPUT) {\\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\\n }\\n\\n // Convert x to the 192.64-bit fixed-point format.\\n uint256 x_192x64 = (xUint << 64) / uUNIT;\\n\\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\\n result = wrap(Common.exp2(x_192x64));\\n}\\n\\n/// @notice Yields the greatest whole number less than or equal to x.\\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n/// @param x The UD60x18 number to floor.\\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\\n assembly (\\\"memory-safe\\\") {\\n // Equivalent to `x % UNIT`.\\n let remainder := mod(x, uUNIT)\\n\\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\\n result := sub(x, mul(remainder, gt(remainder, 0)))\\n }\\n}\\n\\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\\n/// @param x The UD60x18 number to get the fractional part of.\\n/// @param result The fractional part of x as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\\n assembly (\\\"memory-safe\\\") {\\n result := mod(x, uUNIT)\\n }\\n}\\n\\n/// @notice Calculates the geometric mean of x and y, i.e. $\\\\sqrt{x * y}$, rounding down.\\n///\\n/// @dev Requirements:\\n/// - x * y must fit in UD60x18.\\n///\\n/// @param x The first operand as a UD60x18 number.\\n/// @param y The second operand as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n if (xUint == 0 || yUint == 0) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Checking for overflow this way is faster than letting Solidity do it.\\n uint256 xyUint = xUint * yUint;\\n if (xyUint / xUint != yUint) {\\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\\n }\\n\\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\\n // during multiplication. See the comments in {Common.sqrt}.\\n result = wrap(Common.sqrt(xyUint));\\n }\\n}\\n\\n/// @notice Calculates the inverse of x.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must not be zero.\\n///\\n/// @param x The UD60x18 number for which to calculate the inverse.\\n/// @return result The inverse as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(uUNIT_SQUARED / x.unwrap());\\n }\\n}\\n\\n/// @notice Calculates the natural logarithm of x using the following formula:\\n///\\n/// $$\\n/// ln{x} = log_2{x} / log_2{e}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\\n/// @return result The natural logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\\n unchecked {\\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\\n // {log2} can return is ~196_205294292027477728.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\\n }\\n}\\n\\n/// @notice Calculates the common logarithm of x using the following formula:\\n///\\n/// $$\\n/// log_{10}{x} = log_2{x} / log_2{10}\\n/// $$\\n///\\n/// However, if x is an exact power of ten, a hard coded value is returned.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The UD60x18 number for which to calculate the common logarithm.\\n/// @return result The common logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n if (xUint < uUNIT) {\\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\\n }\\n\\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\\n // prettier-ignore\\n assembly (\\\"memory-safe\\\") {\\n switch x\\n case 1 { result := mul(uUNIT, sub(0, 18)) }\\n case 10 { result := mul(uUNIT, sub(1, 18)) }\\n case 100 { result := mul(uUNIT, sub(2, 18)) }\\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\\n case 1000000000000000000 { result := 0 }\\n case 10000000000000000000 { result := uUNIT }\\n case 100000000000000000000 { result := mul(uUNIT, 2) }\\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\\n default { result := uMAX_UD60x18 }\\n }\\n\\n if (result.unwrap() == uMAX_UD60x18) {\\n unchecked {\\n // Inline the fixed-point division to save gas.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\\n }\\n }\\n}\\n\\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\\n///\\n/// $$\\n/// log_2{x} = n + log_2{y}, \\\\text{ where } y = x*2^{-n}, \\\\ y \\\\in [1, 2)\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, the input is inverted:\\n///\\n/// $$\\n/// log_2{x} = -log_2{\\\\frac{1}{x}}\\n/// $$\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\\n///\\n/// Notes:\\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\\n///\\n/// Requirements:\\n/// - x must be greater than zero.\\n///\\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\\n/// @return result The binary logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n if (xUint < uUNIT) {\\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\\n }\\n\\n unchecked {\\n // Calculate the integer part of the logarithm.\\n uint256 n = Common.msb(xUint / uUNIT);\\n\\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\\n // n is at most 255 and UNIT is 1e18.\\n uint256 resultUint = n * uUNIT;\\n\\n // Calculate $y = x * 2^{-n}$.\\n uint256 y = xUint >> n;\\n\\n // If y is the unit number, the fractional part is zero.\\n if (y == uUNIT) {\\n return wrap(resultUint);\\n }\\n\\n // Calculate the fractional part via the iterative approximation.\\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\\n uint256 DOUBLE_UNIT = 2e18;\\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\\n y = (y * y) / uUNIT;\\n\\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\\n if (y >= DOUBLE_UNIT) {\\n // Add the 2^{-m} factor to the logarithm.\\n resultUint += delta;\\n\\n // Halve y, which corresponds to z/2 in the Wikipedia article.\\n y >>= 1;\\n }\\n }\\n result = wrap(resultUint);\\n }\\n}\\n\\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\\n///\\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n///\\n/// @dev See the documentation in {Common.mulDiv18}.\\n/// @param x The multiplicand as a UD60x18 number.\\n/// @param y The multiplier as a UD60x18 number.\\n/// @return result The product as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\\n}\\n\\n/// @notice Raises x to the power of y.\\n///\\n/// For $1 \\\\leq x \\\\leq \\\\infty$, the following standard formula is used:\\n///\\n/// $$\\n/// x^y = 2^{log_2{x} * y}\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\\n///\\n/// $$\\n/// i = \\\\frac{1}{x}\\n/// w = 2^{log_2{i} * y}\\n/// x^y = \\\\frac{1}{w}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2} and {mul}.\\n/// - Returns `UNIT` for 0^0.\\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\\n///\\n/// @param x The base as a UD60x18 number.\\n/// @param y The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n\\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\\n if (xUint == 0) {\\n return yUint == 0 ? UNIT : ZERO;\\n }\\n // If x is `UNIT`, the result is always `UNIT`.\\n else if (xUint == uUNIT) {\\n return UNIT;\\n }\\n\\n // If y is zero, the result is always `UNIT`.\\n if (yUint == 0) {\\n return UNIT;\\n }\\n // If y is `UNIT`, the result is always x.\\n else if (yUint == uUNIT) {\\n return x;\\n }\\n\\n // If x is greater than `UNIT`, use the standard formula.\\n if (xUint > uUNIT) {\\n result = exp2(mul(log2(x), y));\\n }\\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\\n else {\\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\\n UD60x18 w = exp2(mul(log2(i), y));\\n result = wrap(uUNIT_SQUARED / w.unwrap());\\n }\\n}\\n\\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\\n/// algorithm \\\"exponentiation by squaring\\\".\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - The result must fit in UD60x18.\\n///\\n/// @param x The base as a UD60x18 number.\\n/// @param y The exponent as a uint256.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\\n // Calculate the first iteration of the loop in advance.\\n uint256 xUint = x.unwrap();\\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\\n\\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\\n for (y >>= 1; y > 0; y >>= 1) {\\n xUint = Common.mulDiv18(xUint, xUint);\\n\\n // Equivalent to `y % 2 == 1`.\\n if (y & 1 > 0) {\\n resultUint = Common.mulDiv18(resultUint, xUint);\\n }\\n }\\n result = wrap(resultUint);\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must be less than `MAX_UD60x18 / UNIT`.\\n///\\n/// @param x The UD60x18 number for which to calculate the square root.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n unchecked {\\n if (xUint > uMAX_UD60x18 / uUNIT) {\\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\\n }\\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\\n // In this case, the two numbers are both the square root.\\n result = wrap(Common.sqrt(xUint * uUNIT));\\n }\\n}\\n\",\"keccak256\":\"0x462144667aac3f96d5f8dba7aa68fe4c5a3f61e1d7bbbc81bee21168817f9c09\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\nimport \\\"./Helpers.sol\\\" as Helpers;\\nimport \\\"./Math.sol\\\" as Math;\\n\\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\\n/// @dev The value type is defined here so it can be imported in all other files.\\ntype UD60x18 is uint256;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD1x18,\\n Casting.intoUD2x18,\\n Casting.intoSD59x18,\\n Casting.intoUint128,\\n Casting.intoUint256,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes the functions in this library callable on the UD60x18 type.\\nusing {\\n Math.avg,\\n Math.ceil,\\n Math.div,\\n Math.exp,\\n Math.exp2,\\n Math.floor,\\n Math.frac,\\n Math.gm,\\n Math.inv,\\n Math.ln,\\n Math.log10,\\n Math.log2,\\n Math.mul,\\n Math.pow,\\n Math.powu,\\n Math.sqrt\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n HELPER FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes the functions in this library callable on the UD60x18 type.\\nusing {\\n Helpers.add,\\n Helpers.and,\\n Helpers.eq,\\n Helpers.gt,\\n Helpers.gte,\\n Helpers.isZero,\\n Helpers.lshift,\\n Helpers.lt,\\n Helpers.lte,\\n Helpers.mod,\\n Helpers.neq,\\n Helpers.not,\\n Helpers.or,\\n Helpers.rshift,\\n Helpers.sub,\\n Helpers.uncheckedAdd,\\n Helpers.uncheckedSub,\\n Helpers.xor\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n OPERATORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes it possible to use these operators on the UD60x18 type.\\nusing {\\n Helpers.add as +,\\n Helpers.and2 as &,\\n Math.div as /,\\n Helpers.eq as ==,\\n Helpers.gt as >,\\n Helpers.gte as >=,\\n Helpers.lt as <,\\n Helpers.lte as <=,\\n Helpers.or as |,\\n Helpers.mod as %,\\n Math.mul as *,\\n Helpers.neq as !=,\\n Helpers.not as ~,\\n Helpers.sub as -,\\n Helpers.xor as ^\\n} for UD60x18 global;\\n\",\"keccak256\":\"0xdd873b5124180d9b71498b3a7fe93b1c08c368bec741f7d5f8e17f78a0b70f31\",\"license\":\"MIT\"},\"contracts/DecentSablierStreamManagement.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.28;\\n\\nimport {Enum} from \\\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\\\";\\nimport {IAvatar} from \\\"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\\\";\\nimport {ISablierV2Lockup} from \\\"./interfaces/sablier/full/ISablierV2Lockup.sol\\\";\\nimport {Lockup} from \\\"./interfaces/sablier/full/types/DataTypes.sol\\\";\\n\\ncontract DecentSablierStreamManagement {\\n string public constant NAME = \\\"DecentSablierStreamManagement\\\";\\n\\n function withdrawMaxFromStream(\\n ISablierV2Lockup sablier,\\n address recipientHatAccount,\\n uint256 streamId,\\n address to\\n ) public {\\n // Check if there are funds to withdraw\\n uint128 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\\n if (withdrawableAmount == 0) {\\n return;\\n }\\n\\n // Proxy the Sablier withdrawMax call through IAvatar (Safe)\\n IAvatar(msg.sender).execTransactionFromModule(\\n recipientHatAccount,\\n 0,\\n abi.encodeWithSignature(\\n \\\"execute(address,uint256,bytes,uint8)\\\",\\n address(sablier),\\n 0,\\n abi.encodeWithSignature(\\n \\\"withdrawMax(uint256,address)\\\",\\n streamId,\\n to\\n ),\\n 0\\n ),\\n Enum.Operation.Call\\n );\\n }\\n\\n function cancelStream(ISablierV2Lockup sablier, uint256 streamId) public {\\n // Check if the stream can be cancelled\\n Lockup.Status streamStatus = sablier.statusOf(streamId);\\n if (\\n streamStatus != Lockup.Status.PENDING &&\\n streamStatus != Lockup.Status.STREAMING\\n ) {\\n return;\\n }\\n\\n IAvatar(msg.sender).execTransactionFromModule(\\n address(sablier),\\n 0,\\n abi.encodeWithSignature(\\\"cancel(uint256)\\\", streamId),\\n Enum.Operation.Call\\n );\\n }\\n}\\n\",\"keccak256\":\"0xf36be7e97936d82de0035b8bda2c53dbc52b9ca3b8efe305540a7632cb6fe6ab\",\"license\":\"MIT\"},\"contracts/interfaces/sablier/full/IAdminable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\n/// @title IAdminable\\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\\n/// in the constructor.\\ninterface IAdminable {\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin is transferred.\\n /// @param oldAdmin The address of the old admin.\\n /// @param newAdmin The address of the new admin.\\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice The address of the admin account or contract.\\n function admin() external view returns (address);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Transfers the contract admin to a new address.\\n ///\\n /// @dev Notes:\\n /// - Does not revert if the admin is the same.\\n /// - This function can potentially leave the contract without an admin, thereby removing any\\n /// functionality that is only available to the admin.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newAdmin The address of the new admin.\\n function transferAdmin(address newAdmin) external;\\n}\\n\",\"keccak256\":\"0xa279c49e51228b571329164e36250e82b2c1378e8b549194ab7dd90fca9c3b2b\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/IERC4096.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4906.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC165} from \\\"@openzeppelin/contracts/interfaces/IERC165.sol\\\";\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\n/// @title ERC-721 Metadata Update Extension\\ninterface IERC4906 is IERC165, IERC721 {\\n /// @dev This event emits when the metadata of a token is changed.\\n /// So that the third-party platforms such as NFT market could\\n /// timely update the images and related attributes of the NFT.\\n event MetadataUpdate(uint256 _tokenId);\\n\\n /// @dev This event emits when the metadata of a range of tokens is changed.\\n /// So that the third-party platforms such as NFT market could\\n /// timely update the images and related attributes of the NFTs.\\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\\n}\\n\",\"keccak256\":\"0xa34b9c52cbe36be860244f52256f1b05badf0cb797d208664b87337610d0e82d\",\"license\":\"MIT\"},\"contracts/interfaces/sablier/full/ISablierV2Lockup.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC4906} from \\\"./IERC4096.sol\\\";\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {IERC721Metadata} from \\\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\\\";\\nimport {UD60x18} from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\nimport {Lockup} from \\\"./types/DataTypes.sol\\\";\\nimport {IAdminable} from \\\"./IAdminable.sol\\\";\\nimport {ISablierV2NFTDescriptor} from \\\"./ISablierV2NFTDescriptor.sol\\\";\\n\\n/// @title ISablierV2Lockup\\n/// @notice Common logic between all Sablier V2 Lockup contracts.\\ninterface ISablierV2Lockup is\\n IAdminable, // 0 inherited components\\n IERC4906, // 2 inherited components\\n IERC721Metadata // 2 inherited components\\n{\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin allows a new recipient contract to hook to Sablier.\\n /// @param admin The address of the current contract admin.\\n /// @param recipient The address of the recipient contract put on the allowlist.\\n event AllowToHook(address indexed admin, address recipient);\\n\\n /// @notice Emitted when a stream is canceled.\\n /// @param streamId The ID of the stream.\\n /// @param sender The address of the stream's sender.\\n /// @param recipient The address of the stream's recipient.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\\n /// decimals.\\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\\n /// asset's decimals.\\n event CancelLockupStream(\\n uint256 streamId,\\n address indexed sender,\\n address indexed recipient,\\n IERC20 indexed asset,\\n uint128 senderAmount,\\n uint128 recipientAmount\\n );\\n\\n /// @notice Emitted when a sender gives up the right to cancel a stream.\\n /// @param streamId The ID of the stream.\\n event RenounceLockupStream(uint256 indexed streamId);\\n\\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\\n /// @param admin The address of the current contract admin.\\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\\n event SetNFTDescriptor(\\n address indexed admin,\\n ISablierV2NFTDescriptor oldNFTDescriptor,\\n ISablierV2NFTDescriptor newNFTDescriptor\\n );\\n\\n /// @notice Emitted when assets are withdrawn from a stream.\\n /// @param streamId The ID of the stream.\\n /// @param to The address that has received the withdrawn assets.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\\n event WithdrawFromLockupStream(\\n uint256 indexed streamId,\\n address indexed to,\\n IERC20 indexed asset,\\n uint128 amount\\n );\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Retrieves the address of the ERC-20 asset to be distributed.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\\n\\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getDepositedAmount(\\n uint256 streamId\\n ) external view returns (uint128 depositedAmount);\\n\\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getEndTime(\\n uint256 streamId\\n ) external view returns (uint40 endTime);\\n\\n /// @notice Retrieves the stream's recipient.\\n /// @dev Reverts if the NFT has been burned.\\n /// @param streamId The stream ID for the query.\\n function getRecipient(\\n uint256 streamId\\n ) external view returns (address recipient);\\n\\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\\n /// decimals. This amount is always zero unless the stream was canceled.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getRefundedAmount(\\n uint256 streamId\\n ) external view returns (uint128 refundedAmount);\\n\\n /// @notice Retrieves the stream's sender.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getSender(uint256 streamId) external view returns (address sender);\\n\\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getStartTime(\\n uint256 streamId\\n ) external view returns (uint40 startTime);\\n\\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getWithdrawnAmount(\\n uint256 streamId\\n ) external view returns (uint128 withdrawnAmount);\\n\\n /// @notice Retrieves a flag indicating whether the provided address is a contract allowed to hook to Sablier\\n /// when a stream is canceled or when assets are withdrawn.\\n /// @dev See {ISablierLockupRecipient} for more information.\\n function isAllowedToHook(\\n address recipient\\n ) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\\n /// flag is always `false`.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isCancelable(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isCold(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is depleted.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isDepleted(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream exists.\\n /// @dev Does not revert if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isStream(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isTransferable(\\n uint256 streamId\\n ) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isWarm(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves the maximum broker fee that can be charged by the broker, denoted as a fixed-point\\n /// number where 1e18 is 100%.\\n /// @dev This value is hard coded as a constant.\\n function MAX_BROKER_FEE() external view returns (UD60x18);\\n\\n /// @notice Counter for stream IDs, used in the create functions.\\n function nextStreamId() external view returns (uint256);\\n\\n /// @notice Contract that generates the non-fungible token URI.\\n function nftDescriptor() external view returns (ISablierV2NFTDescriptor);\\n\\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\\n /// of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function refundableAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 refundableAmount);\\n\\n /// @notice Retrieves the stream's status.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function statusOf(\\n uint256 streamId\\n ) external view returns (Lockup.Status status);\\n\\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n ///\\n /// Notes:\\n /// - Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\\n /// to the total amount withdrawn.\\n ///\\n /// @param streamId The stream ID for the query.\\n function streamedAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 streamedAmount);\\n\\n /// @notice Retrieves a flag indicating whether the stream was canceled.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function wasCanceled(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\\n /// decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function withdrawableAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 withdrawableAmount);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Allows a recipient contract to hook to Sablier when a stream is canceled or when assets are withdrawn.\\n /// Useful for implementing contracts that hold streams on behalf of users, such as vaults or staking contracts.\\n ///\\n /// @dev Emits an {AllowToHook} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the contract is already on the allowlist.\\n /// - This is an irreversible operation. The contract cannot be removed from the allowlist.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n /// - `recipient` must have a non-zero code size.\\n /// - `recipient` must implement {ISablierLockupRecipient}.\\n ///\\n /// @param recipient The address of the contract to allow for hooks.\\n function allowToHook(address recipient) external;\\n\\n /// @notice Burns the NFT associated with the stream.\\n ///\\n /// @dev Emits a {Transfer} event.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must reference a depleted stream.\\n /// - The NFT must exist.\\n /// - `msg.sender` must be either the NFT owner or an approved third party.\\n ///\\n /// @param streamId The ID of the stream NFT to burn.\\n function burn(uint256 streamId) external;\\n\\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\\n ///\\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\\n /// stream is marked as depleted.\\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - The stream must be warm and cancelable.\\n /// - `msg.sender` must be the stream's sender.\\n ///\\n /// @param streamId The ID of the stream to cancel.\\n function cancel(uint256 streamId) external;\\n\\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\\n ///\\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\\n ///\\n /// Notes:\\n /// - Refer to the notes in {cancel}.\\n ///\\n /// Requirements:\\n /// - All requirements from {cancel} must be met for each stream.\\n ///\\n /// @param streamIds The IDs of the streams to cancel.\\n function cancelMultiple(uint256[] calldata streamIds) external;\\n\\n /// @notice Removes the right of the stream's sender to cancel the stream.\\n ///\\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - This is an irreversible operation.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must reference a warm stream.\\n /// - `msg.sender` must be the stream's sender.\\n /// - The stream must be cancelable.\\n ///\\n /// @param streamId The ID of the stream to renounce.\\n function renounce(uint256 streamId) external;\\n\\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\\n ///\\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the NFT descriptor is the same.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\\n function setNFTDescriptor(\\n ISablierV2NFTDescriptor newNFTDescriptor\\n ) external;\\n\\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\\n ///\\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - This function attempts to call a hook on the recipient of the stream, unless `msg.sender` is the recipient.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must not reference a null or depleted stream.\\n /// - `to` must not be the zero address.\\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\\n /// - `to` must be the recipient if `msg.sender` is not the stream's recipient or an approved third party.\\n ///\\n /// @param streamId The ID of the stream to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\\n function withdraw(uint256 streamId, address to, uint128 amount) external;\\n\\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\\n ///\\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - Refer to the notes in {withdraw}.\\n ///\\n /// Requirements:\\n /// - Refer to the requirements in {withdraw}.\\n ///\\n /// @param streamId The ID of the stream to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\\n function withdrawMax(\\n uint256 streamId,\\n address to\\n ) external returns (uint128 withdrawnAmount);\\n\\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\\n /// NFT to `newRecipient`.\\n ///\\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\\n ///\\n /// Notes:\\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\\n /// - Refer to the notes in {withdraw}.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the stream's recipient.\\n /// - Refer to the requirements in {withdraw}.\\n /// - Refer to the requirements in {IERC721.transferFrom}.\\n ///\\n /// @param streamId The ID of the stream NFT to transfer.\\n /// @param newRecipient The address of the new owner of the stream NFT.\\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\\n function withdrawMaxAndTransfer(\\n uint256 streamId,\\n address newRecipient\\n ) external returns (uint128 withdrawnAmount);\\n\\n /// @notice Withdraws assets from streams to the recipient of each stream.\\n ///\\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\\n ///\\n /// Notes:\\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - There must be an equal number of `streamIds` and `amounts`.\\n /// - Each stream ID in the array must not reference a null or depleted stream.\\n /// - Each amount in the array must be greater than zero and must not exceed the withdrawable amount.\\n ///\\n /// @param streamIds The IDs of the streams to withdraw from.\\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\\n function withdrawMultiple(\\n uint256[] calldata streamIds,\\n uint128[] calldata amounts\\n ) external;\\n}\\n\",\"keccak256\":\"0x3e5541c38a901637bd310965deb5bbde73ef07fe4ee3c752cbec330c6b9d62a3\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/ISablierV2NFTDescriptor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC721Metadata} from \\\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\\\";\\n\\n/// @title ISablierV2NFTDescriptor\\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\\n/// @dev Inspired by Uniswap V3 Positions NFTs.\\ninterface ISablierV2NFTDescriptor {\\n /// @notice Produces the URI describing a particular stream NFT.\\n /// @dev This is a data URI with the JSON contents directly inlined.\\n /// @param sablier The address of the Sablier contract the stream was created in.\\n /// @param streamId The ID of the stream for which to produce a description.\\n /// @return uri The URI of the ERC721-compliant metadata.\\n function tokenURI(\\n IERC721Metadata sablier,\\n uint256 streamId\\n ) external view returns (string memory uri);\\n}\\n\",\"keccak256\":\"0x4ed430e553d14161e93efdaaacd1a502f49b38969c9d714b45d2e682a74fa0bc\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/types/DataTypes.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {UD2x18} from \\\"@prb/math/src/UD2x18.sol\\\";\\nimport {UD60x18} from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\n// DataTypes.sol\\n//\\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\\n//\\n// - Lockup\\n// - LockupDynamic\\n// - LockupLinear\\n// - LockupTranched\\n//\\n// You will notice that some structs contain \\\"slot\\\" annotations - they are used to indicate the\\n// storage layout of the struct. It is more gas efficient to group small data types together so\\n// that they fit in a single 32-byte slot.\\n\\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\\n/// @param account The address receiving the broker's fee.\\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\\nstruct Broker {\\n address account;\\n UD60x18 fee;\\n}\\n\\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\\nlibrary Lockup {\\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the asset's\\n /// decimals.\\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in the same slot\\n /// saves gas.\\n /// @param deposited The initial amount deposited in the stream, net of broker fee.\\n /// @param withdrawn The cumulative amount withdrawn from the stream.\\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\\n struct Amounts {\\n // slot 0\\n uint128 deposited;\\n uint128 withdrawn;\\n // slot 1\\n uint128 refunded;\\n }\\n\\n /// @notice Struct encapsulating (i) the deposit amount and (ii) the broker fee amount, both denoted in units of the\\n /// asset's decimals.\\n /// @param deposit The amount to deposit in the stream.\\n /// @param brokerFee The broker fee amount.\\n struct CreateAmounts {\\n uint128 deposit;\\n uint128 brokerFee;\\n }\\n\\n /// @notice Enum representing the different statuses of a stream.\\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\\n enum Status {\\n PENDING,\\n STREAMING,\\n SETTLED,\\n CANCELED,\\n DEPLETED\\n }\\n\\n /// @notice A common data structure to be stored in all {SablierV2Lockup} models.\\n /// @dev The fields are arranged like this to save gas via tight variable packing.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param endTime The Unix timestamp indicating the stream's end.\\n /// @param isCancelable Boolean indicating if the stream is cancelable.\\n /// @param wasCanceled Boolean indicating if the stream was canceled.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param isDepleted Boolean indicating if the stream is depleted.\\n /// @param isStream Boolean indicating if the struct entity exists.\\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\\n /// @param amounts Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the\\n /// asset's decimals.\\n struct Stream {\\n // slot 0\\n address sender;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n // slot 1\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n // slot 2 and 3\\n Lockup.Amounts amounts;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\\nlibrary LockupDynamic {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param segments Segments with durations used to compose the dynamic distribution function. Timestamps are\\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n SegmentWithDuration[] segments;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param segments Segments used to compose the dynamic distribution function.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n uint40 startTime;\\n Segment[] segments;\\n Broker broker;\\n }\\n\\n /// @notice Segment struct used in the Lockup Dynamic stream.\\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\\n /// @param timestamp The Unix timestamp indicating the segment's end.\\n struct Segment {\\n // slot 0\\n uint128 amount;\\n UD2x18 exponent;\\n uint40 timestamp;\\n }\\n\\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDurations}.\\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\\n /// @param duration The time difference in seconds between the segment and the previous one.\\n struct SegmentWithDuration {\\n uint128 amount;\\n UD2x18 exponent;\\n uint40 duration;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the segments.\\n struct StreamLD {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n Segment[] segments;\\n }\\n\\n /// @notice Struct encapsulating the LockupDynamic timestamps.\\n /// @param start The Unix timestamp indicating the stream's start.\\n /// @param end The Unix timestamp indicating the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 end;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\\nlibrary LockupLinear {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param durations Struct encapsulating (i) cliff period duration and (ii) total stream duration, both in seconds.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n Durations durations;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param timestamps Struct encapsulating (i) the stream's start time, (ii) cliff time, and (iii) end time, all as\\n /// Unix timestamps.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n Timestamps timestamps;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the cliff duration and the total duration.\\n /// @param cliff The cliff duration in seconds.\\n /// @param total The total duration in seconds.\\n struct Durations {\\n uint40 cliff;\\n uint40 total;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the cliff time.\\n struct StreamLL {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n uint40 endTime;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n uint40 cliffTime;\\n }\\n\\n /// @notice Struct encapsulating the LockupLinear timestamps.\\n /// @param start The Unix timestamp for the stream's start.\\n /// @param cliff The Unix timestamp for the cliff period's end. A value of zero means there is no cliff.\\n /// @param end The Unix timestamp for the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 cliff;\\n uint40 end;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupTranched}.\\nlibrary LockupTranched {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param tranches Tranches with durations used to compose the tranched distribution function. Timestamps are\\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n TrancheWithDuration[] tranches;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param tranches Tranches used to compose the tranched distribution function.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n uint40 startTime;\\n Tranche[] tranches;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the tranches.\\n struct StreamLT {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n Tranche[] tranches;\\n }\\n\\n /// @notice Struct encapsulating the LockupTranched timestamps.\\n /// @param start The Unix timestamp indicating the stream's start.\\n /// @param end The Unix timestamp indicating the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 end;\\n }\\n\\n /// @notice Tranche struct used in the Lockup Tranched stream.\\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\\n /// @param timestamp The Unix timestamp indicating the tranche's end.\\n struct Tranche {\\n // slot 0\\n uint128 amount;\\n uint40 timestamp;\\n }\\n\\n /// @notice Tranche struct used at runtime in {SablierV2LockupTranched.createWithDurations}.\\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\\n /// @param duration The time difference in seconds between the tranche and the previous one.\\n struct TrancheWithDuration {\\n uint128 amount;\\n uint40 duration;\\n }\\n}\\n\",\"keccak256\":\"0x727722c0ec71a76a947b935c9dfcac8fd846d6c3547dfbc8739c7109f3b95068\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", + "bytecode": "0x6080604052348015600f57600080fd5b506105fe8061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80636778d4b0146100465780637dc14a8e1461005b578063a3f4df7e1461006e575b600080fd5b6100596100543660046103d0565b6100c0565b005b610059610069366004610423565b610256565b6100aa6040518060400160405280601d81526020017f446563656e745361626c69657253747265616d4d616e6167656d656e7400000081525081565b6040516100b79190610495565b60405180910390f35b60405163d975dfed60e01b8152600481018390526000906001600160a01b0386169063d975dfed90602401602060405180830381865afa158015610108573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012c91906104af565b9050806001600160801b03166000036101455750610250565b336001600160a01b031663468721a7856000886000888860405160240161017f9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529181526020820180516001600160e01b031663ea5ead1960e01b179052516101bc939291906000906024016104d8565b60408051601f198184030181529181526020820180516001600160e01b0316635194544760e01b1790525160e085901b6001600160e01b031916815261020a9392919060009060040161052f565b6020604051808303816000875af1158015610229573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024d9190610585565b50505b50505050565b604051632b4d7bf560e21b8152600481018290526000906001600160a01b0384169063ad35efd490602401602060405180830381865afa15801561029e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c291906105a7565b905060008160048111156102d8576102d8610519565b141580156102f8575060018160048111156102f5576102f5610519565b14155b1561030257505050565b336001600160a01b031663468721a78460008560405160240161032791815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166340e58ee560e01b1790525160e085901b6001600160e01b03191681526103759392919060009060040161052f565b6020604051808303816000875af1158015610394573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102509190610585565b6001600160a01b03811681146103cd57600080fd5b50565b600080600080608085870312156103e657600080fd5b84356103f1816103b8565b93506020850135610401816103b8565b9250604085013591506060850135610418816103b8565b939692955090935050565b6000806040838503121561043657600080fd5b8235610441816103b8565b946020939093013593505050565b6000815180845260005b8181101561047557602081850181015186830182015201610459565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006104a8602083018461044f565b9392505050565b6000602082840312156104c157600080fd5b81516001600160801b03811681146104a857600080fd5b6001600160a01b038516815260ff841660208201526080604082018190526000906105059083018561044f565b905060ff8316606083015295945050505050565b634e487b7160e01b600052602160045260246000fd5b60018060a01b0385168152836020820152608060408201526000610556608083018561044f565b90506002831061057657634e487b7160e01b600052602160045260246000fd5b82606083015295945050505050565b60006020828403121561059757600080fd5b815180151581146104a857600080fd5b6000602082840312156105b957600080fd5b8151600581106104a857600080fdfea2646970667358221220c473750d62fe01ec9f421a499df8738e767b4a5341626c81a992fcdb3ee192de64736f6c634300081c0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80636778d4b0146100465780637dc14a8e1461005b578063a3f4df7e1461006e575b600080fd5b6100596100543660046103d0565b6100c0565b005b610059610069366004610423565b610256565b6100aa6040518060400160405280601d81526020017f446563656e745361626c69657253747265616d4d616e6167656d656e7400000081525081565b6040516100b79190610495565b60405180910390f35b60405163d975dfed60e01b8152600481018390526000906001600160a01b0386169063d975dfed90602401602060405180830381865afa158015610108573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012c91906104af565b9050806001600160801b03166000036101455750610250565b336001600160a01b031663468721a7856000886000888860405160240161017f9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529181526020820180516001600160e01b031663ea5ead1960e01b179052516101bc939291906000906024016104d8565b60408051601f198184030181529181526020820180516001600160e01b0316635194544760e01b1790525160e085901b6001600160e01b031916815261020a9392919060009060040161052f565b6020604051808303816000875af1158015610229573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024d9190610585565b50505b50505050565b604051632b4d7bf560e21b8152600481018290526000906001600160a01b0384169063ad35efd490602401602060405180830381865afa15801561029e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c291906105a7565b905060008160048111156102d8576102d8610519565b141580156102f8575060018160048111156102f5576102f5610519565b14155b1561030257505050565b336001600160a01b031663468721a78460008560405160240161032791815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166340e58ee560e01b1790525160e085901b6001600160e01b03191681526103759392919060009060040161052f565b6020604051808303816000875af1158015610394573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102509190610585565b6001600160a01b03811681146103cd57600080fd5b50565b600080600080608085870312156103e657600080fd5b84356103f1816103b8565b93506020850135610401816103b8565b9250604085013591506060850135610418816103b8565b939692955090935050565b6000806040838503121561043657600080fd5b8235610441816103b8565b946020939093013593505050565b6000815180845260005b8181101561047557602081850181015186830182015201610459565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006104a8602083018461044f565b9392505050565b6000602082840312156104c157600080fd5b81516001600160801b03811681146104a857600080fd5b6001600160a01b038516815260ff841660208201526080604082018190526000906105059083018561044f565b905060ff8316606083015295945050505050565b634e487b7160e01b600052602160045260246000fd5b60018060a01b0385168152836020820152608060408201526000610556608083018561044f565b90506002831061057657634e487b7160e01b600052602160045260246000fd5b82606083015295945050505050565b60006020828403121561059757600080fd5b815180151581146104a857600080fd5b6000602082840312156105b957600080fd5b8151600581106104a857600080fdfea2646970667358221220c473750d62fe01ec9f421a499df8738e767b4a5341626c81a992fcdb3ee192de64736f6c634300081c0033", + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/deployments/mainnet/solcInputs/4511b61209438ca20d2458493e70bb24.json b/deployments/mainnet/solcInputs/4511b61209438ca20d2458493e70bb24.json new file mode 100644 index 00000000..c068a9c4 --- /dev/null +++ b/deployments/mainnet/solcInputs/4511b61209438ca20d2458493e70bb24.json @@ -0,0 +1,351 @@ +{ + "language": "Solidity", + "sources": { + "@gnosis.pm/safe-contracts/contracts/base/Executor.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\n\n/// @title Executor - A contract that can execute transactions\n/// @author Richard Meissner - \ncontract Executor {\n function execute(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 txGas\n ) internal returns (bool success) {\n if (operation == Enum.Operation.DelegateCall) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n success := delegatecall(txGas, to, add(data, 0x20), mload(data), 0, 0)\n }\n } else {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n success := call(txGas, to, value, add(data, 0x20), mload(data), 0, 0)\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/FallbackManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../common/SelfAuthorized.sol\";\n\n/// @title Fallback Manager - A contract that manages fallback calls made to this contract\n/// @author Richard Meissner - \ncontract FallbackManager is SelfAuthorized {\n event ChangedFallbackHandler(address handler);\n\n // keccak256(\"fallback_manager.handler.address\")\n bytes32 internal constant FALLBACK_HANDLER_STORAGE_SLOT = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5;\n\n function internalSetFallbackHandler(address handler) internal {\n bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, handler)\n }\n }\n\n /// @dev Allows to add a contract to handle fallback calls.\n /// Only fallback calls without value and with data will be forwarded.\n /// This can only be done via a Safe transaction.\n /// @param handler contract to handle fallbacks calls.\n function setFallbackHandler(address handler) public authorized {\n internalSetFallbackHandler(handler);\n emit ChangedFallbackHandler(handler);\n }\n\n // solhint-disable-next-line payable-fallback,no-complex-fallback\n fallback() external {\n bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let handler := sload(slot)\n if iszero(handler) {\n return(0, 0)\n }\n calldatacopy(0, 0, calldatasize())\n // The msg.sender address is shifted to the left by 12 bytes to remove the padding\n // Then the address without padding is stored right after the calldata\n mstore(calldatasize(), shl(96, caller()))\n // Add 20 bytes for the address appended add the end\n let success := call(gas(), handler, 0, 0, add(calldatasize(), 20), 0, 0)\n returndatacopy(0, 0, returndatasize())\n if iszero(success) {\n revert(0, returndatasize())\n }\n return(0, returndatasize())\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/GuardManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\n\ninterface Guard {\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external;\n\n function checkAfterExecution(bytes32 txHash, bool success) external;\n}\n\n/// @title Fallback Manager - A contract that manages fallback calls made to this contract\n/// @author Richard Meissner - \ncontract GuardManager is SelfAuthorized {\n event ChangedGuard(address guard);\n // keccak256(\"guard_manager.guard.address\")\n bytes32 internal constant GUARD_STORAGE_SLOT = 0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8;\n\n /// @dev Set a guard that checks transactions before execution\n /// @param guard The address of the guard to be used or the 0 address to disable the guard\n function setGuard(address guard) external authorized {\n bytes32 slot = GUARD_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, guard)\n }\n emit ChangedGuard(guard);\n }\n\n function getGuard() internal view returns (address guard) {\n bytes32 slot = GUARD_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n guard := sload(slot)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/ModuleManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\nimport \"./Executor.sol\";\n\n/// @title Module Manager - A contract that manages modules that can execute transactions via this contract\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract ModuleManager is SelfAuthorized, Executor {\n event EnabledModule(address module);\n event DisabledModule(address module);\n event ExecutionFromModuleSuccess(address indexed module);\n event ExecutionFromModuleFailure(address indexed module);\n\n address internal constant SENTINEL_MODULES = address(0x1);\n\n mapping(address => address) internal modules;\n\n function setupModules(address to, bytes memory data) internal {\n require(modules[SENTINEL_MODULES] == address(0), \"GS100\");\n modules[SENTINEL_MODULES] = SENTINEL_MODULES;\n if (to != address(0))\n // Setup has to complete successfully or transaction fails.\n require(execute(to, 0, data, Enum.Operation.DelegateCall, gasleft()), \"GS000\");\n }\n\n /// @dev Allows to add a module to the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Enables the module `module` for the Safe.\n /// @param module Module to be whitelisted.\n function enableModule(address module) public authorized {\n // Module address cannot be null or sentinel.\n require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n // Module cannot be added twice.\n require(modules[module] == address(0), \"GS102\");\n modules[module] = modules[SENTINEL_MODULES];\n modules[SENTINEL_MODULES] = module;\n emit EnabledModule(module);\n }\n\n /// @dev Allows to remove a module from the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Disables the module `module` for the Safe.\n /// @param prevModule Module that pointed to the module to be removed in the linked list\n /// @param module Module to be removed.\n function disableModule(address prevModule, address module) public authorized {\n // Validate module address and check that it corresponds to module index.\n require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n require(modules[prevModule] == module, \"GS103\");\n modules[prevModule] = modules[module];\n modules[module] = address(0);\n emit DisabledModule(module);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public virtual returns (bool success) {\n // Only whitelisted modules are allowed.\n require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), \"GS104\");\n // Execute transaction without further confirmations.\n success = execute(to, value, data, operation, gasleft());\n if (success) emit ExecutionFromModuleSuccess(msg.sender);\n else emit ExecutionFromModuleFailure(msg.sender);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModuleReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public returns (bool success, bytes memory returnData) {\n success = execTransactionFromModule(to, value, data, operation);\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // Load free memory location\n let ptr := mload(0x40)\n // We allocate memory for the return data by setting the free memory location to\n // current free memory location + data size + 32 bytes for data size value\n mstore(0x40, add(ptr, add(returndatasize(), 0x20)))\n // Store the size\n mstore(ptr, returndatasize())\n // Store the data\n returndatacopy(add(ptr, 0x20), 0, returndatasize())\n // Point the return data to the correct memory location\n returnData := ptr\n }\n }\n\n /// @dev Returns if an module is enabled\n /// @return True if the module is enabled\n function isModuleEnabled(address module) public view returns (bool) {\n return SENTINEL_MODULES != module && modules[module] != address(0);\n }\n\n /// @dev Returns array of modules.\n /// @param start Start of the page.\n /// @param pageSize Maximum number of modules that should be returned.\n /// @return array Array of modules.\n /// @return next Start of the next page.\n function getModulesPaginated(address start, uint256 pageSize) external view returns (address[] memory array, address next) {\n // Init array with max page size\n array = new address[](pageSize);\n\n // Populate return array\n uint256 moduleCount = 0;\n address currentModule = modules[start];\n while (currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {\n array[moduleCount] = currentModule;\n currentModule = modules[currentModule];\n moduleCount++;\n }\n next = currentModule;\n // Set correct size of returned array\n // solhint-disable-next-line no-inline-assembly\n assembly {\n mstore(array, moduleCount)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/OwnerManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/SelfAuthorized.sol\";\n\n/// @title OwnerManager - Manages a set of owners and a threshold to perform actions.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract OwnerManager is SelfAuthorized {\n event AddedOwner(address owner);\n event RemovedOwner(address owner);\n event ChangedThreshold(uint256 threshold);\n\n address internal constant SENTINEL_OWNERS = address(0x1);\n\n mapping(address => address) internal owners;\n uint256 internal ownerCount;\n uint256 internal threshold;\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n function setupOwners(address[] memory _owners, uint256 _threshold) internal {\n // Threshold can only be 0 at initialization.\n // Check ensures that setup function can only be called once.\n require(threshold == 0, \"GS200\");\n // Validate that threshold is smaller than number of added owners.\n require(_threshold <= _owners.length, \"GS201\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"GS202\");\n // Initializing Safe owners.\n address currentOwner = SENTINEL_OWNERS;\n for (uint256 i = 0; i < _owners.length; i++) {\n // Owner address cannot be null.\n address owner = _owners[i];\n require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, \"GS203\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"GS204\");\n owners[currentOwner] = owner;\n currentOwner = owner;\n }\n owners[currentOwner] = SENTINEL_OWNERS;\n ownerCount = _owners.length;\n threshold = _threshold;\n }\n\n /// @dev Allows to add a new owner to the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.\n /// @param owner New owner address.\n /// @param _threshold New threshold.\n function addOwnerWithThreshold(address owner, uint256 _threshold) public authorized {\n // Owner address cannot be null, the sentinel or the Safe itself.\n require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), \"GS203\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"GS204\");\n owners[owner] = owners[SENTINEL_OWNERS];\n owners[SENTINEL_OWNERS] = owner;\n ownerCount++;\n emit AddedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold) changeThreshold(_threshold);\n }\n\n /// @dev Allows to remove an owner from the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.\n /// @param prevOwner Owner that pointed to the owner to be removed in the linked list\n /// @param owner Owner address to be removed.\n /// @param _threshold New threshold.\n function removeOwner(\n address prevOwner,\n address owner,\n uint256 _threshold\n ) public authorized {\n // Only allow to remove an owner, if threshold can still be reached.\n require(ownerCount - 1 >= _threshold, \"GS201\");\n // Validate owner address and check that it corresponds to owner index.\n require(owner != address(0) && owner != SENTINEL_OWNERS, \"GS203\");\n require(owners[prevOwner] == owner, \"GS205\");\n owners[prevOwner] = owners[owner];\n owners[owner] = address(0);\n ownerCount--;\n emit RemovedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold) changeThreshold(_threshold);\n }\n\n /// @dev Allows to swap/replace an owner from the Safe with another address.\n /// This can only be done via a Safe transaction.\n /// @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.\n /// @param prevOwner Owner that pointed to the owner to be replaced in the linked list\n /// @param oldOwner Owner address to be replaced.\n /// @param newOwner New owner address.\n function swapOwner(\n address prevOwner,\n address oldOwner,\n address newOwner\n ) public authorized {\n // Owner address cannot be null, the sentinel or the Safe itself.\n require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), \"GS203\");\n // No duplicate owners allowed.\n require(owners[newOwner] == address(0), \"GS204\");\n // Validate oldOwner address and check that it corresponds to owner index.\n require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, \"GS203\");\n require(owners[prevOwner] == oldOwner, \"GS205\");\n owners[newOwner] = owners[oldOwner];\n owners[prevOwner] = newOwner;\n owners[oldOwner] = address(0);\n emit RemovedOwner(oldOwner);\n emit AddedOwner(newOwner);\n }\n\n /// @dev Allows to update the number of required confirmations by Safe owners.\n /// This can only be done via a Safe transaction.\n /// @notice Changes the threshold of the Safe to `_threshold`.\n /// @param _threshold New threshold.\n function changeThreshold(uint256 _threshold) public authorized {\n // Validate that threshold is smaller than number of owners.\n require(_threshold <= ownerCount, \"GS201\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"GS202\");\n threshold = _threshold;\n emit ChangedThreshold(threshold);\n }\n\n function getThreshold() public view returns (uint256) {\n return threshold;\n }\n\n function isOwner(address owner) public view returns (bool) {\n return owner != SENTINEL_OWNERS && owners[owner] != address(0);\n }\n\n /// @dev Returns array of owners.\n /// @return Array of Safe owners.\n function getOwners() public view returns (address[] memory) {\n address[] memory array = new address[](ownerCount);\n\n // populate return array\n uint256 index = 0;\n address currentOwner = owners[SENTINEL_OWNERS];\n while (currentOwner != SENTINEL_OWNERS) {\n array[index] = currentOwner;\n currentOwner = owners[currentOwner];\n index++;\n }\n return array;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/Enum.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Enum - Collection of enums\n/// @author Richard Meissner - \ncontract Enum {\n enum Operation {Call, DelegateCall}\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/EtherPaymentFallback.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title EtherPaymentFallback - A contract that has a fallback to accept ether payments\n/// @author Richard Meissner - \ncontract EtherPaymentFallback {\n event SafeReceived(address indexed sender, uint256 value);\n\n /// @dev Fallback function accepts Ether transactions.\n receive() external payable {\n emit SafeReceived(msg.sender, msg.value);\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SecuredTokenTransfer.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SecuredTokenTransfer - Secure token transfer\n/// @author Richard Meissner - \ncontract SecuredTokenTransfer {\n /// @dev Transfers a token and returns if it was a success\n /// @param token Token that should be transferred\n /// @param receiver Receiver to whom the token should be transferred\n /// @param amount The amount of tokens that should be transferred\n function transferToken(\n address token,\n address receiver,\n uint256 amount\n ) internal returns (bool transferred) {\n // 0xa9059cbb - keccack(\"transfer(address,uint256)\")\n bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // We write the return value to scratch space.\n // See https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory\n let success := call(sub(gas(), 10000), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n switch returndatasize()\n case 0 {\n transferred := success\n }\n case 0x20 {\n transferred := iszero(or(iszero(success), iszero(mload(0))))\n }\n default {\n transferred := 0\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SelfAuthorized.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SelfAuthorized - authorizes current contract to perform actions\n/// @author Richard Meissner - \ncontract SelfAuthorized {\n function requireSelfCall() private view {\n require(msg.sender == address(this), \"GS031\");\n }\n\n modifier authorized() {\n // This is a function call as it minimized the bytecode size\n requireSelfCall();\n _;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SignatureDecoder.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SignatureDecoder - Decodes signatures that a encoded as bytes\n/// @author Richard Meissner - \ncontract SignatureDecoder {\n /// @dev divides bytes signature into `uint8 v, bytes32 r, bytes32 s`.\n /// @notice Make sure to peform a bounds check for @param pos, to avoid out of bounds access on @param signatures\n /// @param pos which signature to read. A prior bounds check of this parameter should be performed, to avoid out of bounds access\n /// @param signatures concatenated rsv signatures\n function signatureSplit(bytes memory signatures, uint256 pos)\n internal\n pure\n returns (\n uint8 v,\n bytes32 r,\n bytes32 s\n )\n {\n // The signature format is a compact form of:\n // {bytes32 r}{bytes32 s}{uint8 v}\n // Compact means, uint8 is not padded to 32 bytes.\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let signaturePos := mul(0x41, pos)\n r := mload(add(signatures, add(signaturePos, 0x20)))\n s := mload(add(signatures, add(signaturePos, 0x40)))\n // Here we are loading the last 32 bytes, including 31 bytes\n // of 's'. There is no 'mload8' to do this.\n //\n // 'byte' is not working due to the Solidity parser, so lets\n // use the second best option, 'and'\n v := and(mload(add(signatures, add(signaturePos, 0x41))), 0xff)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/Singleton.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Singleton - Base for singleton contracts (should always be first super contract)\n/// This contract is tightly coupled to our proxy contract (see `proxies/GnosisSafeProxy.sol`)\n/// @author Richard Meissner - \ncontract Singleton {\n // singleton always needs to be first declared variable, to ensure that it is at the same location as in the Proxy contract.\n // It should also always be ensured that the address is stored alone (uses a full word)\n address private singleton;\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/StorageAccessible.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title StorageAccessible - generic base contract that allows callers to access all internal storage.\n/// @notice See https://github.com/gnosis/util-contracts/blob/bb5fe5fb5df6d8400998094fb1b32a178a47c3a1/contracts/StorageAccessible.sol\ncontract StorageAccessible {\n /**\n * @dev Reads `length` bytes of storage in the currents contract\n * @param offset - the offset in the current contract's storage in words to start reading from\n * @param length - the number of words (32 bytes) of data to read\n * @return the bytes that were read.\n */\n function getStorageAt(uint256 offset, uint256 length) public view returns (bytes memory) {\n bytes memory result = new bytes(length * 32);\n for (uint256 index = 0; index < length; index++) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let word := sload(add(offset, index))\n mstore(add(add(result, 0x20), mul(index, 0x20)), word)\n }\n }\n return result;\n }\n\n /**\n * @dev Performs a delegetecall on a targetContract in the context of self.\n * Internally reverts execution to avoid side effects (making it static).\n *\n * This method reverts with data equal to `abi.encode(bool(success), bytes(response))`.\n * Specifically, the `returndata` after a call to this method will be:\n * `success:bool || response.length:uint256 || response:bytes`.\n *\n * @param targetContract Address of the contract containing the code to execute.\n * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).\n */\n function simulateAndRevert(address targetContract, bytes memory calldataPayload) external {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let success := delegatecall(gas(), targetContract, add(calldataPayload, 0x20), mload(calldataPayload), 0, 0)\n\n mstore(0x00, success)\n mstore(0x20, returndatasize())\n returndatacopy(0x40, 0, returndatasize())\n revert(0, add(returndatasize(), 0x40))\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/external/GnosisSafeMath.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title GnosisSafeMath\n * @dev Math operations with safety checks that revert on error\n * Renamed from SafeMath to GnosisSafeMath to avoid conflicts\n * TODO: remove once open zeppelin update to solc 0.5.0\n */\nlibrary GnosisSafeMath {\n /**\n * @dev Multiplies two numbers, reverts on overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b);\n\n return c;\n }\n\n /**\n * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Adds two numbers, reverts on overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a);\n\n return c;\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 a >= b ? a : b;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/GnosisSafe.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./base/ModuleManager.sol\";\nimport \"./base/OwnerManager.sol\";\nimport \"./base/FallbackManager.sol\";\nimport \"./base/GuardManager.sol\";\nimport \"./common/EtherPaymentFallback.sol\";\nimport \"./common/Singleton.sol\";\nimport \"./common/SignatureDecoder.sol\";\nimport \"./common/SecuredTokenTransfer.sol\";\nimport \"./common/StorageAccessible.sol\";\nimport \"./interfaces/ISignatureValidator.sol\";\nimport \"./external/GnosisSafeMath.sol\";\n\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafe is\n EtherPaymentFallback,\n Singleton,\n ModuleManager,\n OwnerManager,\n SignatureDecoder,\n SecuredTokenTransfer,\n ISignatureValidatorConstants,\n FallbackManager,\n StorageAccessible,\n GuardManager\n{\n using GnosisSafeMath for uint256;\n\n string public constant VERSION = \"1.3.0\";\n\n // keccak256(\n // \"EIP712Domain(uint256 chainId,address verifyingContract)\"\n // );\n bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;\n\n // keccak256(\n // \"SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)\"\n // );\n bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;\n\n event SafeSetup(address indexed initiator, address[] owners, uint256 threshold, address initializer, address fallbackHandler);\n event ApproveHash(bytes32 indexed approvedHash, address indexed owner);\n event SignMsg(bytes32 indexed msgHash);\n event ExecutionFailure(bytes32 txHash, uint256 payment);\n event ExecutionSuccess(bytes32 txHash, uint256 payment);\n\n uint256 public nonce;\n bytes32 private _deprecatedDomainSeparator;\n // Mapping to keep track of all message hashes that have been approve by ALL REQUIRED owners\n mapping(bytes32 => uint256) public signedMessages;\n // Mapping to keep track of all hashes (message or transaction) that have been approve by ANY owners\n mapping(address => mapping(bytes32 => uint256)) public approvedHashes;\n\n // This constructor ensures that this contract can only be used as a master copy for Proxy contracts\n constructor() {\n // By setting the threshold it is not possible to call setup anymore,\n // so we create a Safe with 0 owners and threshold 1.\n // This is an unusable Safe, perfect for the singleton\n threshold = 1;\n }\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n /// @param to Contract address for optional delegate call.\n /// @param data Data payload for optional delegate call.\n /// @param fallbackHandler Handler for fallback calls to this contract\n /// @param paymentToken Token that should be used for the payment (0 is ETH)\n /// @param payment Value that should be paid\n /// @param paymentReceiver Adddress that should receive the payment (or 0 if tx.origin)\n function setup(\n address[] calldata _owners,\n uint256 _threshold,\n address to,\n bytes calldata data,\n address fallbackHandler,\n address paymentToken,\n uint256 payment,\n address payable paymentReceiver\n ) external {\n // setupOwners checks if the Threshold is already set, therefore preventing that this method is called twice\n setupOwners(_owners, _threshold);\n if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);\n // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules\n setupModules(to, data);\n\n if (payment > 0) {\n // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)\n // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment\n handlePayment(payment, 0, 1, paymentToken, paymentReceiver);\n }\n emit SafeSetup(msg.sender, _owners, _threshold, to, fallbackHandler);\n }\n\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\n /// Note: The fees are always transferred, even if the user transaction fails.\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @param safeTxGas Gas that should be used for the Safe transaction.\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Gas price that should be used for the payment calculation.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\n function execTransaction(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures\n ) public payable virtual returns (bool success) {\n bytes32 txHash;\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n bytes memory txHashData =\n encodeTransactionData(\n // Transaction info\n to,\n value,\n data,\n operation,\n safeTxGas,\n // Payment info\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n // Signature info\n nonce\n );\n // Increase nonce and execute transaction.\n nonce++;\n txHash = keccak256(txHashData);\n checkSignatures(txHash, txHashData, signatures);\n }\n address guard = getGuard();\n {\n if (guard != address(0)) {\n Guard(guard).checkTransaction(\n // Transaction info\n to,\n value,\n data,\n operation,\n safeTxGas,\n // Payment info\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n // Signature info\n signatures,\n msg.sender\n );\n }\n }\n // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)\n // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150\n require(gasleft() >= ((safeTxGas * 64) / 63).max(safeTxGas + 2500) + 500, \"GS010\");\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n uint256 gasUsed = gasleft();\n // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)\n // We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas\n success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);\n gasUsed = gasUsed.sub(gasleft());\n // If no safeTxGas and no gasPrice was set (e.g. both are 0), then the internal tx is required to be successful\n // This makes it possible to use `estimateGas` without issues, as it searches for the minimum gas where the tx doesn't revert\n require(success || safeTxGas != 0 || gasPrice != 0, \"GS013\");\n // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls\n uint256 payment = 0;\n if (gasPrice > 0) {\n payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);\n }\n if (success) emit ExecutionSuccess(txHash, payment);\n else emit ExecutionFailure(txHash, payment);\n }\n {\n if (guard != address(0)) {\n Guard(guard).checkAfterExecution(txHash, success);\n }\n }\n }\n\n function handlePayment(\n uint256 gasUsed,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver\n ) private returns (uint256 payment) {\n // solhint-disable-next-line avoid-tx-origin\n address payable receiver = refundReceiver == address(0) ? payable(tx.origin) : refundReceiver;\n if (gasToken == address(0)) {\n // For ETH we will only adjust the gas price to not be higher than the actual used gas price\n payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);\n require(receiver.send(payment), \"GS011\");\n } else {\n payment = gasUsed.add(baseGas).mul(gasPrice);\n require(transferToken(gasToken, receiver, payment), \"GS012\");\n }\n }\n\n /**\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n * @param data That should be signed (this is passed to an external validator contract)\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\n */\n function checkSignatures(\n bytes32 dataHash,\n bytes memory data,\n bytes memory signatures\n ) public view {\n // Load threshold to avoid multiple storage loads\n uint256 _threshold = threshold;\n // Check that a threshold is set\n require(_threshold > 0, \"GS001\");\n checkNSignatures(dataHash, data, signatures, _threshold);\n }\n\n /**\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n * @param data That should be signed (this is passed to an external validator contract)\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\n * @param requiredSignatures Amount of required valid signatures.\n */\n function checkNSignatures(\n bytes32 dataHash,\n bytes memory data,\n bytes memory signatures,\n uint256 requiredSignatures\n ) public view {\n // Check that the provided signature data is not too short\n require(signatures.length >= requiredSignatures.mul(65), \"GS020\");\n // There cannot be an owner with address 0.\n address lastOwner = address(0);\n address currentOwner;\n uint8 v;\n bytes32 r;\n bytes32 s;\n uint256 i;\n for (i = 0; i < requiredSignatures; i++) {\n (v, r, s) = signatureSplit(signatures, i);\n if (v == 0) {\n // If v is 0 then it is a contract signature\n // When handling contract signatures the address of the contract is encoded into r\n currentOwner = address(uint160(uint256(r)));\n\n // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes\n // This check is not completely accurate, since it is possible that more signatures than the threshold are send.\n // Here we only check that the pointer is not pointing inside the part that is being processed\n require(uint256(s) >= requiredSignatures.mul(65), \"GS021\");\n\n // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)\n require(uint256(s).add(32) <= signatures.length, \"GS022\");\n\n // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length\n uint256 contractSignatureLen;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n contractSignatureLen := mload(add(add(signatures, s), 0x20))\n }\n require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, \"GS023\");\n\n // Check signature\n bytes memory contractSignature;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s\n contractSignature := add(add(signatures, s), 0x20)\n }\n require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, \"GS024\");\n } else if (v == 1) {\n // If v is 1 then it is an approved hash\n // When handling approved hashes the address of the approver is encoded into r\n currentOwner = address(uint160(uint256(r)));\n // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction\n require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, \"GS025\");\n } else if (v > 30) {\n // If v > 30 then default va (27,28) has been adjusted for eth_sign flow\n // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover\n currentOwner = ecrecover(keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", dataHash)), v - 4, r, s);\n } else {\n // Default is the ecrecover flow with the provided data hash\n // Use ecrecover with the messageHash for EOA signatures\n currentOwner = ecrecover(dataHash, v, r, s);\n }\n require(currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS, \"GS026\");\n lastOwner = currentOwner;\n }\n }\n\n /// @dev Allows to estimate a Safe transaction.\n /// This method is only meant for estimation purpose, therefore the call will always revert and encode the result in the revert data.\n /// Since the `estimateGas` function includes refunds, call this method to get an estimated of the costs that are deducted from the safe with `execTransaction`\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @return Estimate without refunds and overhead fees (base transaction and payload data gas costs).\n /// @notice Deprecated in favor of common/StorageAccessible.sol and will be removed in next version.\n function requiredTxGas(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation\n ) external returns (uint256) {\n uint256 startGas = gasleft();\n // We don't provide an error message here, as we use it to return the estimate\n require(execute(to, value, data, operation, gasleft()));\n uint256 requiredGas = startGas - gasleft();\n // Convert response to string and return via error message\n revert(string(abi.encodePacked(requiredGas)));\n }\n\n /**\n * @dev Marks a hash as approved. This can be used to validate a hash that is used by a signature.\n * @param hashToApprove The hash that should be marked as approved for signatures that are verified by this contract.\n */\n function approveHash(bytes32 hashToApprove) external {\n require(owners[msg.sender] != address(0), \"GS030\");\n approvedHashes[msg.sender][hashToApprove] = 1;\n emit ApproveHash(hashToApprove, msg.sender);\n }\n\n /// @dev Returns the chain id used by this contract.\n function getChainId() public view returns (uint256) {\n uint256 id;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n id := chainid()\n }\n return id;\n }\n\n function domainSeparator() public view returns (bytes32) {\n return keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, getChainId(), this));\n }\n\n /// @dev Returns the bytes that are hashed to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Gas that should be used for the safe transaction.\n /// @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash bytes.\n function encodeTransactionData(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n ) public view returns (bytes memory) {\n bytes32 safeTxHash =\n keccak256(\n abi.encode(\n SAFE_TX_TYPEHASH,\n to,\n value,\n keccak256(data),\n operation,\n safeTxGas,\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n _nonce\n )\n );\n return abi.encodePacked(bytes1(0x19), bytes1(0x01), domainSeparator(), safeTxHash);\n }\n\n /// @dev Returns hash to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Fas that should be used for the safe transaction.\n /// @param baseGas Gas costs for data used to trigger the safe transaction.\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash.\n function getTransactionHash(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n ) public view returns (bytes32) {\n return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./GnosisSafe.sol\";\n\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafeL2 is GnosisSafe {\n event SafeMultiSigTransaction(\n address to,\n uint256 value,\n bytes data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes signatures,\n // We combine nonce, sender and threshold into one to avoid stack too deep\n // Dev note: additionalInfo should not contain `bytes`, as this complicates decoding\n bytes additionalInfo\n );\n\n event SafeModuleTransaction(address module, address to, uint256 value, bytes data, Enum.Operation operation);\n\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\n /// Note: The fees are always transferred, even if the user transaction fails.\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @param safeTxGas Gas that should be used for the Safe transaction.\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Gas price that should be used for the payment calculation.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\n function execTransaction(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures\n ) public payable override returns (bool) {\n bytes memory additionalInfo;\n {\n additionalInfo = abi.encode(nonce, msg.sender, threshold);\n }\n emit SafeMultiSigTransaction(\n to,\n value,\n data,\n operation,\n safeTxGas,\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n signatures,\n additionalInfo\n );\n return super.execTransaction(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, signatures);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public override returns (bool success) {\n emit SafeModuleTransaction(msg.sender, to, value, data, operation);\n success = super.execTransactionFromModule(to, value, data, operation);\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/interfaces/ISignatureValidator.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\ncontract ISignatureValidatorConstants {\n // bytes4(keccak256(\"isValidSignature(bytes,bytes)\")\n bytes4 internal constant EIP1271_MAGIC_VALUE = 0x20c13b0b;\n}\n\nabstract contract ISignatureValidator is ISignatureValidatorConstants {\n /**\n * @dev Should return whether the signature provided is valid for the provided data\n * @param _data Arbitrary length data signed on the behalf of address(this)\n * @param _signature Signature byte array associated with _data\n *\n * MUST return the bytes4 magic value 0x20c13b0b when function passes.\n * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)\n * MUST allow external calls\n */\n function isValidSignature(bytes memory _data, bytes memory _signature) public view virtual returns (bytes4);\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Multi Send Call Only - Allows to batch multiple transactions into one, but only calls\n/// @author Stefan George - \n/// @author Richard Meissner - \n/// @notice The guard logic is not required here as this contract doesn't support nested delegate calls\ncontract MultiSendCallOnly {\n /// @dev Sends multiple transactions and reverts all if one fails.\n /// @param transactions Encoded transactions. Each transaction is encoded as a packed bytes of\n /// operation has to be uint8(0) in this version (=> 1 byte),\n /// to as a address (=> 20 bytes),\n /// value as a uint256 (=> 32 bytes),\n /// data length as a uint256 (=> 32 bytes),\n /// data as bytes.\n /// see abi.encodePacked for more information on packed encoding\n /// @notice The code is for most part the same as the normal MultiSend (to keep compatibility),\n /// but reverts if a transaction tries to use a delegatecall.\n /// @notice This method is payable as delegatecalls keep the msg.value from the previous call\n /// If the calling method (e.g. execTransaction) received ETH this would revert otherwise\n function multiSend(bytes memory transactions) public payable {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let length := mload(transactions)\n let i := 0x20\n for {\n // Pre block is not used in \"while mode\"\n } lt(i, length) {\n // Post block is not used in \"while mode\"\n } {\n // First byte of the data is the operation.\n // We shift by 248 bits (256 - 8 [operation byte]) it right since mload will always load 32 bytes (a word).\n // This will also zero out unused data.\n let operation := shr(0xf8, mload(add(transactions, i)))\n // We offset the load address by 1 byte (operation byte)\n // We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data.\n let to := shr(0x60, mload(add(transactions, add(i, 0x01))))\n // We offset the load address by 21 byte (operation byte + 20 address bytes)\n let value := mload(add(transactions, add(i, 0x15)))\n // We offset the load address by 53 byte (operation byte + 20 address bytes + 32 value bytes)\n let dataLength := mload(add(transactions, add(i, 0x35)))\n // We offset the load address by 85 byte (operation byte + 20 address bytes + 32 value bytes + 32 data length bytes)\n let data := add(transactions, add(i, 0x55))\n let success := 0\n switch operation\n case 0 {\n success := call(gas(), to, value, data, dataLength, 0, 0)\n }\n // This version does not allow delegatecalls\n case 1 {\n revert(0, 0)\n }\n if eq(success, 0) {\n revert(0, 0)\n }\n // Next entry starts at 85 byte + data length\n i := add(i, add(0x55, dataLength))\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxy.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain\n/// @author Richard Meissner - \ninterface IProxy {\n function masterCopy() external view returns (address);\n}\n\n/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafeProxy {\n // singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.\n // To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`\n address internal singleton;\n\n /// @dev Constructor function sets address of singleton contract.\n /// @param _singleton Singleton address.\n constructor(address _singleton) {\n require(_singleton != address(0), \"Invalid singleton address provided\");\n singleton = _singleton;\n }\n\n /// @dev Fallback function forwards all transactions and returns all received return data.\n fallback() external payable {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)\n // 0xa619486e == keccak(\"masterCopy()\"). The value is right padded to 32-bytes with 0s\n if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {\n mstore(0, _singleton)\n return(0, 0x20)\n }\n calldatacopy(0, 0, calldatasize())\n let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)\n returndatacopy(0, 0, returndatasize())\n if eq(success, 0) {\n revert(0, returndatasize())\n }\n return(0, returndatasize())\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./GnosisSafeProxy.sol\";\nimport \"./IProxyCreationCallback.sol\";\n\n/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n/// @author Stefan George - \ncontract GnosisSafeProxyFactory {\n event ProxyCreation(GnosisSafeProxy proxy, address singleton);\n\n /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n /// @param singleton Address of singleton contract.\n /// @param data Payload for message call sent to new proxy contract.\n function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {\n proxy = new GnosisSafeProxy(singleton);\n if (data.length > 0)\n // solhint-disable-next-line no-inline-assembly\n assembly {\n if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {\n revert(0, 0)\n }\n }\n emit ProxyCreation(proxy, singleton);\n }\n\n /// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.\n function proxyRuntimeCode() public pure returns (bytes memory) {\n return type(GnosisSafeProxy).runtimeCode;\n }\n\n /// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.\n function proxyCreationCode() public pure returns (bytes memory) {\n return type(GnosisSafeProxy).creationCode;\n }\n\n /// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.\n /// This method is only meant as an utility to be called from other methods\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function deployProxyWithNonce(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce\n ) internal returns (GnosisSafeProxy proxy) {\n // If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it\n bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));\n bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));\n // solhint-disable-next-line no-inline-assembly\n assembly {\n proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)\n }\n require(address(proxy) != address(0), \"Create2 call failed\");\n }\n\n /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function createProxyWithNonce(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce\n ) public returns (GnosisSafeProxy proxy) {\n proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);\n if (initializer.length > 0)\n // solhint-disable-next-line no-inline-assembly\n assembly {\n if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {\n revert(0, 0)\n }\n }\n emit ProxyCreation(proxy, _singleton);\n }\n\n /// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n /// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.\n function createProxyWithCallback(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce,\n IProxyCreationCallback callback\n ) public returns (GnosisSafeProxy proxy) {\n uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));\n proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);\n if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);\n }\n\n /// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`\n /// This method is only meant for address calculation purpose when you use an initializer that would revert,\n /// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function calculateCreateProxyWithNonceAddress(\n address _singleton,\n bytes calldata initializer,\n uint256 saltNonce\n ) external returns (GnosisSafeProxy proxy) {\n proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);\n revert(string(abi.encodePacked(proxy)));\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/IProxyCreationCallback.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"./GnosisSafeProxy.sol\";\n\ninterface IProxyCreationCallback {\n function proxyCreated(\n GnosisSafeProxy proxy,\n address _singleton,\n bytes calldata initializer,\n uint256 saltNonce\n ) external;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/core/Module.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Module Interface - A contract that can pass messages to a Module Manager contract if enabled by that contract.\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../interfaces/IAvatar.sol\";\nimport \"../factory/FactoryFriendly.sol\";\nimport \"../guard/Guardable.sol\";\n\nabstract contract Module is FactoryFriendly, Guardable {\n /// @dev Address that will ultimately execute function calls.\n address public avatar;\n /// @dev Address that this module will pass transactions to.\n address public target;\n\n /// @dev Emitted each time the avatar is set.\n event AvatarSet(address indexed previousAvatar, address indexed newAvatar);\n /// @dev Emitted each time the Target is set.\n event TargetSet(address indexed previousTarget, address indexed newTarget);\n\n /// @dev Sets the avatar to a new avatar (`newAvatar`).\n /// @notice Can only be called by the current owner.\n function setAvatar(address _avatar) public onlyOwner {\n address previousAvatar = avatar;\n avatar = _avatar;\n emit AvatarSet(previousAvatar, _avatar);\n }\n\n /// @dev Sets the target to a new target (`newTarget`).\n /// @notice Can only be called by the current owner.\n function setTarget(address _target) public onlyOwner {\n address previousTarget = target;\n target = _target;\n emit TargetSet(previousTarget, _target);\n }\n\n /// @dev Passes a transaction to be executed by the avatar.\n /// @notice Can only be called by this contract.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function exec(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) internal returns (bool success) {\n /// Check if a transactioon guard is enabled.\n if (guard != address(0)) {\n IGuard(guard).checkTransaction(\n /// Transaction info used by module transactions.\n to,\n value,\n data,\n operation,\n /// Zero out the redundant transaction information only used for Safe multisig transctions.\n 0,\n 0,\n 0,\n address(0),\n payable(0),\n bytes(\"0x\"),\n msg.sender\n );\n }\n success = IAvatar(target).execTransactionFromModule(\n to,\n value,\n data,\n operation\n );\n if (guard != address(0)) {\n IGuard(guard).checkAfterExecution(bytes32(\"0x\"), success);\n }\n return success;\n }\n\n /// @dev Passes a transaction to be executed by the target and returns data.\n /// @notice Can only be called by this contract.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execAndReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) internal returns (bool success, bytes memory returnData) {\n /// Check if a transactioon guard is enabled.\n if (guard != address(0)) {\n IGuard(guard).checkTransaction(\n /// Transaction info used by module transactions.\n to,\n value,\n data,\n operation,\n /// Zero out the redundant transaction information only used for Safe multisig transctions.\n 0,\n 0,\n 0,\n address(0),\n payable(0),\n bytes(\"0x\"),\n msg.sender\n );\n }\n (success, returnData) = IAvatar(target)\n .execTransactionFromModuleReturnData(to, value, data, operation);\n if (guard != address(0)) {\n IGuard(guard).checkAfterExecution(bytes32(\"0x\"), success);\n }\n return (success, returnData);\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/factory/FactoryFriendly.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Zodiac FactoryFriendly - A contract that allows other contracts to be initializable and pass bytes as arguments to define contract state\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nabstract contract FactoryFriendly is OwnableUpgradeable {\n function setUp(bytes memory initializeParams) public virtual;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.8.0;\n\ncontract ModuleProxyFactory {\n event ModuleProxyCreation(\n address indexed proxy,\n address indexed masterCopy\n );\n\n /// `target` can not be zero.\n error ZeroAddress(address target);\n\n /// `address_` is already taken.\n error TakenAddress(address address_);\n\n /// @notice Initialization failed.\n error FailedInitialization();\n\n function createProxy(address target, bytes32 salt)\n internal\n returns (address result)\n {\n if (address(target) == address(0)) revert ZeroAddress(target);\n bytes memory deployment = abi.encodePacked(\n hex\"602d8060093d393df3363d3d373d3d3d363d73\",\n target,\n hex\"5af43d82803e903d91602b57fd5bf3\"\n );\n // solhint-disable-next-line no-inline-assembly\n assembly {\n result := create2(0, add(deployment, 0x20), mload(deployment), salt)\n }\n if (result == address(0)) revert TakenAddress(result);\n }\n\n function deployModule(\n address masterCopy,\n bytes memory initializer,\n uint256 saltNonce\n ) public returns (address proxy) {\n proxy = createProxy(\n masterCopy,\n keccak256(abi.encodePacked(keccak256(initializer), saltNonce))\n );\n (bool success, ) = proxy.call(initializer);\n if (!success) revert FailedInitialization();\n\n emit ModuleProxyCreation(proxy, masterCopy);\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/guard/BaseGuard.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport \"../interfaces/IGuard.sol\";\n\nabstract contract BaseGuard is IERC165 {\n function supportsInterface(bytes4 interfaceId)\n external\n pure\n override\n returns (bool)\n {\n return\n interfaceId == type(IGuard).interfaceId || // 0xe6d7a83a\n interfaceId == type(IERC165).interfaceId; // 0x01ffc9a7\n }\n\n /// @dev Module transactions only use the first four parameters: to, value, data, and operation.\n /// Module.sol hardcodes the remaining parameters as 0 since they are not used for module transactions.\n /// @notice This interface is used to maintain compatibilty with Gnosis Safe transaction guards.\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external virtual;\n\n function checkAfterExecution(bytes32 txHash, bool success) external virtual;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/guard/Guardable.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"./BaseGuard.sol\";\n\n/// @title Guardable - A contract that manages fallback calls made to this contract\ncontract Guardable is OwnableUpgradeable {\n address public guard;\n\n event ChangedGuard(address guard);\n\n /// `guard_` does not implement IERC165.\n error NotIERC165Compliant(address guard_);\n\n /// @dev Set a guard that checks transactions before execution.\n /// @param _guard The address of the guard to be used or the 0 address to disable the guard.\n function setGuard(address _guard) external onlyOwner {\n if (_guard != address(0)) {\n if (!BaseGuard(_guard).supportsInterface(type(IGuard).interfaceId))\n revert NotIERC165Compliant(_guard);\n }\n guard = _guard;\n emit ChangedGuard(guard);\n }\n\n function getGuard() external view returns (address _guard) {\n return guard;\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Zodiac Avatar - A contract that manages modules that can execute transactions via this contract.\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\n\ninterface IAvatar {\n event EnabledModule(address module);\n event DisabledModule(address module);\n event ExecutionFromModuleSuccess(address indexed module);\n event ExecutionFromModuleFailure(address indexed module);\n\n /// @dev Enables a module on the avatar.\n /// @notice Can only be called by the avatar.\n /// @notice Modules should be stored as a linked list.\n /// @notice Must emit EnabledModule(address module) if successful.\n /// @param module Module to be enabled.\n function enableModule(address module) external;\n\n /// @dev Disables a module on the avatar.\n /// @notice Can only be called by the avatar.\n /// @notice Must emit DisabledModule(address module) if successful.\n /// @param prevModule Address that pointed to the module to be removed in the linked list\n /// @param module Module to be removed.\n function disableModule(address prevModule, address module) external;\n\n /// @dev Allows a Module to execute a transaction.\n /// @notice Can only be called by an enabled module.\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) external returns (bool success);\n\n /// @dev Allows a Module to execute a transaction and return data\n /// @notice Can only be called by an enabled module.\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execTransactionFromModuleReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) external returns (bool success, bytes memory returnData);\n\n /// @dev Returns if an module is enabled\n /// @return True if the module is enabled\n function isModuleEnabled(address module) external view returns (bool);\n\n /// @dev Returns array of modules.\n /// @param start Start of the page.\n /// @param pageSize Maximum number of modules that should be returned.\n /// @return array Array of modules.\n /// @return next Start of the next page.\n function getModulesPaginated(address start, uint256 pageSize)\n external\n view\n returns (address[] memory array, address next);\n}\n" + }, + "@gnosis.pm/zodiac/contracts/interfaces/IGuard.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\n\ninterface IGuard {\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external;\n\n function checkAfterExecution(bytes32 txHash, bool success) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 * By default, the owner account will be the one that deploys the contract. This\n * can 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 OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\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 require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing 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 require(newOwner != address(0), \"Ownable: new owner is the zero address\");\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/governance/utils/IVotesUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotesUpgradeable {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\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 * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\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 Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 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. Equivalent to `reinitializer(1)`.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\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 * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\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 modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\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 require(_initializing, \"Initializable: contract is not initializing\");\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 function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20Upgradeable.sol\";\nimport \"./extensions/IERC20MetadataUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC20_init_unchained(name_, symbol_);\n }\n\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[45] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20PermitUpgradeable.sol\";\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/cryptography/draft-EIP712Upgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {\n using CountersUpgradeable for CountersUpgradeable.Counter;\n\n mapping(address => CountersUpgradeable.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n function __ERC20Permit_init(string memory name) internal onlyInitializing {\n __EIP712_init_unchained(name, \"1\");\n }\n\n function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSAUpgradeable.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n CountersUpgradeable.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20SnapshotUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC20Snapshot.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/ArraysUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances and\n * total supply at the time are recorded for later access.\n *\n * This can be used to safely create mechanisms based on token balances such as trustless dividends or weighted voting.\n * In naive implementations it's possible to perform a \"double spend\" attack by reusing the same balance from different\n * accounts. By using snapshots to calculate dividends or voting power, those attacks no longer apply. It can also be\n * used to create an efficient ERC20 forking mechanism.\n *\n * Snapshots are created by the internal {_snapshot} function, which will emit the {Snapshot} event and return a\n * snapshot id. To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with the snapshot\n * id. To get the balance of an account at the time of a snapshot, call the {balanceOfAt} function with the snapshot id\n * and the account address.\n *\n * NOTE: Snapshot policy can be customized by overriding the {_getCurrentSnapshotId} method. For example, having it\n * return `block.number` will trigger the creation of snapshot at the beginning of each new block. When overriding this\n * function, be careful about the monotonicity of its result. Non-monotonic snapshot ids will break the contract.\n *\n * Implementing snapshots for every block using this method will incur significant gas costs. For a gas-efficient\n * alternative consider {ERC20Votes}.\n *\n * ==== Gas Costs\n *\n * Snapshots are efficient. Snapshot creation is _O(1)_. Retrieval of balances or total supply from a snapshot is _O(log\n * n)_ in the number of snapshots that have been created, although _n_ for a specific account will generally be much\n * smaller since identical balances in subsequent snapshots are stored as a single entry.\n *\n * There is a constant overhead for normal ERC20 transfers due to the additional snapshot bookkeeping. This overhead is\n * only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent\n * transfers will have normal cost until the next snapshot, and so on.\n */\n\nabstract contract ERC20SnapshotUpgradeable is Initializable, ERC20Upgradeable {\n function __ERC20Snapshot_init() internal onlyInitializing {\n }\n\n function __ERC20Snapshot_init_unchained() internal onlyInitializing {\n }\n // Inspired by Jordi Baylina's MiniMeToken to record historical balances:\n // https://github.com/Giveth/minime/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol\n\n using ArraysUpgradeable for uint256[];\n using CountersUpgradeable for CountersUpgradeable.Counter;\n\n // Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a\n // Snapshot struct, but that would impede usage of functions that work on an array.\n struct Snapshots {\n uint256[] ids;\n uint256[] values;\n }\n\n mapping(address => Snapshots) private _accountBalanceSnapshots;\n Snapshots private _totalSupplySnapshots;\n\n // Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid.\n CountersUpgradeable.Counter private _currentSnapshotId;\n\n /**\n * @dev Emitted by {_snapshot} when a snapshot identified by `id` is created.\n */\n event Snapshot(uint256 id);\n\n /**\n * @dev Creates a new snapshot and returns its snapshot id.\n *\n * Emits a {Snapshot} event that contains the same id.\n *\n * {_snapshot} is `internal` and you have to decide how to expose it externally. Its usage may be restricted to a\n * set of accounts, for example using {AccessControl}, or it may be open to the public.\n *\n * [WARNING]\n * ====\n * While an open way of calling {_snapshot} is required for certain trust minimization mechanisms such as forking,\n * you must consider that it can potentially be used by attackers in two ways.\n *\n * First, it can be used to increase the cost of retrieval of values from snapshots, although it will grow\n * logarithmically thus rendering this attack ineffective in the long term. Second, it can be used to target\n * specific accounts and increase the cost of ERC20 transfers for them, in the ways specified in the Gas Costs\n * section above.\n *\n * We haven't measured the actual numbers; if this is something you're interested in please reach out to us.\n * ====\n */\n function _snapshot() internal virtual returns (uint256) {\n _currentSnapshotId.increment();\n\n uint256 currentId = _getCurrentSnapshotId();\n emit Snapshot(currentId);\n return currentId;\n }\n\n /**\n * @dev Get the current snapshotId\n */\n function _getCurrentSnapshotId() internal view virtual returns (uint256) {\n return _currentSnapshotId.current();\n }\n\n /**\n * @dev Retrieves the balance of `account` at the time `snapshotId` was created.\n */\n function balanceOfAt(address account, uint256 snapshotId) public view virtual returns (uint256) {\n (bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]);\n\n return snapshotted ? value : balanceOf(account);\n }\n\n /**\n * @dev Retrieves the total supply at the time `snapshotId` was created.\n */\n function totalSupplyAt(uint256 snapshotId) public view virtual returns (uint256) {\n (bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots);\n\n return snapshotted ? value : totalSupply();\n }\n\n // Update balance and/or total supply snapshots before the values are modified. This is implemented\n // in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations.\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n if (from == address(0)) {\n // mint\n _updateAccountSnapshot(to);\n _updateTotalSupplySnapshot();\n } else if (to == address(0)) {\n // burn\n _updateAccountSnapshot(from);\n _updateTotalSupplySnapshot();\n } else {\n // transfer\n _updateAccountSnapshot(from);\n _updateAccountSnapshot(to);\n }\n }\n\n function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) {\n require(snapshotId > 0, \"ERC20Snapshot: id is 0\");\n require(snapshotId <= _getCurrentSnapshotId(), \"ERC20Snapshot: nonexistent id\");\n\n // When a valid snapshot is queried, there are three possibilities:\n // a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was never\n // created for this id, and all stored snapshot ids are smaller than the requested one. The value that corresponds\n // to this id is the current one.\n // b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with the\n // requested id, and its value is the one to return.\n // c) More snapshots were created after the requested one, and the queried value was later modified. There will be\n // no entry for the requested id: the value that corresponds to it is that of the smallest snapshot id that is\n // larger than the requested one.\n //\n // In summary, we need to find an element in an array, returning the index of the smallest value that is larger if\n // it is not found, unless said value doesn't exist (e.g. when all values are smaller). Arrays.findUpperBound does\n // exactly this.\n\n uint256 index = snapshots.ids.findUpperBound(snapshotId);\n\n if (index == snapshots.ids.length) {\n return (false, 0);\n } else {\n return (true, snapshots.values[index]);\n }\n }\n\n function _updateAccountSnapshot(address account) private {\n _updateSnapshot(_accountBalanceSnapshots[account], balanceOf(account));\n }\n\n function _updateTotalSupplySnapshot() private {\n _updateSnapshot(_totalSupplySnapshots, totalSupply());\n }\n\n function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private {\n uint256 currentId = _getCurrentSnapshotId();\n if (_lastSnapshotId(snapshots.ids) < currentId) {\n snapshots.ids.push(currentId);\n snapshots.values.push(currentValue);\n }\n }\n\n function _lastSnapshotId(uint256[] storage ids) private view returns (uint256) {\n if (ids.length == 0) {\n return 0;\n } else {\n return ids[ids.length - 1];\n }\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[46] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Votes.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-ERC20PermitUpgradeable.sol\";\nimport \"../../../utils/math/MathUpgradeable.sol\";\nimport \"../../../governance/utils/IVotesUpgradeable.sol\";\nimport \"../../../utils/math/SafeCastUpgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's,\n * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1.\n *\n * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module.\n *\n * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either\n * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting\n * power can be queried through the public accessors {getVotes} and {getPastVotes}.\n *\n * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it\n * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.\n *\n * _Available since v4.2._\n */\nabstract contract ERC20VotesUpgradeable is Initializable, IVotesUpgradeable, ERC20PermitUpgradeable {\n function __ERC20Votes_init() internal onlyInitializing {\n }\n\n function __ERC20Votes_init_unchained() internal onlyInitializing {\n }\n struct Checkpoint {\n uint32 fromBlock;\n uint224 votes;\n }\n\n bytes32 private constant _DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n mapping(address => address) private _delegates;\n mapping(address => Checkpoint[]) private _checkpoints;\n Checkpoint[] private _totalSupplyCheckpoints;\n\n /**\n * @dev Get the `pos`-th checkpoint for `account`.\n */\n function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) {\n return _checkpoints[account][pos];\n }\n\n /**\n * @dev Get number of checkpoints for `account`.\n */\n function numCheckpoints(address account) public view virtual returns (uint32) {\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\n }\n\n /**\n * @dev Get the address `account` is currently delegating to.\n */\n function delegates(address account) public view virtual override returns (address) {\n return _delegates[account];\n }\n\n /**\n * @dev Gets the current votes balance for `account`\n */\n function getVotes(address account) public view virtual override returns (uint256) {\n uint256 pos = _checkpoints[account].length;\n return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;\n }\n\n /**\n * @dev Retrieve the number of votes for `account` at the end of `blockNumber`.\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_checkpoints[account], blockNumber);\n }\n\n /**\n * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances.\n * It is but NOT the sum of all the delegated votes!\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastTotalSupply(uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber);\n }\n\n /**\n * @dev Lookup a value in a list of (sorted) checkpoints.\n */\n function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) {\n // We run a binary search to look for the earliest checkpoint taken after `blockNumber`.\n //\n // During the loop, the index of the wanted checkpoint remains in the range [low-1, high).\n // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.\n // - If the middle checkpoint is after `blockNumber`, we look in [low, mid)\n // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high)\n // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not\n // out of bounds (in which case we're looking too far in the past and the result is 0).\n // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is\n // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out\n // the same.\n uint256 high = ckpts.length;\n uint256 low = 0;\n while (low < high) {\n uint256 mid = MathUpgradeable.average(low, high);\n if (ckpts[mid].fromBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n return high == 0 ? 0 : ckpts[high - 1].votes;\n }\n\n /**\n * @dev Delegate votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) public virtual override {\n _delegate(_msgSender(), delegatee);\n }\n\n /**\n * @dev Delegates votes from signer to `delegatee`\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= expiry, \"ERC20Votes: signature expired\");\n address signer = ECDSAUpgradeable.recover(\n _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))),\n v,\n r,\n s\n );\n require(nonce == _useNonce(signer), \"ERC20Votes: invalid nonce\");\n _delegate(signer, delegatee);\n }\n\n /**\n * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).\n */\n function _maxSupply() internal view virtual returns (uint224) {\n return type(uint224).max;\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been increased.\n */\n function _mint(address account, uint256 amount) internal virtual override {\n super._mint(account, amount);\n require(totalSupply() <= _maxSupply(), \"ERC20Votes: total supply risks overflowing votes\");\n\n _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been decreased.\n */\n function _burn(address account, uint256 amount) internal virtual override {\n super._burn(account, amount);\n\n _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);\n }\n\n /**\n * @dev Move voting power when tokens are transferred.\n *\n * Emits a {DelegateVotesChanged} event.\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._afterTokenTransfer(from, to, amount);\n\n _moveVotingPower(delegates(from), delegates(to), amount);\n }\n\n /**\n * @dev Change delegation for `delegator` to `delegatee`.\n *\n * Emits events {DelegateChanged} and {DelegateVotesChanged}.\n */\n function _delegate(address delegator, address delegatee) internal virtual {\n address currentDelegate = delegates(delegator);\n uint256 delegatorBalance = balanceOf(delegator);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _moveVotingPower(\n address src,\n address dst,\n uint256 amount\n ) private {\n if (src != dst && amount > 0) {\n if (src != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);\n emit DelegateVotesChanged(src, oldWeight, newWeight);\n }\n\n if (dst != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\n }\n }\n }\n\n function _writeCheckpoint(\n Checkpoint[] storage ckpts,\n function(uint256, uint256) view returns (uint256) op,\n uint256 delta\n ) private returns (uint256 oldWeight, uint256 newWeight) {\n uint256 pos = ckpts.length;\n oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes;\n newWeight = op(oldWeight, delta);\n\n if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {\n ckpts[pos - 1].votes = SafeCastUpgradeable.toUint224(newWeight);\n } else {\n ckpts.push(Checkpoint({fromBlock: SafeCastUpgradeable.toUint32(block.number), votes: SafeCastUpgradeable.toUint224(newWeight)}));\n }\n }\n\n function _add(uint256 a, uint256 b) private pure returns (uint256) {\n return a + b;\n }\n\n function _subtract(uint256 a, uint256 b) private pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[47] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20WrapperUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/ERC20Wrapper.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../utils/SafeERC20Upgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Extension of the ERC20 token contract to support token wrapping.\n *\n * Users can deposit and withdraw \"underlying tokens\" and receive a matching number of \"wrapped tokens\". This is useful\n * in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the\n * wrapping of an existing \"basic\" ERC20 into a governance token.\n *\n * _Available since v4.2._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20WrapperUpgradeable is Initializable, ERC20Upgradeable {\n IERC20Upgradeable public underlying;\n\n function __ERC20Wrapper_init(IERC20Upgradeable underlyingToken) internal onlyInitializing {\n __ERC20Wrapper_init_unchained(underlyingToken);\n }\n\n function __ERC20Wrapper_init_unchained(IERC20Upgradeable underlyingToken) internal onlyInitializing {\n underlying = underlyingToken;\n }\n\n /**\n * @dev See {ERC20-decimals}.\n */\n function decimals() public view virtual override returns (uint8) {\n try IERC20MetadataUpgradeable(address(underlying)).decimals() returns (uint8 value) {\n return value;\n } catch {\n return super.decimals();\n }\n }\n\n /**\n * @dev Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.\n */\n function depositFor(address account, uint256 amount) public virtual returns (bool) {\n SafeERC20Upgradeable.safeTransferFrom(underlying, _msgSender(), address(this), amount);\n _mint(account, amount);\n return true;\n }\n\n /**\n * @dev Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.\n */\n function withdrawTo(address account, uint256 amount) public virtual returns (bool) {\n _burn(_msgSender(), amount);\n SafeERC20Upgradeable.safeTransfer(underlying, account, amount);\n return true;\n }\n\n /**\n * @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal\n * function that can be exposed with access control if desired.\n */\n function _recover(address account) internal virtual returns (uint256) {\n uint256 value = underlying.balanceOf(address(this)) - totalSupply();\n _mint(account, value);\n return value;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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 function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\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 /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ArraysUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Arrays.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\n\n/**\n * @dev Collection of functions related to array types.\n */\nlibrary ArraysUpgradeable {\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 * `array` is expected to be sorted in ascending order, and to contain no\n * repeated elements.\n */\n function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {\n if (array.length == 0) {\n return 0;\n }\n\n uint256 low = 0;\n uint256 high = array.length;\n\n while (low < high) {\n uint256 mid = MathUpgradeable.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 down (it does integer division with truncation).\n if (array[mid] > 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 && array[low - 1] == element) {\n return low - 1;\n } else {\n return low;\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary CountersUpgradeable {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSAUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 52\n */\nabstract contract EIP712Upgradeable is Initializable {\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n __EIP712_init_unchained(name, version);\n }\n\n function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev The hash of the name parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712NameHash() internal virtual view returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /**\n * @dev The hash of the version parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712VersionHash() internal virtual view returns (bytes32) {\n return _HASHED_VERSION;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\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 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 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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / 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 prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\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 works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\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^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`.\n // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.\n // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.\n // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a\n // good first aproximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1;\n uint256 x = a;\n if (x >> 128 > 0) {\n x >>= 128;\n result <<= 64;\n }\n if (x >> 64 > 0) {\n x >>= 64;\n result <<= 32;\n }\n if (x >> 32 > 0) {\n x >>= 32;\n result <<= 16;\n }\n if (x >> 16 > 0) {\n x >>= 16;\n result <<= 8;\n }\n if (x >> 8 > 0) {\n x >>= 8;\n result <<= 4;\n }\n if (x >> 4 > 0) {\n x >>= 4;\n result <<= 2;\n }\n if (x >> 2 > 0) {\n result <<= 1;\n }\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n uint256 result = sqrt(a);\n if (rounding == Rounding.Up && result * result < a) {\n result += 1;\n }\n return result;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX 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 *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\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 * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\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 * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\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 * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\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 * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\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 * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\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 * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\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 * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\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 * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\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 * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\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 * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\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 * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\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 * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\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 * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\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 * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\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 * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\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 * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\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 * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\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 * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\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 * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\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 * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\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 * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\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 * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\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 * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\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 * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\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 * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\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 * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\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 * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\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 * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\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 * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\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 * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\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 * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\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 * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\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 * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248) {\n require(value >= type(int248).min && value <= type(int248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return int248(value);\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 * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240) {\n require(value >= type(int240).min && value <= type(int240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return int240(value);\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 * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232) {\n require(value >= type(int232).min && value <= type(int232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return int232(value);\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 * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224) {\n require(value >= type(int224).min && value <= type(int224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return int224(value);\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 * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216) {\n require(value >= type(int216).min && value <= type(int216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return int216(value);\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 * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208) {\n require(value >= type(int208).min && value <= type(int208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return int208(value);\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 * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200) {\n require(value >= type(int200).min && value <= type(int200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return int200(value);\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 * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192) {\n require(value >= type(int192).min && value <= type(int192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return int192(value);\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 * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184) {\n require(value >= type(int184).min && value <= type(int184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return int184(value);\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 * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176) {\n require(value >= type(int176).min && value <= type(int176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return int176(value);\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 * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168) {\n require(value >= type(int168).min && value <= type(int168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return int168(value);\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 * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160) {\n require(value >= type(int160).min && value <= type(int160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return int160(value);\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 * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152) {\n require(value >= type(int152).min && value <= type(int152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return int152(value);\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 * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144) {\n require(value >= type(int144).min && value <= type(int144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return int144(value);\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 * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136) {\n require(value >= type(int136).min && value <= type(int136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return int136(value);\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 * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128) {\n require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return int128(value);\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 * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120) {\n require(value >= type(int120).min && value <= type(int120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return int120(value);\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 * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112) {\n require(value >= type(int112).min && value <= type(int112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return int112(value);\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 * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104) {\n require(value >= type(int104).min && value <= type(int104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return int104(value);\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 * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96) {\n require(value >= type(int96).min && value <= type(int96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return int96(value);\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 * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88) {\n require(value >= type(int88).min && value <= type(int88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return int88(value);\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 * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80) {\n require(value >= type(int80).min && value <= type(int80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return int80(value);\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 * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72) {\n require(value >= type(int72).min && value <= type(int72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return int72(value);\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 * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64) {\n require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return int64(value);\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 * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56) {\n require(value >= type(int56).min && value <= type(int56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return int56(value);\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 * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48) {\n require(value >= type(int48).min && value <= type(int48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return int48(value);\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 * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40) {\n require(value >= type(int40).min && value <= type(int40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return int40(value);\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 * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32) {\n require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return int32(value);\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 * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24) {\n require(value >= type(int24).min && value <= type(int24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return int24(value);\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 * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16) {\n require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return int16(value);\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 * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8) {\n require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return int8(value);\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 * _Available since v3.0._\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 require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@openzeppelin/contracts/governance/utils/IVotes.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotes {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/ERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\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 /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\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" + }, + "@openzeppelin/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 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 *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165Storage.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Storage.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ERC165.sol\";\n\n/**\n * @dev Storage based implementation of the {IERC165} interface.\n *\n * Contracts may inherit from this and call {_registerInterface} to declare\n * their support of an interface.\n */\nabstract contract ERC165Storage is ERC165 {\n /**\n * @dev Mapping of interface ids to whether or not it's supported.\n */\n mapping(bytes4 => bool) private _supportedInterfaces;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return super.supportsInterface(interfaceId) || _supportedInterfaces[interfaceId];\n }\n\n /**\n * @dev Registers the contract as an implementer of the interface defined by\n * `interfaceId`. Support of the actual ERC165 interface is automatic and\n * registering its interface id is not required.\n *\n * See {IERC165-supportsInterface}.\n *\n * Requirements:\n *\n * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).\n */\n function _registerInterface(bytes4 interfaceId) internal virtual {\n require(interfaceId != 0xffffffff, \"ERC165: invalid interface id\");\n _supportedInterfaces[interfaceId] = true;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\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[EIP 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" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@prb/math/src/Common.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\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 works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\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^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n" + }, + "@prb/math/src/sd1x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n" + }, + "@prb/math/src/sd1x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint64 constant uUNIT = 1e18;\n" + }, + "@prb/math/src/sd1x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n" + }, + "@prb/math/src/sd1x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n" + }, + "@prb/math/src/sd59x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n" + }, + "@prb/math/src/sd59x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev Any value less than this returns 0 in {exp}.\nint256 constant uEXP_MIN_THRESHOLD = -41_446531673892822322;\nSD59x18 constant EXP_MIN_THRESHOLD = SD59x18.wrap(uEXP_MIN_THRESHOLD);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Any value less than this returns 0 in {exp2}.\nint256 constant uEXP2_MIN_THRESHOLD = -59_794705707972522261;\nSD59x18 constant EXP2_MIN_THRESHOLD = SD59x18.wrap(uEXP2_MIN_THRESHOLD);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n" + }, + "@prb/math/src/sd59x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n" + }, + "@prb/math/src/sd59x18/Helpers.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" + }, + "@prb/math/src/sd59x18/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uEXP_MIN_THRESHOLD,\n uEXP2_MIN_THRESHOLD,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // Any input less than the threshold returns zero.\n // This check also prevents an overflow for very small numbers.\n if (xInt < uEXP_MIN_THRESHOLD) {\n return ZERO;\n }\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than the threshold is truncated to zero.\n if (xInt < uEXP2_MIN_THRESHOLD) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n" + }, + "@prb/math/src/sd59x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n" + }, + "@prb/math/src/UD2x18.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗╚════██╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║ █████╔╝ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══╝ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud2x18/Casting.sol\";\nimport \"./ud2x18/Constants.sol\";\nimport \"./ud2x18/Errors.sol\";\nimport \"./ud2x18/ValueType.sol\";\n" + }, + "@prb/math/src/ud2x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n" + }, + "@prb/math/src/ud2x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\nuint64 constant uUNIT = 1e18;\n" + }, + "@prb/math/src/ud2x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n" + }, + "@prb/math/src/ud2x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n" + }, + "@prb/math/src/UD60x18.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n" + }, + "@prb/math/src/ud60x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n" + }, + "@prb/math/src/ud60x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n" + }, + "@prb/math/src/ud60x18/Conversions.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n" + }, + "@prb/math/src/ud60x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n" + }, + "@prb/math/src/ud60x18/Helpers.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" + }, + "@prb/math/src/ud60x18/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n///\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n" + }, + "@prb/math/src/ud60x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n" + }, + "contracts/DecentSablierStreamManagement.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.28;\n\nimport {Enum} from \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport {IAvatar} from \"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\";\nimport {ISablierV2Lockup} from \"./interfaces/sablier/full/ISablierV2Lockup.sol\";\nimport {Lockup} from \"./interfaces/sablier/full/types/DataTypes.sol\";\n\ncontract DecentSablierStreamManagement {\n string public constant NAME = \"DecentSablierStreamManagement\";\n\n function withdrawMaxFromStream(\n ISablierV2Lockup sablier,\n address recipientHatAccount,\n uint256 streamId,\n address to\n ) public {\n // Check if there are funds to withdraw\n uint128 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\n if (withdrawableAmount == 0) {\n return;\n }\n\n // Proxy the Sablier withdrawMax call through IAvatar (Safe)\n IAvatar(msg.sender).execTransactionFromModule(\n recipientHatAccount,\n 0,\n abi.encodeWithSignature(\n \"execute(address,uint256,bytes,uint8)\",\n address(sablier),\n 0,\n abi.encodeWithSignature(\n \"withdrawMax(uint256,address)\",\n streamId,\n to\n ),\n 0\n ),\n Enum.Operation.Call\n );\n }\n\n function cancelStream(ISablierV2Lockup sablier, uint256 streamId) public {\n // Check if the stream can be cancelled\n Lockup.Status streamStatus = sablier.statusOf(streamId);\n if (\n streamStatus != Lockup.Status.PENDING &&\n streamStatus != Lockup.Status.STREAMING\n ) {\n return;\n }\n\n IAvatar(msg.sender).execTransactionFromModule(\n address(sablier),\n 0,\n abi.encodeWithSignature(\"cancel(uint256)\", streamId),\n Enum.Operation.Call\n );\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol';\n" + }, + "contracts/interfaces/hats/IHats.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0\n// Copyright (C) 2023 Haberdasher Labs\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see .\n\npragma solidity >=0.8.13;\n\ninterface IHats {\n function mintTopHat(\n address _target,\n string memory _details,\n string memory _imageURI\n ) external returns (uint256 topHatId);\n\n function createHat(\n uint256 _admin,\n string calldata _details,\n uint32 _maxSupply,\n address _eligibility,\n address _toggle,\n bool _mutable,\n string calldata _imageURI\n ) external returns (uint256 newHatId);\n\n function mintHat(\n uint256 _hatId,\n address _wearer\n ) external returns (bool success);\n\n function transferHat(uint256 _hatId, address _from, address _to) external;\n}\n" + }, + "contracts/interfaces/IERC6551Registry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IERC6551Registry {\n /**\n * @dev Creates a token bound account for a non-fungible token.\n *\n * If account has already been created, returns the account address without calling create2.\n *\n * Emits ERC6551AccountCreated event.\n *\n * @return account The address of the token bound account\n */\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address account);\n}\n" + }, + "contracts/interfaces/sablier/full/IAdminable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\n/// @title IAdminable\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\n/// in the constructor.\ninterface IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin is transferred.\n /// @param oldAdmin The address of the old admin.\n /// @param newAdmin The address of the new admin.\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice The address of the admin account or contract.\n function admin() external view returns (address);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Transfers the contract admin to a new address.\n ///\n /// @dev Notes:\n /// - Does not revert if the admin is the same.\n /// - This function can potentially leave the contract without an admin, thereby removing any\n /// functionality that is only available to the admin.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newAdmin The address of the new admin.\n function transferAdmin(address newAdmin) external;\n}\n" + }, + "contracts/interfaces/sablier/full/IERC4096.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4906.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\n/// @title ERC-721 Metadata Update Extension\ninterface IERC4906 is IERC165, IERC721 {\n /// @dev This event emits when the metadata of a token is changed.\n /// So that the third-party platforms such as NFT market could\n /// timely update the images and related attributes of the NFT.\n event MetadataUpdate(uint256 _tokenId);\n\n /// @dev This event emits when the metadata of a range of tokens is changed.\n /// So that the third-party platforms such as NFT market could\n /// timely update the images and related attributes of the NFTs.\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n}\n" + }, + "contracts/interfaces/sablier/full/ISablierV2Lockup.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC4906} from \"./IERC4096.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IERC721Metadata} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\nimport {UD60x18} from \"@prb/math/src/UD60x18.sol\";\n\nimport {Lockup} from \"./types/DataTypes.sol\";\nimport {IAdminable} from \"./IAdminable.sol\";\nimport {ISablierV2NFTDescriptor} from \"./ISablierV2NFTDescriptor.sol\";\n\n/// @title ISablierV2Lockup\n/// @notice Common logic between all Sablier V2 Lockup contracts.\ninterface ISablierV2Lockup is\n IAdminable, // 0 inherited components\n IERC4906, // 2 inherited components\n IERC721Metadata // 2 inherited components\n{\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin allows a new recipient contract to hook to Sablier.\n /// @param admin The address of the current contract admin.\n /// @param recipient The address of the recipient contract put on the allowlist.\n event AllowToHook(address indexed admin, address recipient);\n\n /// @notice Emitted when a stream is canceled.\n /// @param streamId The ID of the stream.\n /// @param sender The address of the stream's sender.\n /// @param recipient The address of the stream's recipient.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\n /// decimals.\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\n /// asset's decimals.\n event CancelLockupStream(\n uint256 streamId,\n address indexed sender,\n address indexed recipient,\n IERC20 indexed asset,\n uint128 senderAmount,\n uint128 recipientAmount\n );\n\n /// @notice Emitted when a sender gives up the right to cancel a stream.\n /// @param streamId The ID of the stream.\n event RenounceLockupStream(uint256 indexed streamId);\n\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\n /// @param admin The address of the current contract admin.\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n event SetNFTDescriptor(\n address indexed admin,\n ISablierV2NFTDescriptor oldNFTDescriptor,\n ISablierV2NFTDescriptor newNFTDescriptor\n );\n\n /// @notice Emitted when assets are withdrawn from a stream.\n /// @param streamId The ID of the stream.\n /// @param to The address that has received the withdrawn assets.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\n event WithdrawFromLockupStream(\n uint256 indexed streamId,\n address indexed to,\n IERC20 indexed asset,\n uint128 amount\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the address of the ERC-20 asset to be distributed.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\n\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getDepositedAmount(\n uint256 streamId\n ) external view returns (uint128 depositedAmount);\n\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getEndTime(\n uint256 streamId\n ) external view returns (uint40 endTime);\n\n /// @notice Retrieves the stream's recipient.\n /// @dev Reverts if the NFT has been burned.\n /// @param streamId The stream ID for the query.\n function getRecipient(\n uint256 streamId\n ) external view returns (address recipient);\n\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\n /// decimals. This amount is always zero unless the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getRefundedAmount(\n uint256 streamId\n ) external view returns (uint128 refundedAmount);\n\n /// @notice Retrieves the stream's sender.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getSender(uint256 streamId) external view returns (address sender);\n\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getStartTime(\n uint256 streamId\n ) external view returns (uint40 startTime);\n\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getWithdrawnAmount(\n uint256 streamId\n ) external view returns (uint128 withdrawnAmount);\n\n /// @notice Retrieves a flag indicating whether the provided address is a contract allowed to hook to Sablier\n /// when a stream is canceled or when assets are withdrawn.\n /// @dev See {ISablierLockupRecipient} for more information.\n function isAllowedToHook(\n address recipient\n ) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\n /// flag is always `false`.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isCancelable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isCold(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isDepleted(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream exists.\n /// @dev Does not revert if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isStream(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isTransferable(\n uint256 streamId\n ) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isWarm(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves the maximum broker fee that can be charged by the broker, denoted as a fixed-point\n /// number where 1e18 is 100%.\n /// @dev This value is hard coded as a constant.\n function MAX_BROKER_FEE() external view returns (UD60x18);\n\n /// @notice Counter for stream IDs, used in the create functions.\n function nextStreamId() external view returns (uint256);\n\n /// @notice Contract that generates the non-fungible token URI.\n function nftDescriptor() external view returns (ISablierV2NFTDescriptor);\n\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\n /// of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function refundableAmountOf(\n uint256 streamId\n ) external view returns (uint128 refundableAmount);\n\n /// @notice Retrieves the stream's status.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function statusOf(\n uint256 streamId\n ) external view returns (Lockup.Status status);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n ///\n /// Notes:\n /// - Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\n /// to the total amount withdrawn.\n ///\n /// @param streamId The stream ID for the query.\n function streamedAmountOf(\n uint256 streamId\n ) external view returns (uint128 streamedAmount);\n\n /// @notice Retrieves a flag indicating whether the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function wasCanceled(uint256 streamId) external view returns (bool result);\n\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\n /// decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function withdrawableAmountOf(\n uint256 streamId\n ) external view returns (uint128 withdrawableAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Allows a recipient contract to hook to Sablier when a stream is canceled or when assets are withdrawn.\n /// Useful for implementing contracts that hold streams on behalf of users, such as vaults or staking contracts.\n ///\n /// @dev Emits an {AllowToHook} event.\n ///\n /// Notes:\n /// - Does not revert if the contract is already on the allowlist.\n /// - This is an irreversible operation. The contract cannot be removed from the allowlist.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n /// - `recipient` must have a non-zero code size.\n /// - `recipient` must implement {ISablierLockupRecipient}.\n ///\n /// @param recipient The address of the contract to allow for hooks.\n function allowToHook(address recipient) external;\n\n /// @notice Burns the NFT associated with the stream.\n ///\n /// @dev Emits a {Transfer} event.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a depleted stream.\n /// - The NFT must exist.\n /// - `msg.sender` must be either the NFT owner or an approved third party.\n ///\n /// @param streamId The ID of the stream NFT to burn.\n function burn(uint256 streamId) external;\n\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\n ///\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\n /// stream is marked as depleted.\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - The stream must be warm and cancelable.\n /// - `msg.sender` must be the stream's sender.\n ///\n /// @param streamId The ID of the stream to cancel.\n function cancel(uint256 streamId) external;\n\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\n ///\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - Refer to the notes in {cancel}.\n ///\n /// Requirements:\n /// - All requirements from {cancel} must be met for each stream.\n ///\n /// @param streamIds The IDs of the streams to cancel.\n function cancelMultiple(uint256[] calldata streamIds) external;\n\n /// @notice Removes the right of the stream's sender to cancel the stream.\n ///\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This is an irreversible operation.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a warm stream.\n /// - `msg.sender` must be the stream's sender.\n /// - The stream must be cancelable.\n ///\n /// @param streamId The ID of the stream to renounce.\n function renounce(uint256 streamId) external;\n\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\n ///\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\n ///\n /// Notes:\n /// - Does not revert if the NFT descriptor is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n function setNFTDescriptor(\n ISablierV2NFTDescriptor newNFTDescriptor\n ) external;\n\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of the stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must not reference a null or depleted stream.\n /// - `to` must not be the zero address.\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\n /// - `to` must be the recipient if `msg.sender` is not the stream's recipient or an approved third party.\n ///\n /// @param streamId The ID of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\n function withdraw(uint256 streamId, address to, uint128 amount) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - Refer to the requirements in {withdraw}.\n ///\n /// @param streamId The ID of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\n function withdrawMax(\n uint256 streamId,\n address to\n ) external returns (uint128 withdrawnAmount);\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\n /// NFT to `newRecipient`.\n ///\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\n ///\n /// Notes:\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - `msg.sender` must be the stream's recipient.\n /// - Refer to the requirements in {withdraw}.\n /// - Refer to the requirements in {IERC721.transferFrom}.\n ///\n /// @param streamId The ID of the stream NFT to transfer.\n /// @param newRecipient The address of the new owner of the stream NFT.\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\n function withdrawMaxAndTransfer(\n uint256 streamId,\n address newRecipient\n ) external returns (uint128 withdrawnAmount);\n\n /// @notice Withdraws assets from streams to the recipient of each stream.\n ///\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - There must be an equal number of `streamIds` and `amounts`.\n /// - Each stream ID in the array must not reference a null or depleted stream.\n /// - Each amount in the array must be greater than zero and must not exceed the withdrawable amount.\n ///\n /// @param streamIds The IDs of the streams to withdraw from.\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\n function withdrawMultiple(\n uint256[] calldata streamIds,\n uint128[] calldata amounts\n ) external;\n}\n" + }, + "contracts/interfaces/sablier/full/ISablierV2NFTDescriptor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC721Metadata} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\n/// @title ISablierV2NFTDescriptor\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\n/// @dev Inspired by Uniswap V3 Positions NFTs.\ninterface ISablierV2NFTDescriptor {\n /// @notice Produces the URI describing a particular stream NFT.\n /// @dev This is a data URI with the JSON contents directly inlined.\n /// @param sablier The address of the Sablier contract the stream was created in.\n /// @param streamId The ID of the stream for which to produce a description.\n /// @return uri The URI of the ERC721-compliant metadata.\n function tokenURI(\n IERC721Metadata sablier,\n uint256 streamId\n ) external view returns (string memory uri);\n}\n" + }, + "contracts/interfaces/sablier/full/types/DataTypes.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {UD2x18} from \"@prb/math/src/UD2x18.sol\";\nimport {UD60x18} from \"@prb/math/src/UD60x18.sol\";\n\n// DataTypes.sol\n//\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\n//\n// - Lockup\n// - LockupDynamic\n// - LockupLinear\n// - LockupTranched\n//\n// You will notice that some structs contain \"slot\" annotations - they are used to indicate the\n// storage layout of the struct. It is more gas efficient to group small data types together so\n// that they fit in a single 32-byte slot.\n\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\n/// @param account The address receiving the broker's fee.\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\nstruct Broker {\n address account;\n UD60x18 fee;\n}\n\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\nlibrary Lockup {\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the asset's\n /// decimals.\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in the same slot\n /// saves gas.\n /// @param deposited The initial amount deposited in the stream, net of broker fee.\n /// @param withdrawn The cumulative amount withdrawn from the stream.\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\n struct Amounts {\n // slot 0\n uint128 deposited;\n uint128 withdrawn;\n // slot 1\n uint128 refunded;\n }\n\n /// @notice Struct encapsulating (i) the deposit amount and (ii) the broker fee amount, both denoted in units of the\n /// asset's decimals.\n /// @param deposit The amount to deposit in the stream.\n /// @param brokerFee The broker fee amount.\n struct CreateAmounts {\n uint128 deposit;\n uint128 brokerFee;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING,\n STREAMING,\n SETTLED,\n CANCELED,\n DEPLETED\n }\n\n /// @notice A common data structure to be stored in all {SablierV2Lockup} models.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address distributing the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\nlibrary LockupDynamic {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param segments Segments with durations used to compose the dynamic distribution function. Timestamps are\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n SegmentWithDuration[] segments;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param segments Segments used to compose the dynamic distribution function.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n uint40 startTime;\n Segment[] segments;\n Broker broker;\n }\n\n /// @notice Segment struct used in the Lockup Dynamic stream.\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\n /// @param timestamp The Unix timestamp indicating the segment's end.\n struct Segment {\n // slot 0\n uint128 amount;\n UD2x18 exponent;\n uint40 timestamp;\n }\n\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDurations}.\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\n /// @param duration The time difference in seconds between the segment and the previous one.\n struct SegmentWithDuration {\n uint128 amount;\n UD2x18 exponent;\n uint40 duration;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the segments.\n struct StreamLD {\n address sender;\n address recipient;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n Segment[] segments;\n }\n\n /// @notice Struct encapsulating the LockupDynamic timestamps.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 end;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\nlibrary LockupLinear {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param durations Struct encapsulating (i) cliff period duration and (ii) total stream duration, both in seconds.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Durations durations;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param timestamps Struct encapsulating (i) the stream's start time, (ii) cliff time, and (iii) end time, all as\n /// Unix timestamps.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the cliff duration and the total duration.\n /// @param cliff The cliff duration in seconds.\n /// @param total The total duration in seconds.\n struct Durations {\n uint40 cliff;\n uint40 total;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the cliff time.\n struct StreamLL {\n address sender;\n address recipient;\n uint40 startTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n uint40 endTime;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n uint40 cliffTime;\n }\n\n /// @notice Struct encapsulating the LockupLinear timestamps.\n /// @param start The Unix timestamp for the stream's start.\n /// @param cliff The Unix timestamp for the cliff period's end. A value of zero means there is no cliff.\n /// @param end The Unix timestamp for the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupTranched}.\nlibrary LockupTranched {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param tranches Tranches with durations used to compose the tranched distribution function. Timestamps are\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n TrancheWithDuration[] tranches;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param tranches Tranches used to compose the tranched distribution function.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n uint40 startTime;\n Tranche[] tranches;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the tranches.\n struct StreamLT {\n address sender;\n address recipient;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n Tranche[] tranches;\n }\n\n /// @notice Struct encapsulating the LockupTranched timestamps.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 end;\n }\n\n /// @notice Tranche struct used in the Lockup Tranched stream.\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\n /// @param timestamp The Unix timestamp indicating the tranche's end.\n struct Tranche {\n // slot 0\n uint128 amount;\n uint40 timestamp;\n }\n\n /// @notice Tranche struct used at runtime in {SablierV2LockupTranched.createWithDurations}.\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\n /// @param duration The time difference in seconds between the tranche and the previous one.\n struct TrancheWithDuration {\n uint128 amount;\n uint40 duration;\n }\n}\n" + }, + "contracts/interfaces/sablier/ISablierV2LockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {LockupLinear} from \"./LockupLinear.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface ISablierV2LockupLinear {\n function createWithTimestamps(\n LockupLinear.CreateWithTimestamps calldata params\n ) external returns (uint256 streamId);\n}\n" + }, + "contracts/interfaces/sablier/LockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nlibrary LockupLinear {\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n struct Broker {\n address account;\n uint256 fee;\n }\n}\n" + }, + "contracts/mocks/ERC6551Registry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IERC6551Registry {\n /**\n * @dev The registry MUST emit the ERC6551AccountCreated event upon successful account creation.\n */\n event ERC6551AccountCreated(\n address account,\n address indexed implementation,\n bytes32 salt,\n uint256 chainId,\n address indexed tokenContract,\n uint256 indexed tokenId\n );\n\n /**\n * @dev The registry MUST revert with AccountCreationFailed error if the create2 operation fails.\n */\n error AccountCreationFailed();\n\n /**\n * @dev Creates a token bound account for a non-fungible token.\n *\n * If account has already been created, returns the account address without calling create2.\n *\n * Emits ERC6551AccountCreated event.\n *\n * @return account The address of the token bound account\n */\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address account);\n\n /**\n * @dev Returns the computed token bound account address for a non-fungible token.\n *\n * @return account The address of the token bound account\n */\n function account(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external view returns (address account);\n}\n\ncontract ERC6551Registry is IERC6551Registry {\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address) {\n assembly {\n // Memory Layout:\n // ----\n // 0x00 0xff (1 byte)\n // 0x01 registry (address) (20 bytes)\n // 0x15 salt (bytes32) (32 bytes)\n // 0x35 Bytecode Hash (bytes32) (32 bytes)\n // ----\n // 0x55 ERC-1167 Constructor + Header (20 bytes)\n // 0x69 implementation (address) (20 bytes)\n // 0x5D ERC-1167 Footer (15 bytes)\n // 0x8C salt (uint256) (32 bytes)\n // 0xAC chainId (uint256) (32 bytes)\n // 0xCC tokenContract (address) (32 bytes)\n // 0xEC tokenId (uint256) (32 bytes)\n\n // Silence unused variable warnings\n pop(chainId)\n\n // Copy bytecode + constant data to memory\n calldatacopy(0x8c, 0x24, 0x80) // salt, chainId, tokenContract, tokenId\n mstore(0x6c, 0x5af43d82803e903d91602b57fd5bf3) // ERC-1167 footer\n mstore(0x5d, implementation) // implementation\n mstore(0x49, 0x3d60ad80600a3d3981f3363d3d373d3d3d363d73) // ERC-1167 constructor + header\n\n // Copy create2 computation data to memory\n mstore8(0x00, 0xff) // 0xFF\n mstore(0x35, keccak256(0x55, 0xb7)) // keccak256(bytecode)\n mstore(0x01, shl(96, address())) // registry address\n mstore(0x15, salt) // salt\n\n // Compute account address\n let computed := keccak256(0x00, 0x55)\n\n // If the account has not yet been deployed\n if iszero(extcodesize(computed)) {\n // Deploy account contract\n let deployed := create2(0, 0x55, 0xb7, salt)\n\n // Revert if the deployment fails\n if iszero(deployed) {\n mstore(0x00, 0x20188a59) // `AccountCreationFailed()`\n revert(0x1c, 0x04)\n }\n\n // Store account address in memory before salt and chainId\n mstore(0x6c, deployed)\n\n // Emit the ERC6551AccountCreated event\n log4(\n 0x6c,\n 0x60,\n // `ERC6551AccountCreated(address,address,bytes32,uint256,address,uint256)`\n 0x79f19b3655ee38b1ce526556b7731a20c8f218fbda4a3990b6cc4172fdf88722,\n implementation,\n tokenContract,\n tokenId\n )\n\n // Return the account address\n return(0x6c, 0x20)\n }\n\n // Otherwise, return the computed account address\n mstore(0x00, shr(96, shl(96, computed)))\n return(0x00, 0x20)\n }\n }\n\n function account(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external view returns (address) {\n assembly {\n // Silence unused variable warnings\n pop(chainId)\n pop(tokenContract)\n pop(tokenId)\n\n // Copy bytecode + constant data to memory\n calldatacopy(0x8c, 0x24, 0x80) // salt, chainId, tokenContract, tokenId\n mstore(0x6c, 0x5af43d82803e903d91602b57fd5bf3) // ERC-1167 footer\n mstore(0x5d, implementation) // implementation\n mstore(0x49, 0x3d60ad80600a3d3981f3363d3d373d3d3d363d73) // ERC-1167 constructor + header\n\n // Copy create2 computation data to memory\n mstore8(0x00, 0xff) // 0xFF\n mstore(0x35, keccak256(0x55, 0xb7)) // keccak256(bytecode)\n mstore(0x01, shl(96, address())) // registry address\n mstore(0x15, salt) // salt\n\n // Store computed account address in memory\n mstore(0x00, shr(96, shl(96, keccak256(0x00, 0x55))))\n\n // Return computed account address\n return(0x00, 0x20)\n }\n }\n}\n" + }, + "contracts/mocks/MockContract.sol": { + "content": "//SPDX-License-Identifier: Unlicense\n\npragma solidity ^0.8.19;\n\n/**\n * Mock contract for testing\n */\ncontract MockContract {\n event DidSomething(string message);\n\n error Reverting();\n\n function doSomething() public {\n doSomethingWithParam(\"doSomething()\");\n }\n\n function doSomethingWithParam(string memory _message) public {\n emit DidSomething(_message);\n }\n\n function returnSomething(string memory _s)\n external\n pure\n returns (string memory)\n {\n return _s;\n }\n\n function revertSomething() external pure {\n revert Reverting();\n }\n}\n" + }, + "contracts/mocks/MockLockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nlibrary MockLockupLinear {\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n struct Broker {\n address account;\n uint256 fee;\n }\n\n struct Stream {\n address sender;\n uint40 startTime;\n uint40 endTime;\n uint40 cliffTime;\n bool cancelable;\n bool wasCanceled;\n address asset;\n bool transferable;\n uint128 totalAmount;\n address recipient;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING,\n STREAMING,\n SETTLED,\n CANCELED,\n DEPLETED\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/optimism/DecentSablierStreamManagement.json b/deployments/optimism/DecentSablierStreamManagement.json new file mode 100644 index 00000000..5681bc6e --- /dev/null +++ b/deployments/optimism/DecentSablierStreamManagement.json @@ -0,0 +1,100 @@ +{ + "address": "0x10295461bf4ad03A76Bf29d8e98bf068ec333854", + "abi": [ + { + "inputs": [], + "name": "NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ISablierV2Lockup", + "name": "sablier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + } + ], + "name": "cancelStream", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ISablierV2Lockup", + "name": "sablier", + "type": "address" + }, + { + "internalType": "address", + "name": "recipientHatAccount", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "withdrawMaxFromStream", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xa70b0fd93d4afeb76e06826853681fb456c1c99e5005adf1904d7dce18e311bb", + "receipt": { + "to": null, + "from": "0xb5Ca125166C1987A35EDD550E16846Fa1e1D9bB3", + "contractAddress": "0x10295461bf4ad03A76Bf29d8e98bf068ec333854", + "transactionIndex": 13, + "gasUsed": "384441", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x8d4430fb1ba84139a233692228da3d47eda1e21063cbe56f4c01501a37926b2b", + "transactionHash": "0xa70b0fd93d4afeb76e06826853681fb456c1c99e5005adf1904d7dce18e311bb", + "logs": [], + "blockNumber": 126489616, + "cumulativeGasUsed": "2581689", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4511b61209438ca20d2458493e70bb24", + "metadata": "{\"compiler\":{\"version\":\"0.8.28+commit.7893614a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"NAME\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISablierV2Lockup\",\"name\":\"sablier\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"streamId\",\"type\":\"uint256\"}],\"name\":\"cancelStream\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISablierV2Lockup\",\"name\":\"sablier\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipientHatAccount\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"streamId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"withdrawMaxFromStream\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/DecentSablierStreamManagement.sol\":\"DecentSablierStreamManagement\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only\\npragma solidity >=0.7.0 <0.9.0;\\n\\n/// @title Enum - Collection of enums\\n/// @author Richard Meissner - \\ncontract Enum {\\n enum Operation {Call, DelegateCall}\\n}\\n\",\"keccak256\":\"0x473e45b1a5cc47be494b0e123c9127f0c11c1e0992a321ae5a644c0bfdb2c14f\",\"license\":\"LGPL-3.0-only\"},\"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only\\n\\n/// @title Zodiac Avatar - A contract that manages modules that can execute transactions via this contract.\\npragma solidity >=0.7.0 <0.9.0;\\n\\nimport \\\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\\\";\\n\\ninterface IAvatar {\\n event EnabledModule(address module);\\n event DisabledModule(address module);\\n event ExecutionFromModuleSuccess(address indexed module);\\n event ExecutionFromModuleFailure(address indexed module);\\n\\n /// @dev Enables a module on the avatar.\\n /// @notice Can only be called by the avatar.\\n /// @notice Modules should be stored as a linked list.\\n /// @notice Must emit EnabledModule(address module) if successful.\\n /// @param module Module to be enabled.\\n function enableModule(address module) external;\\n\\n /// @dev Disables a module on the avatar.\\n /// @notice Can only be called by the avatar.\\n /// @notice Must emit DisabledModule(address module) if successful.\\n /// @param prevModule Address that pointed to the module to be removed in the linked list\\n /// @param module Module to be removed.\\n function disableModule(address prevModule, address module) external;\\n\\n /// @dev Allows a Module to execute a transaction.\\n /// @notice Can only be called by an enabled module.\\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\\n function execTransactionFromModule(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation\\n ) external returns (bool success);\\n\\n /// @dev Allows a Module to execute a transaction and return data\\n /// @notice Can only be called by an enabled module.\\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\\n function execTransactionFromModuleReturnData(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation\\n ) external returns (bool success, bytes memory returnData);\\n\\n /// @dev Returns if an module is enabled\\n /// @return True if the module is enabled\\n function isModuleEnabled(address module) external view returns (bool);\\n\\n /// @dev Returns array of modules.\\n /// @param start Start of the page.\\n /// @param pageSize Maximum number of modules that should be returned.\\n /// @return array Array of modules.\\n /// @return next Start of the next page.\\n function getModulesPaginated(address start, uint256 pageSize)\\n external\\n view\\n returns (address[] memory array, address next);\\n}\\n\",\"keccak256\":\"0xcd5508ffe596eef8fbccfd5fc4f10a34397773547ce64e212d48b5212865ec1f\",\"license\":\"LGPL-3.0-only\"},\"@openzeppelin/contracts/interfaces/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/introspection/IERC165.sol\\\";\\n\",\"keccak256\":\"0xd04b0f06e0666f29cf7cccc82894de541e19bb30a765b107b1e40bb7fe5f7d7a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xed6a749c5373af398105ce6ee3ac4763aa450ea7285d268c85d9eeca809cdb1f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Metadata is IERC721 {\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x75b829ff2f26c14355d1cba20e16fe7b29ca58eb5fef665ede48bc0f9c6c74b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\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[EIP 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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@prb/math/src/Common.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n// Common.sol\\n//\\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\\n// always operate with SD59x18 and UD60x18 numbers.\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CUSTOM ERRORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\\n\\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\\n\\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\\nerror PRBMath_MulDivSigned_InputTooSmall();\\n\\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CONSTANTS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @dev The maximum value a uint128 number can have.\\nuint128 constant MAX_UINT128 = type(uint128).max;\\n\\n/// @dev The maximum value a uint40 number can have.\\nuint40 constant MAX_UINT40 = type(uint40).max;\\n\\n/// @dev The unit number, which the decimal precision of the fixed-point types.\\nuint256 constant UNIT = 1e18;\\n\\n/// @dev The unit number inverted mod 2^256.\\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\\n\\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\\n/// bit in the binary representation of `UNIT`.\\nuint256 constant UNIT_LPOTD = 262144;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method.\\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(uint256 x) pure returns (uint256 result) {\\n unchecked {\\n // Start from 0.5 in the 192.64-bit fixed-point format.\\n result = 0x800000000000000000000000000000000000000000000000;\\n\\n // The following logic multiplies the result by $\\\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\\n //\\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\\n // we know that `x & 0xFF` is also 1.\\n if (x & 0xFF00000000000000 > 0) {\\n if (x & 0x8000000000000000 > 0) {\\n result = (result * 0x16A09E667F3BCC909) >> 64;\\n }\\n if (x & 0x4000000000000000 > 0) {\\n result = (result * 0x1306FE0A31B7152DF) >> 64;\\n }\\n if (x & 0x2000000000000000 > 0) {\\n result = (result * 0x1172B83C7D517ADCE) >> 64;\\n }\\n if (x & 0x1000000000000000 > 0) {\\n result = (result * 0x10B5586CF9890F62A) >> 64;\\n }\\n if (x & 0x800000000000000 > 0) {\\n result = (result * 0x1059B0D31585743AE) >> 64;\\n }\\n if (x & 0x400000000000000 > 0) {\\n result = (result * 0x102C9A3E778060EE7) >> 64;\\n }\\n if (x & 0x200000000000000 > 0) {\\n result = (result * 0x10163DA9FB33356D8) >> 64;\\n }\\n if (x & 0x100000000000000 > 0) {\\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\\n }\\n }\\n\\n if (x & 0xFF000000000000 > 0) {\\n if (x & 0x80000000000000 > 0) {\\n result = (result * 0x10058C86DA1C09EA2) >> 64;\\n }\\n if (x & 0x40000000000000 > 0) {\\n result = (result * 0x1002C605E2E8CEC50) >> 64;\\n }\\n if (x & 0x20000000000000 > 0) {\\n result = (result * 0x100162F3904051FA1) >> 64;\\n }\\n if (x & 0x10000000000000 > 0) {\\n result = (result * 0x1000B175EFFDC76BA) >> 64;\\n }\\n if (x & 0x8000000000000 > 0) {\\n result = (result * 0x100058BA01FB9F96D) >> 64;\\n }\\n if (x & 0x4000000000000 > 0) {\\n result = (result * 0x10002C5CC37DA9492) >> 64;\\n }\\n if (x & 0x2000000000000 > 0) {\\n result = (result * 0x1000162E525EE0547) >> 64;\\n }\\n if (x & 0x1000000000000 > 0) {\\n result = (result * 0x10000B17255775C04) >> 64;\\n }\\n }\\n\\n if (x & 0xFF0000000000 > 0) {\\n if (x & 0x800000000000 > 0) {\\n result = (result * 0x1000058B91B5BC9AE) >> 64;\\n }\\n if (x & 0x400000000000 > 0) {\\n result = (result * 0x100002C5C89D5EC6D) >> 64;\\n }\\n if (x & 0x200000000000 > 0) {\\n result = (result * 0x10000162E43F4F831) >> 64;\\n }\\n if (x & 0x100000000000 > 0) {\\n result = (result * 0x100000B1721BCFC9A) >> 64;\\n }\\n if (x & 0x80000000000 > 0) {\\n result = (result * 0x10000058B90CF1E6E) >> 64;\\n }\\n if (x & 0x40000000000 > 0) {\\n result = (result * 0x1000002C5C863B73F) >> 64;\\n }\\n if (x & 0x20000000000 > 0) {\\n result = (result * 0x100000162E430E5A2) >> 64;\\n }\\n if (x & 0x10000000000 > 0) {\\n result = (result * 0x1000000B172183551) >> 64;\\n }\\n }\\n\\n if (x & 0xFF00000000 > 0) {\\n if (x & 0x8000000000 > 0) {\\n result = (result * 0x100000058B90C0B49) >> 64;\\n }\\n if (x & 0x4000000000 > 0) {\\n result = (result * 0x10000002C5C8601CC) >> 64;\\n }\\n if (x & 0x2000000000 > 0) {\\n result = (result * 0x1000000162E42FFF0) >> 64;\\n }\\n if (x & 0x1000000000 > 0) {\\n result = (result * 0x10000000B17217FBB) >> 64;\\n }\\n if (x & 0x800000000 > 0) {\\n result = (result * 0x1000000058B90BFCE) >> 64;\\n }\\n if (x & 0x400000000 > 0) {\\n result = (result * 0x100000002C5C85FE3) >> 64;\\n }\\n if (x & 0x200000000 > 0) {\\n result = (result * 0x10000000162E42FF1) >> 64;\\n }\\n if (x & 0x100000000 > 0) {\\n result = (result * 0x100000000B17217F8) >> 64;\\n }\\n }\\n\\n if (x & 0xFF000000 > 0) {\\n if (x & 0x80000000 > 0) {\\n result = (result * 0x10000000058B90BFC) >> 64;\\n }\\n if (x & 0x40000000 > 0) {\\n result = (result * 0x1000000002C5C85FE) >> 64;\\n }\\n if (x & 0x20000000 > 0) {\\n result = (result * 0x100000000162E42FF) >> 64;\\n }\\n if (x & 0x10000000 > 0) {\\n result = (result * 0x1000000000B17217F) >> 64;\\n }\\n if (x & 0x8000000 > 0) {\\n result = (result * 0x100000000058B90C0) >> 64;\\n }\\n if (x & 0x4000000 > 0) {\\n result = (result * 0x10000000002C5C860) >> 64;\\n }\\n if (x & 0x2000000 > 0) {\\n result = (result * 0x1000000000162E430) >> 64;\\n }\\n if (x & 0x1000000 > 0) {\\n result = (result * 0x10000000000B17218) >> 64;\\n }\\n }\\n\\n if (x & 0xFF0000 > 0) {\\n if (x & 0x800000 > 0) {\\n result = (result * 0x1000000000058B90C) >> 64;\\n }\\n if (x & 0x400000 > 0) {\\n result = (result * 0x100000000002C5C86) >> 64;\\n }\\n if (x & 0x200000 > 0) {\\n result = (result * 0x10000000000162E43) >> 64;\\n }\\n if (x & 0x100000 > 0) {\\n result = (result * 0x100000000000B1721) >> 64;\\n }\\n if (x & 0x80000 > 0) {\\n result = (result * 0x10000000000058B91) >> 64;\\n }\\n if (x & 0x40000 > 0) {\\n result = (result * 0x1000000000002C5C8) >> 64;\\n }\\n if (x & 0x20000 > 0) {\\n result = (result * 0x100000000000162E4) >> 64;\\n }\\n if (x & 0x10000 > 0) {\\n result = (result * 0x1000000000000B172) >> 64;\\n }\\n }\\n\\n if (x & 0xFF00 > 0) {\\n if (x & 0x8000 > 0) {\\n result = (result * 0x100000000000058B9) >> 64;\\n }\\n if (x & 0x4000 > 0) {\\n result = (result * 0x10000000000002C5D) >> 64;\\n }\\n if (x & 0x2000 > 0) {\\n result = (result * 0x1000000000000162E) >> 64;\\n }\\n if (x & 0x1000 > 0) {\\n result = (result * 0x10000000000000B17) >> 64;\\n }\\n if (x & 0x800 > 0) {\\n result = (result * 0x1000000000000058C) >> 64;\\n }\\n if (x & 0x400 > 0) {\\n result = (result * 0x100000000000002C6) >> 64;\\n }\\n if (x & 0x200 > 0) {\\n result = (result * 0x10000000000000163) >> 64;\\n }\\n if (x & 0x100 > 0) {\\n result = (result * 0x100000000000000B1) >> 64;\\n }\\n }\\n\\n if (x & 0xFF > 0) {\\n if (x & 0x80 > 0) {\\n result = (result * 0x10000000000000059) >> 64;\\n }\\n if (x & 0x40 > 0) {\\n result = (result * 0x1000000000000002C) >> 64;\\n }\\n if (x & 0x20 > 0) {\\n result = (result * 0x10000000000000016) >> 64;\\n }\\n if (x & 0x10 > 0) {\\n result = (result * 0x1000000000000000B) >> 64;\\n }\\n if (x & 0x8 > 0) {\\n result = (result * 0x10000000000000006) >> 64;\\n }\\n if (x & 0x4 > 0) {\\n result = (result * 0x10000000000000003) >> 64;\\n }\\n if (x & 0x2 > 0) {\\n result = (result * 0x10000000000000001) >> 64;\\n }\\n if (x & 0x1 > 0) {\\n result = (result * 0x10000000000000001) >> 64;\\n }\\n }\\n\\n // In the code snippet below, two operations are executed simultaneously:\\n //\\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\\n //\\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\\n // integer part, $2^n$.\\n result *= UNIT;\\n result >>= (191 - (x >> 64));\\n }\\n}\\n\\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\\n///\\n/// @dev See the note on \\\"msb\\\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\\n///\\n/// Each step in this implementation is equivalent to this high-level code:\\n///\\n/// ```solidity\\n/// if (x >= 2 ** 128) {\\n/// x >>= 128;\\n/// result += 128;\\n/// }\\n/// ```\\n///\\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\\n///\\n/// The Yul instructions used below are:\\n///\\n/// - \\\"gt\\\" is \\\"greater than\\\"\\n/// - \\\"or\\\" is the OR bitwise operator\\n/// - \\\"shl\\\" is \\\"shift left\\\"\\n/// - \\\"shr\\\" is \\\"shift right\\\"\\n///\\n/// @param x The uint256 number for which to find the index of the most significant bit.\\n/// @return result The index of the most significant bit as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction msb(uint256 x) pure returns (uint256 result) {\\n // 2^128\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^64\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^32\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(5, gt(x, 0xFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^16\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(4, gt(x, 0xFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^8\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(3, gt(x, 0xFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^4\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(2, gt(x, 0xF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^2\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(1, gt(x, 0x3))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^1\\n // No need to shift x any more.\\n assembly (\\\"memory-safe\\\") {\\n let factor := gt(x, 0x1)\\n result := or(result, factor)\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f7denominator with 512-bit precision.\\n///\\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - The denominator must not be zero.\\n/// - The result must fit in uint256.\\n///\\n/// @param x The multiplicand as a uint256.\\n/// @param y The multiplier as a uint256.\\n/// @param denominator The divisor as a uint256.\\n/// @return result The result as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly (\\\"memory-safe\\\") {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n unchecked {\\n return prod0 / denominator;\\n }\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n if (prod1 >= denominator) {\\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\\n }\\n\\n ////////////////////////////////////////////////////////////////////////////\\n // 512 by 256 division\\n ////////////////////////////////////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly (\\\"memory-safe\\\") {\\n // Compute remainder using the mulmod Yul instruction.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512-bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n unchecked {\\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\\n uint256 lpotdod = denominator & (~denominator + 1);\\n uint256 flippedLpotdod;\\n\\n assembly (\\\"memory-safe\\\") {\\n // Factor powers of two out of denominator.\\n denominator := div(denominator, lpotdod)\\n\\n // Divide [prod1 prod0] by lpotdod.\\n prod0 := div(prod0, lpotdod)\\n\\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * flippedLpotdod;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\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 works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\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^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f71e18 with 512-bit precision.\\n///\\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\\n///\\n/// Notes:\\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\\n/// - The result is rounded toward zero.\\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\\n///\\n/// $$\\n/// \\\\begin{cases}\\n/// x * y = MAX\\\\_UINT256 * UNIT \\\\\\\\\\n/// (x * y) \\\\% UNIT \\\\geq \\\\frac{UNIT}{2}\\n/// \\\\end{cases}\\n/// $$\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {mulDiv}.\\n/// - The result must fit in uint256.\\n///\\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\\n uint256 prod0;\\n uint256 prod1;\\n assembly (\\\"memory-safe\\\") {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n if (prod1 == 0) {\\n unchecked {\\n return prod0 / UNIT;\\n }\\n }\\n\\n if (prod1 >= UNIT) {\\n revert PRBMath_MulDiv18_Overflow(x, y);\\n }\\n\\n uint256 remainder;\\n assembly (\\\"memory-safe\\\") {\\n remainder := mulmod(x, y, UNIT)\\n result :=\\n mul(\\n or(\\n div(sub(prod0, remainder), UNIT_LPOTD),\\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\\n ),\\n UNIT_INVERSE\\n )\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f7denominator with 512-bit precision.\\n///\\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {mulDiv}.\\n/// - None of the inputs can be `type(int256).min`.\\n/// - The result must fit in int256.\\n///\\n/// @param x The multiplicand as an int256.\\n/// @param y The multiplier as an int256.\\n/// @param denominator The divisor as an int256.\\n/// @return result The result as an int256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\\n revert PRBMath_MulDivSigned_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x, y and the denominator.\\n uint256 xAbs;\\n uint256 yAbs;\\n uint256 dAbs;\\n unchecked {\\n xAbs = x < 0 ? uint256(-x) : uint256(x);\\n yAbs = y < 0 ? uint256(-y) : uint256(y);\\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\\n }\\n\\n // Compute the absolute value of x*y\\u00f7denominator. The result must fit in int256.\\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\\n if (resultAbs > uint256(type(int256).max)) {\\n revert PRBMath_MulDivSigned_Overflow(x, y);\\n }\\n\\n // Get the signs of x, y and the denominator.\\n uint256 sx;\\n uint256 sy;\\n uint256 sd;\\n assembly (\\\"memory-safe\\\") {\\n // \\\"sgt\\\" is the \\\"signed greater than\\\" assembly instruction and \\\"sub(0,1)\\\" is -1 in two's complement.\\n sx := sgt(x, sub(0, 1))\\n sy := sgt(y, sub(0, 1))\\n sd := sgt(denominator, sub(0, 1))\\n }\\n\\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\\n // If there are, the result should be negative. Otherwise, it should be positive.\\n unchecked {\\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\\n }\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - If x is not a perfect square, the result is rounded down.\\n/// - Credits to OpenZeppelin for the explanations in comments below.\\n///\\n/// @param x The uint256 number for which to calculate the square root.\\n/// @return result The result as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(uint256 x) pure returns (uint256 result) {\\n if (x == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of x is a power of 2 such that we have:\\n //\\n // $$\\n // msb(x) <= x <= 2*msb(x)$\\n // $$\\n //\\n // We write $msb(x)$ as $2^k$, and we get:\\n //\\n // $$\\n // k = log_2(x)\\n // $$\\n //\\n // Thus, we can write the initial inequality as:\\n //\\n // $$\\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\\\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\\\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\\n // $$\\n //\\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\\n uint256 xAux = uint256(x);\\n result = 1;\\n if (xAux >= 2 ** 128) {\\n xAux >>= 128;\\n result <<= 64;\\n }\\n if (xAux >= 2 ** 64) {\\n xAux >>= 64;\\n result <<= 32;\\n }\\n if (xAux >= 2 ** 32) {\\n xAux >>= 32;\\n result <<= 16;\\n }\\n if (xAux >= 2 ** 16) {\\n xAux >>= 16;\\n result <<= 8;\\n }\\n if (xAux >= 2 ** 8) {\\n xAux >>= 8;\\n result <<= 4;\\n }\\n if (xAux >= 2 ** 4) {\\n xAux >>= 4;\\n result <<= 2;\\n }\\n if (xAux >= 2 ** 2) {\\n result <<= 1;\\n }\\n\\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\\n // precision into the expected uint128 result.\\n unchecked {\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n\\n // If x is not a perfect square, round the result toward zero.\\n uint256 roundedResult = x / result;\\n if (result >= roundedResult) {\\n result = roundedResult;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaa374e2c26cc93e8c22a6953804ee05f811597ef5fa82f76824378b22944778b\",\"license\":\"MIT\"},\"@prb/math/src/UD2x18.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n/*\\n\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2588\\u2588\\u2554\\u2550\\u2550\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u2588\\u2588\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u255a\\u2550\\u255d \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\n\\n\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u255d\\n\\n*/\\n\\nimport \\\"./ud2x18/Casting.sol\\\";\\nimport \\\"./ud2x18/Constants.sol\\\";\\nimport \\\"./ud2x18/Errors.sol\\\";\\nimport \\\"./ud2x18/ValueType.sol\\\";\\n\",\"keccak256\":\"0xfb624e24cd8bb790fa08e7827819de85504a86e20e961fa4ad126c65b6d90641\",\"license\":\"MIT\"},\"@prb/math/src/UD60x18.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n/*\\n\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2588\\u2588\\u2554\\u2550\\u2550\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u2588\\u2588\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u255a\\u2550\\u255d \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\n\\n\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2588\\u2588\\u2588\\u2588\\u2557\\u255a\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551 \\u255a\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u255d \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u255d\\n\\n*/\\n\\nimport \\\"./ud60x18/Casting.sol\\\";\\nimport \\\"./ud60x18/Constants.sol\\\";\\nimport \\\"./ud60x18/Conversions.sol\\\";\\nimport \\\"./ud60x18/Errors.sol\\\";\\nimport \\\"./ud60x18/Helpers.sol\\\";\\nimport \\\"./ud60x18/Math.sol\\\";\\nimport \\\"./ud60x18/ValueType.sol\\\";\\n\",\"keccak256\":\"0xb98c6f74275914d279e8af6c502c2b1f50d5f6e1ed418d3b0153f5a193206c48\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts an SD1x18 number into SD59x18.\\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\\n}\\n\\n/// @notice Casts an SD1x18 number into UD2x18.\\n/// - x must be positive.\\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\\n }\\n result = UD2x18.wrap(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into UD60x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\\n }\\n result = UD60x18.wrap(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint256.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\\n }\\n result = uint256(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\\n }\\n result = uint128(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\\n }\\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\\n }\\n result = uint40(uint64(xInt));\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\\n result = SD1x18.wrap(x);\\n}\\n\\n/// @notice Unwraps an SD1x18 number into int64.\\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\\n result = SD1x18.unwrap(x);\\n}\\n\\n/// @notice Wraps an int64 number into SD1x18.\\nfunction wrap(int64 x) pure returns (SD1x18 result) {\\n result = SD1x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x9e49e2b37c1bb845861740805edaaef3fe951a7b96eef16ce84fbf76e8278670\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @dev Euler's number as an SD1x18 number.\\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum value an SD1x18 number can have.\\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\\n\\n/// @dev The maximum value an SD1x18 number can have.\\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\\n\\n/// @dev PI as an SD1x18 number.\\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of SD1x18.\\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\\nint64 constant uUNIT = 1e18;\\n\",\"keccak256\":\"0x6496165b80552785a4b65a239b96e2a5fedf62fe54f002eeed72d75e566d7585\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\\n\",\"keccak256\":\"0x836cb42ba619ca369fd4765bc47fefc3c3621369c5861882af14660aca5057ee\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\n\\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\\n/// storage.\\ntype SD1x18 is int64;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD59x18,\\n Casting.intoUD2x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for SD1x18 global;\\n\",\"keccak256\":\"0x2f86f1aa9fca42f40808b51a879b406ac51817647bdb9642f8a79dd8fdb754a7\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { MAX_UINT128, MAX_UINT40 } from \\\"../Common.sol\\\";\\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { uMAX_UD2x18 } from \\\"../ud2x18/Constants.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts an SD59x18 number into int256.\\n/// @dev This is basically a functional alias for {unwrap}.\\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\\n result = SD59x18.unwrap(x);\\n}\\n\\n/// @notice Casts an SD59x18 number into SD1x18.\\n/// @dev Requirements:\\n/// - x must be greater than or equal to `uMIN_SD1x18`.\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < uMIN_SD1x18) {\\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\\n }\\n if (xInt > uMAX_SD1x18) {\\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into UD2x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `uMAX_UD2x18`.\\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\\n }\\n if (xInt > int256(uint256(uMAX_UD2x18))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\\n }\\n result = UD2x18.wrap(uint64(uint256(xInt)));\\n}\\n\\n/// @notice Casts an SD59x18 number into UD60x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\\n }\\n result = UD60x18.wrap(uint256(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into uint256.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\\n }\\n result = uint256(xInt);\\n}\\n\\n/// @notice Casts an SD59x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `uMAX_UINT128`.\\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\\n }\\n if (xInt > int256(uint256(MAX_UINT128))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\\n }\\n result = uint128(uint256(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\\n }\\n if (xInt > int256(uint256(MAX_UINT40))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(uint256(xInt));\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\\n/// @notice Unwraps an SD59x18 number into int256.\\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\\n result = SD59x18.unwrap(x);\\n}\\n\\n/// @notice Wraps an int256 number into SD59x18.\\nfunction wrap(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x3b21b60ec2998c3ae32f647412da51d3683b3f183a807198cc8d157499484f99\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n// NOTICE: the \\\"u\\\" prefix stands for \\\"unwrapped\\\".\\n\\n/// @dev Euler's number as an SD59x18 number.\\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum input permitted in {exp}.\\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\\n\\n/// @dev Any value less than this returns 0 in {exp}.\\nint256 constant uEXP_MIN_THRESHOLD = -41_446531673892822322;\\nSD59x18 constant EXP_MIN_THRESHOLD = SD59x18.wrap(uEXP_MIN_THRESHOLD);\\n\\n/// @dev The maximum input permitted in {exp2}.\\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\\n\\n/// @dev Any value less than this returns 0 in {exp2}.\\nint256 constant uEXP2_MIN_THRESHOLD = -59_794705707972522261;\\nSD59x18 constant EXP2_MIN_THRESHOLD = SD59x18.wrap(uEXP2_MIN_THRESHOLD);\\n\\n/// @dev Half the UNIT number.\\nint256 constant uHALF_UNIT = 0.5e18;\\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\\n\\n/// @dev $log_2(10)$ as an SD59x18 number.\\nint256 constant uLOG2_10 = 3_321928094887362347;\\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\\n\\n/// @dev $log_2(e)$ as an SD59x18 number.\\nint256 constant uLOG2_E = 1_442695040888963407;\\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\\n\\n/// @dev The maximum value an SD59x18 number can have.\\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\\n\\n/// @dev The maximum whole value an SD59x18 number can have.\\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\\n\\n/// @dev The minimum value an SD59x18 number can have.\\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\\n\\n/// @dev The minimum whole value an SD59x18 number can have.\\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\\n\\n/// @dev PI as an SD59x18 number.\\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of SD59x18.\\nint256 constant uUNIT = 1e18;\\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\\n\\n/// @dev The unit number squared.\\nint256 constant uUNIT_SQUARED = 1e36;\\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\\n\\n/// @dev Zero as an SD59x18 number.\\nSD59x18 constant ZERO = SD59x18.wrap(0);\\n\",\"keccak256\":\"0x9bcb8dd6b3e886d140ad1c32747a4f6d29a492529ceb835be878ae837aa6cc3a\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Abs_MinSD59x18();\\n\\n/// @notice Thrown when ceiling a number overflows SD59x18.\\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\\n\\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Div_InputTooSmall();\\n\\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\\n\\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\\n\\n/// @notice Thrown when flooring a number underflows SD59x18.\\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\\n\\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Mul_InputTooSmall();\\n\\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\\n\\n/// @notice Thrown when taking the square root of a negative number.\\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\\n\\n/// @notice Thrown when the calculating the square root overflows SD59x18.\\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\\n\",\"keccak256\":\"0xa6d00fe5efa215ac0df25c896e3da99a12fb61e799644b2ec32da947313d3db4\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() + y.unwrap());\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() & bits);\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() & y.unwrap());\\n}\\n\\n/// @notice Implements the equal (=) operation in the SD59x18 type.\\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() == y.unwrap();\\n}\\n\\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() > y.unwrap();\\n}\\n\\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() >= y.unwrap();\\n}\\n\\n/// @notice Implements a zero comparison check function in the SD59x18 type.\\nfunction isZero(SD59x18 x) pure returns (bool result) {\\n result = x.unwrap() == 0;\\n}\\n\\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() << bits);\\n}\\n\\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() < y.unwrap();\\n}\\n\\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() <= y.unwrap();\\n}\\n\\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() % y.unwrap());\\n}\\n\\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() != y.unwrap();\\n}\\n\\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(~x.unwrap());\\n}\\n\\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() | y.unwrap());\\n}\\n\\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() >> bits);\\n}\\n\\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() - y.unwrap());\\n}\\n\\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(-x.unwrap());\\n}\\n\\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() + y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() - y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(-x.unwrap());\\n }\\n}\\n\\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() ^ y.unwrap());\\n}\\n\",\"keccak256\":\"0x208570f1657cf730cb6c3d81aa14030e0d45cf906cdedea5059369d7df4bb716\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport {\\n uEXP_MAX_INPUT,\\n uEXP2_MAX_INPUT,\\n uEXP_MIN_THRESHOLD,\\n uEXP2_MIN_THRESHOLD,\\n uHALF_UNIT,\\n uLOG2_10,\\n uLOG2_E,\\n uMAX_SD59x18,\\n uMAX_WHOLE_SD59x18,\\n uMIN_SD59x18,\\n uMIN_WHOLE_SD59x18,\\n UNIT,\\n uUNIT,\\n uUNIT_SQUARED,\\n ZERO\\n} from \\\"./Constants.sol\\\";\\nimport { wrap } from \\\"./Helpers.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Calculates the absolute value of x.\\n///\\n/// @dev Requirements:\\n/// - x must be greater than `MIN_SD59x18`.\\n///\\n/// @param x The SD59x18 number for which to calculate the absolute value.\\n/// @param result The absolute value of x as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\\n }\\n result = xInt < 0 ? wrap(-xInt) : x;\\n}\\n\\n/// @notice Calculates the arithmetic average of x and y.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// @param x The first operand as an SD59x18 number.\\n/// @param y The second operand as an SD59x18 number.\\n/// @return result The arithmetic average as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n\\n unchecked {\\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\\n int256 sum = (xInt >> 1) + (yInt >> 1);\\n\\n if (sum < 0) {\\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\\n assembly (\\\"memory-safe\\\") {\\n result := add(sum, and(or(xInt, yInt), 1))\\n }\\n } else {\\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\\n result = wrap(sum + (xInt & yInt & 1));\\n }\\n }\\n}\\n\\n/// @notice Yields the smallest whole number greater than or equal to x.\\n///\\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\\n///\\n/// @param x The SD59x18 number to ceil.\\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt > uMAX_WHOLE_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\\n }\\n\\n int256 remainder = xInt % uUNIT;\\n if (remainder == 0) {\\n result = x;\\n } else {\\n unchecked {\\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\\n int256 resultInt = xInt - remainder;\\n if (xInt > 0) {\\n resultInt += uUNIT;\\n }\\n result = wrap(resultInt);\\n }\\n }\\n}\\n\\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\\n///\\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\\n/// values separately.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n/// - None of the inputs can be `MIN_SD59x18`.\\n/// - The denominator must not be zero.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The numerator as an SD59x18 number.\\n/// @param y The denominator as an SD59x18 number.\\n/// @param result The quotient as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x and y.\\n uint256 xAbs;\\n uint256 yAbs;\\n unchecked {\\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\\n }\\n\\n // Compute the absolute value (x*UNIT\\u00f7y). The resulting value must fit in SD59x18.\\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\\n }\\n\\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\\n // negative, 0 for positive or zero).\\n bool sameSign = (xInt ^ yInt) > -1;\\n\\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\\n unchecked {\\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\\n }\\n}\\n\\n/// @notice Calculates the natural exponent of x using the following formula:\\n///\\n/// $$\\n/// e^x = 2^{x * log_2{e}}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {exp2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}.\\n/// - x must be less than 133_084258667509499441.\\n///\\n/// @param x The exponent as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n\\n // Any input less than the threshold returns zero.\\n // This check also prevents an overflow for very small numbers.\\n if (xInt < uEXP_MIN_THRESHOLD) {\\n return ZERO;\\n }\\n\\n // This check prevents values greater than 192e18 from being passed to {exp2}.\\n if (xInt > uEXP_MAX_INPUT) {\\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Inline the fixed-point multiplication to save gas.\\n int256 doubleUnitProduct = xInt * uLOG2_E;\\n result = exp2(wrap(doubleUnitProduct / uUNIT));\\n }\\n}\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\\n///\\n/// $$\\n/// 2^{-x} = \\\\frac{1}{2^x}\\n/// $$\\n///\\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\\n///\\n/// Notes:\\n/// - If x is less than -59_794705707972522261, the result is zero.\\n///\\n/// Requirements:\\n/// - x must be less than 192e18.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The exponent as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n // The inverse of any number less than the threshold is truncated to zero.\\n if (xInt < uEXP2_MIN_THRESHOLD) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Inline the fixed-point inversion to save gas.\\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\\n }\\n } else {\\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\\n if (xInt > uEXP2_MAX_INPUT) {\\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Convert x to the 192.64-bit fixed-point format.\\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\\n\\n // It is safe to cast the result to int256 due to the checks above.\\n result = wrap(int256(Common.exp2(x_192x64)));\\n }\\n }\\n}\\n\\n/// @notice Yields the greatest whole number less than or equal to x.\\n///\\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\\n///\\n/// @param x The SD59x18 number to floor.\\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < uMIN_WHOLE_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\\n }\\n\\n int256 remainder = xInt % uUNIT;\\n if (remainder == 0) {\\n result = x;\\n } else {\\n unchecked {\\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\\n int256 resultInt = xInt - remainder;\\n if (xInt < 0) {\\n resultInt -= uUNIT;\\n }\\n result = wrap(resultInt);\\n }\\n }\\n}\\n\\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\\n/// of the radix point for negative numbers.\\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\\n/// @param x The SD59x18 number to get the fractional part of.\\n/// @param result The fractional part of x as an SD59x18 number.\\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() % uUNIT);\\n}\\n\\n/// @notice Calculates the geometric mean of x and y, i.e. $\\\\sqrt{x * y}$.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x * y must fit in SD59x18.\\n/// - x * y must not be negative, since complex numbers are not supported.\\n///\\n/// @param x The first operand as an SD59x18 number.\\n/// @param y The second operand as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == 0 || yInt == 0) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\\n int256 xyInt = xInt * yInt;\\n if (xyInt / xInt != yInt) {\\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\\n }\\n\\n // The product must not be negative, since complex numbers are not supported.\\n if (xyInt < 0) {\\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\\n }\\n\\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\\n // during multiplication. See the comments in {Common.sqrt}.\\n uint256 resultUint = Common.sqrt(uint256(xyInt));\\n result = wrap(int256(resultUint));\\n }\\n}\\n\\n/// @notice Calculates the inverse of x.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must not be zero.\\n///\\n/// @param x The SD59x18 number for which to calculate the inverse.\\n/// @return result The inverse as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(uUNIT_SQUARED / x.unwrap());\\n}\\n\\n/// @notice Calculates the natural logarithm of x using the following formula:\\n///\\n/// $$\\n/// ln{x} = log_2{x} / log_2{e}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\\n/// @return result The natural logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\\n // {log2} can return is ~195_205294292027477728.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\\n}\\n\\n/// @notice Calculates the common logarithm of x using the following formula:\\n///\\n/// $$\\n/// log_{10}{x} = log_2{x} / log_2{10}\\n/// $$\\n///\\n/// However, if x is an exact power of ten, a hard coded value is returned.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The SD59x18 number for which to calculate the common logarithm.\\n/// @return result The common logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\\n }\\n\\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\\n // prettier-ignore\\n assembly (\\\"memory-safe\\\") {\\n switch x\\n case 1 { result := mul(uUNIT, sub(0, 18)) }\\n case 10 { result := mul(uUNIT, sub(1, 18)) }\\n case 100 { result := mul(uUNIT, sub(2, 18)) }\\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\\n case 1000000000000000000 { result := 0 }\\n case 10000000000000000000 { result := uUNIT }\\n case 100000000000000000000 { result := mul(uUNIT, 2) }\\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\\n default { result := uMAX_SD59x18 }\\n }\\n\\n if (result.unwrap() == uMAX_SD59x18) {\\n unchecked {\\n // Inline the fixed-point division to save gas.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\\n }\\n }\\n}\\n\\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\\n///\\n/// $$\\n/// log_2{x} = n + log_2{y}, \\\\text{ where } y = x*2^{-n}, \\\\ y \\\\in [1, 2)\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, the input is inverted:\\n///\\n/// $$\\n/// log_2{x} = -log_2{\\\\frac{1}{x}}\\n/// $$\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\\n///\\n/// Notes:\\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\\n///\\n/// Requirements:\\n/// - x must be greater than zero.\\n///\\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\\n/// @return result The binary logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt <= 0) {\\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\\n }\\n\\n unchecked {\\n int256 sign;\\n if (xInt >= uUNIT) {\\n sign = 1;\\n } else {\\n sign = -1;\\n // Inline the fixed-point inversion to save gas.\\n xInt = uUNIT_SQUARED / xInt;\\n }\\n\\n // Calculate the integer part of the logarithm.\\n uint256 n = Common.msb(uint256(xInt / uUNIT));\\n\\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\\n int256 resultInt = int256(n) * uUNIT;\\n\\n // Calculate $y = x * 2^{-n}$.\\n int256 y = xInt >> n;\\n\\n // If y is the unit number, the fractional part is zero.\\n if (y == uUNIT) {\\n return wrap(resultInt * sign);\\n }\\n\\n // Calculate the fractional part via the iterative approximation.\\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\\n int256 DOUBLE_UNIT = 2e18;\\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\\n y = (y * y) / uUNIT;\\n\\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\\n if (y >= DOUBLE_UNIT) {\\n // Add the 2^{-m} factor to the logarithm.\\n resultInt = resultInt + delta;\\n\\n // Halve y, which corresponds to z/2 in the Wikipedia article.\\n y >>= 1;\\n }\\n }\\n resultInt *= sign;\\n result = wrap(resultInt);\\n }\\n}\\n\\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv18}.\\n/// - None of the inputs can be `MIN_SD59x18`.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The multiplicand as an SD59x18 number.\\n/// @param y The multiplier as an SD59x18 number.\\n/// @return result The product as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x and y.\\n uint256 xAbs;\\n uint256 yAbs;\\n unchecked {\\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\\n }\\n\\n // Compute the absolute value (x*y\\u00f7UNIT). The resulting value must fit in SD59x18.\\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\\n }\\n\\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\\n // negative, 0 for positive or zero).\\n bool sameSign = (xInt ^ yInt) > -1;\\n\\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\\n unchecked {\\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\\n }\\n}\\n\\n/// @notice Raises x to the power of y using the following formula:\\n///\\n/// $$\\n/// x^y = 2^{log_2{x} * y}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\\n///\\n/// @param x The base as an SD59x18 number.\\n/// @param y Exponent to raise x to, as an SD59x18 number\\n/// @return result x raised to power y, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n\\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\\n if (xInt == 0) {\\n return yInt == 0 ? UNIT : ZERO;\\n }\\n // If x is `UNIT`, the result is always `UNIT`.\\n else if (xInt == uUNIT) {\\n return UNIT;\\n }\\n\\n // If y is zero, the result is always `UNIT`.\\n if (yInt == 0) {\\n return UNIT;\\n }\\n // If y is `UNIT`, the result is always x.\\n else if (yInt == uUNIT) {\\n return x;\\n }\\n\\n // Calculate the result using the formula.\\n result = exp2(mul(log2(x), y));\\n}\\n\\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\\n/// algorithm \\\"exponentiation by squaring\\\".\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The base as an SD59x18 number.\\n/// @param y The exponent as a uint256.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\\n uint256 xAbs = uint256(abs(x).unwrap());\\n\\n // Calculate the first iteration of the loop in advance.\\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\\n\\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\\n uint256 yAux = y;\\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\\n xAbs = Common.mulDiv18(xAbs, xAbs);\\n\\n // Equivalent to `y % 2 == 1`.\\n if (yAux & 1 > 0) {\\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\\n }\\n }\\n\\n // The result must fit in SD59x18.\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\\n }\\n\\n unchecked {\\n // Is the base negative and the exponent odd? If yes, the result should be negative.\\n int256 resultInt = int256(resultAbs);\\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\\n if (isNegative) {\\n resultInt = -resultInt;\\n }\\n result = wrap(resultInt);\\n }\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - Only the positive root is returned.\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x cannot be negative, since complex numbers are not supported.\\n/// - x must be less than `MAX_SD59x18 / UNIT`.\\n///\\n/// @param x The SD59x18 number for which to calculate the square root.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\\n }\\n if (xInt > uMAX_SD59x18 / uUNIT) {\\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\\n }\\n\\n unchecked {\\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\\n // In this case, the two numbers are both the square root.\\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\\n result = wrap(int256(resultUint));\\n }\\n}\\n\",\"keccak256\":\"0xa074831139fc89ca0e5a36086b30eb50896bb6770cd5823461b1f2769017d2f0\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\nimport \\\"./Helpers.sol\\\" as Helpers;\\nimport \\\"./Math.sol\\\" as Math;\\n\\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type int256.\\ntype SD59x18 is int256;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoInt256,\\n Casting.intoSD1x18,\\n Casting.intoUD2x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Math.abs,\\n Math.avg,\\n Math.ceil,\\n Math.div,\\n Math.exp,\\n Math.exp2,\\n Math.floor,\\n Math.frac,\\n Math.gm,\\n Math.inv,\\n Math.log10,\\n Math.log2,\\n Math.ln,\\n Math.mul,\\n Math.pow,\\n Math.powu,\\n Math.sqrt\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n HELPER FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Helpers.add,\\n Helpers.and,\\n Helpers.eq,\\n Helpers.gt,\\n Helpers.gte,\\n Helpers.isZero,\\n Helpers.lshift,\\n Helpers.lt,\\n Helpers.lte,\\n Helpers.mod,\\n Helpers.neq,\\n Helpers.not,\\n Helpers.or,\\n Helpers.rshift,\\n Helpers.sub,\\n Helpers.uncheckedAdd,\\n Helpers.uncheckedSub,\\n Helpers.uncheckedUnary,\\n Helpers.xor\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n OPERATORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes it possible to use these operators on the SD59x18 type.\\nusing {\\n Helpers.add as +,\\n Helpers.and2 as &,\\n Math.div as /,\\n Helpers.eq as ==,\\n Helpers.gt as >,\\n Helpers.gte as >=,\\n Helpers.lt as <,\\n Helpers.lte as <=,\\n Helpers.mod as %,\\n Math.mul as *,\\n Helpers.neq as !=,\\n Helpers.not as ~,\\n Helpers.or as |,\\n Helpers.sub as -,\\n Helpers.unary as -,\\n Helpers.xor as ^\\n} for SD59x18 global;\\n\",\"keccak256\":\"0xe03112d145dcd5863aff24e5f381debaae29d446acd5666f3d640e3d9af738d7\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport { uMAX_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts a UD2x18 number into SD1x18.\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\\n uint64 xUint = UD2x18.unwrap(x);\\n if (xUint > uint64(uMAX_SD1x18)) {\\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(xUint));\\n}\\n\\n/// @notice Casts a UD2x18 number into SD59x18.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\\n}\\n\\n/// @notice Casts a UD2x18 number into UD60x18.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint128.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\\n result = uint128(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint256.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\\n result = uint256(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\\n uint64 xUint = UD2x18.unwrap(x);\\n if (xUint > uint64(Common.MAX_UINT40)) {\\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(xUint);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\\n result = UD2x18.wrap(x);\\n}\\n\\n/// @notice Unwrap a UD2x18 number into uint64.\\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\\n result = UD2x18.unwrap(x);\\n}\\n\\n/// @notice Wraps a uint64 number into UD2x18.\\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\\n result = UD2x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x9b1a35d432ef951a415fae8098b3c609a99b630a3d5464b3c8e1efa8893eea07\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @dev Euler's number as a UD2x18 number.\\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum value a UD2x18 number can have.\\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\\n\\n/// @dev PI as a UD2x18 number.\\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of UD2x18.\\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\\nuint64 constant uUNIT = 1e18;\\n\",\"keccak256\":\"0x29b0e050c865899e1fb9022b460a7829cdee248c44c4299f068ba80695eec3fc\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\\n\\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\\n\",\"keccak256\":\"0xdf1e22f0b4c8032bcc8b7f63fe3984e1387f3dc7b2e9ab381822249f75376d33\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\n\\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\\n/// storage.\\ntype UD2x18 is uint64;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD1x18,\\n Casting.intoSD59x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for UD2x18 global;\\n\",\"keccak256\":\"0x2802edc9869db116a0b5c490cc5f8554742f747183fa30ac5e9c80bb967e61a1\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { MAX_UINT128, MAX_UINT40 } from \\\"../Common.sol\\\";\\nimport { uMAX_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { uMAX_SD59x18 } from \\\"../sd59x18/Constants.sol\\\";\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { uMAX_UD2x18 } from \\\"../ud2x18/Constants.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts a UD60x18 number into SD1x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uint256(int256(uMAX_SD1x18))) {\\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(uint64(xUint)));\\n}\\n\\n/// @notice Casts a UD60x18 number into UD2x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_UD2x18`.\\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uMAX_UD2x18) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\\n }\\n result = UD2x18.wrap(uint64(xUint));\\n}\\n\\n/// @notice Casts a UD60x18 number into SD59x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_SD59x18`.\\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uint256(uMAX_SD59x18)) {\\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\\n }\\n result = SD59x18.wrap(int256(xUint));\\n}\\n\\n/// @notice Casts a UD60x18 number into uint128.\\n/// @dev This is basically an alias for {unwrap}.\\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x);\\n}\\n\\n/// @notice Casts a UD60x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT128`.\\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > MAX_UINT128) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\\n }\\n result = uint128(xUint);\\n}\\n\\n/// @notice Casts a UD60x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > MAX_UINT40) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(xUint);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\\n/// @notice Unwraps a UD60x18 number into uint256.\\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x);\\n}\\n\\n/// @notice Wraps a uint256 number into the UD60x18 value type.\\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x5bb532da36921cbdac64d1f16de5d366ef1f664502e3b7c07d0ad06917551f85\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n// NOTICE: the \\\"u\\\" prefix stands for \\\"unwrapped\\\".\\n\\n/// @dev Euler's number as a UD60x18 number.\\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum input permitted in {exp}.\\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\\n\\n/// @dev The maximum input permitted in {exp2}.\\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\\n\\n/// @dev Half the UNIT number.\\nuint256 constant uHALF_UNIT = 0.5e18;\\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\\n\\n/// @dev $log_2(10)$ as a UD60x18 number.\\nuint256 constant uLOG2_10 = 3_321928094887362347;\\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\\n\\n/// @dev $log_2(e)$ as a UD60x18 number.\\nuint256 constant uLOG2_E = 1_442695040888963407;\\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\\n\\n/// @dev The maximum value a UD60x18 number can have.\\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\\n\\n/// @dev The maximum whole value a UD60x18 number can have.\\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\\n\\n/// @dev PI as a UD60x18 number.\\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of UD60x18.\\nuint256 constant uUNIT = 1e18;\\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\\n\\n/// @dev The unit number squared.\\nuint256 constant uUNIT_SQUARED = 1e36;\\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\\n\\n/// @dev Zero as a UD60x18 number.\\nUD60x18 constant ZERO = UD60x18.wrap(0);\\n\",\"keccak256\":\"0x2b80d26153d3fdcfb3a9ca772d9309d31ed1275f5b8b54c3ffb54d3652b37d90\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Conversions.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { uMAX_UD60x18, uUNIT } from \\\"./Constants.sol\\\";\\nimport { PRBMath_UD60x18_Convert_Overflow } from \\\"./Errors.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\\n/// @dev The result is rounded toward zero.\\n/// @param x The UD60x18 number to convert.\\n/// @return result The same number in basic integer form.\\nfunction convert(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x) / uUNIT;\\n}\\n\\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\\n///\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\\n///\\n/// @param x The basic integer to convert.\\n/// @param result The same number converted to UD60x18.\\nfunction convert(uint256 x) pure returns (UD60x18 result) {\\n if (x > uMAX_UD60x18 / uUNIT) {\\n revert PRBMath_UD60x18_Convert_Overflow(x);\\n }\\n unchecked {\\n result = UD60x18.wrap(x * uUNIT);\\n }\\n}\\n\",\"keccak256\":\"0xaf7fc2523413822de3b66ba339fe2884fb3b8c6f6cf38ec90a2c3e3aae71df6b\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when ceiling a number overflows UD60x18.\\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\\n\\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\\n\\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when taking the logarithm of a number less than 1.\\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\\n\\n/// @notice Thrown when calculating the square root overflows UD60x18.\\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\\n\",\"keccak256\":\"0xa8c60d4066248df22c49c882873efbc017344107edabc48c52209abbc39cb1e3\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() + y.unwrap());\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() & bits);\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() & y.unwrap());\\n}\\n\\n/// @notice Implements the equal operation (==) in the UD60x18 type.\\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() == y.unwrap();\\n}\\n\\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() > y.unwrap();\\n}\\n\\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() >= y.unwrap();\\n}\\n\\n/// @notice Implements a zero comparison check function in the UD60x18 type.\\nfunction isZero(UD60x18 x) pure returns (bool result) {\\n // This wouldn't work if x could be negative.\\n result = x.unwrap() == 0;\\n}\\n\\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() << bits);\\n}\\n\\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() < y.unwrap();\\n}\\n\\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() <= y.unwrap();\\n}\\n\\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() % y.unwrap());\\n}\\n\\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() != y.unwrap();\\n}\\n\\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\\n result = wrap(~x.unwrap());\\n}\\n\\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() | y.unwrap());\\n}\\n\\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() >> bits);\\n}\\n\\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() - y.unwrap());\\n}\\n\\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() + y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() - y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() ^ y.unwrap());\\n}\\n\",\"keccak256\":\"0xf5faff881391d2c060029499a666cc5f0bea90a213150bb476fae8f02a5df268\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport {\\n uEXP_MAX_INPUT,\\n uEXP2_MAX_INPUT,\\n uHALF_UNIT,\\n uLOG2_10,\\n uLOG2_E,\\n uMAX_UD60x18,\\n uMAX_WHOLE_UD60x18,\\n UNIT,\\n uUNIT,\\n uUNIT_SQUARED,\\n ZERO\\n} from \\\"./Constants.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Calculates the arithmetic average of x and y using the following formula:\\n///\\n/// $$\\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\\n/// $$\\n///\\n/// In English, this is what this formula does:\\n///\\n/// 1. AND x and y.\\n/// 2. Calculate half of XOR x and y.\\n/// 3. Add the two results together.\\n///\\n/// This technique is known as SWAR, which stands for \\\"SIMD within a register\\\". You can read more about it here:\\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// @param x The first operand as a UD60x18 number.\\n/// @param y The second operand as a UD60x18 number.\\n/// @return result The arithmetic average as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n unchecked {\\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\\n }\\n}\\n\\n/// @notice Yields the smallest whole number greater than or equal to x.\\n///\\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\\n///\\n/// @param x The UD60x18 number to ceil.\\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n if (xUint > uMAX_WHOLE_UD60x18) {\\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\\n }\\n\\n assembly (\\\"memory-safe\\\") {\\n // Equivalent to `x % UNIT`.\\n let remainder := mod(x, uUNIT)\\n\\n // Equivalent to `UNIT - remainder`.\\n let delta := sub(uUNIT, remainder)\\n\\n // Equivalent to `x + remainder > 0 ? delta : 0`.\\n result := add(x, mul(delta, gt(remainder, 0)))\\n }\\n}\\n\\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\\n///\\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n///\\n/// @param x The numerator as a UD60x18 number.\\n/// @param y The denominator as a UD60x18 number.\\n/// @param result The quotient as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\\n}\\n\\n/// @notice Calculates the natural exponent of x using the following formula:\\n///\\n/// $$\\n/// e^x = 2^{x * log_2{e}}\\n/// $$\\n///\\n/// @dev Requirements:\\n/// - x must be less than 133_084258667509499441.\\n///\\n/// @param x The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n // This check prevents values greater than 192e18 from being passed to {exp2}.\\n if (xUint > uEXP_MAX_INPUT) {\\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Inline the fixed-point multiplication to save gas.\\n uint256 doubleUnitProduct = xUint * uLOG2_E;\\n result = exp2(wrap(doubleUnitProduct / uUNIT));\\n }\\n}\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method.\\n///\\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\\n///\\n/// Requirements:\\n/// - x must be less than 192e18.\\n/// - The result must fit in UD60x18.\\n///\\n/// @param x The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\\n if (xUint > uEXP2_MAX_INPUT) {\\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\\n }\\n\\n // Convert x to the 192.64-bit fixed-point format.\\n uint256 x_192x64 = (xUint << 64) / uUNIT;\\n\\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\\n result = wrap(Common.exp2(x_192x64));\\n}\\n\\n/// @notice Yields the greatest whole number less than or equal to x.\\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n/// @param x The UD60x18 number to floor.\\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\\n assembly (\\\"memory-safe\\\") {\\n // Equivalent to `x % UNIT`.\\n let remainder := mod(x, uUNIT)\\n\\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\\n result := sub(x, mul(remainder, gt(remainder, 0)))\\n }\\n}\\n\\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\\n/// @param x The UD60x18 number to get the fractional part of.\\n/// @param result The fractional part of x as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\\n assembly (\\\"memory-safe\\\") {\\n result := mod(x, uUNIT)\\n }\\n}\\n\\n/// @notice Calculates the geometric mean of x and y, i.e. $\\\\sqrt{x * y}$, rounding down.\\n///\\n/// @dev Requirements:\\n/// - x * y must fit in UD60x18.\\n///\\n/// @param x The first operand as a UD60x18 number.\\n/// @param y The second operand as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n if (xUint == 0 || yUint == 0) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Checking for overflow this way is faster than letting Solidity do it.\\n uint256 xyUint = xUint * yUint;\\n if (xyUint / xUint != yUint) {\\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\\n }\\n\\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\\n // during multiplication. See the comments in {Common.sqrt}.\\n result = wrap(Common.sqrt(xyUint));\\n }\\n}\\n\\n/// @notice Calculates the inverse of x.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must not be zero.\\n///\\n/// @param x The UD60x18 number for which to calculate the inverse.\\n/// @return result The inverse as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(uUNIT_SQUARED / x.unwrap());\\n }\\n}\\n\\n/// @notice Calculates the natural logarithm of x using the following formula:\\n///\\n/// $$\\n/// ln{x} = log_2{x} / log_2{e}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\\n/// @return result The natural logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\\n unchecked {\\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\\n // {log2} can return is ~196_205294292027477728.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\\n }\\n}\\n\\n/// @notice Calculates the common logarithm of x using the following formula:\\n///\\n/// $$\\n/// log_{10}{x} = log_2{x} / log_2{10}\\n/// $$\\n///\\n/// However, if x is an exact power of ten, a hard coded value is returned.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The UD60x18 number for which to calculate the common logarithm.\\n/// @return result The common logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n if (xUint < uUNIT) {\\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\\n }\\n\\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\\n // prettier-ignore\\n assembly (\\\"memory-safe\\\") {\\n switch x\\n case 1 { result := mul(uUNIT, sub(0, 18)) }\\n case 10 { result := mul(uUNIT, sub(1, 18)) }\\n case 100 { result := mul(uUNIT, sub(2, 18)) }\\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\\n case 1000000000000000000 { result := 0 }\\n case 10000000000000000000 { result := uUNIT }\\n case 100000000000000000000 { result := mul(uUNIT, 2) }\\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\\n default { result := uMAX_UD60x18 }\\n }\\n\\n if (result.unwrap() == uMAX_UD60x18) {\\n unchecked {\\n // Inline the fixed-point division to save gas.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\\n }\\n }\\n}\\n\\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\\n///\\n/// $$\\n/// log_2{x} = n + log_2{y}, \\\\text{ where } y = x*2^{-n}, \\\\ y \\\\in [1, 2)\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, the input is inverted:\\n///\\n/// $$\\n/// log_2{x} = -log_2{\\\\frac{1}{x}}\\n/// $$\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\\n///\\n/// Notes:\\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\\n///\\n/// Requirements:\\n/// - x must be greater than zero.\\n///\\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\\n/// @return result The binary logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n if (xUint < uUNIT) {\\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\\n }\\n\\n unchecked {\\n // Calculate the integer part of the logarithm.\\n uint256 n = Common.msb(xUint / uUNIT);\\n\\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\\n // n is at most 255 and UNIT is 1e18.\\n uint256 resultUint = n * uUNIT;\\n\\n // Calculate $y = x * 2^{-n}$.\\n uint256 y = xUint >> n;\\n\\n // If y is the unit number, the fractional part is zero.\\n if (y == uUNIT) {\\n return wrap(resultUint);\\n }\\n\\n // Calculate the fractional part via the iterative approximation.\\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\\n uint256 DOUBLE_UNIT = 2e18;\\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\\n y = (y * y) / uUNIT;\\n\\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\\n if (y >= DOUBLE_UNIT) {\\n // Add the 2^{-m} factor to the logarithm.\\n resultUint += delta;\\n\\n // Halve y, which corresponds to z/2 in the Wikipedia article.\\n y >>= 1;\\n }\\n }\\n result = wrap(resultUint);\\n }\\n}\\n\\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\\n///\\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n///\\n/// @dev See the documentation in {Common.mulDiv18}.\\n/// @param x The multiplicand as a UD60x18 number.\\n/// @param y The multiplier as a UD60x18 number.\\n/// @return result The product as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\\n}\\n\\n/// @notice Raises x to the power of y.\\n///\\n/// For $1 \\\\leq x \\\\leq \\\\infty$, the following standard formula is used:\\n///\\n/// $$\\n/// x^y = 2^{log_2{x} * y}\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\\n///\\n/// $$\\n/// i = \\\\frac{1}{x}\\n/// w = 2^{log_2{i} * y}\\n/// x^y = \\\\frac{1}{w}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2} and {mul}.\\n/// - Returns `UNIT` for 0^0.\\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\\n///\\n/// @param x The base as a UD60x18 number.\\n/// @param y The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n\\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\\n if (xUint == 0) {\\n return yUint == 0 ? UNIT : ZERO;\\n }\\n // If x is `UNIT`, the result is always `UNIT`.\\n else if (xUint == uUNIT) {\\n return UNIT;\\n }\\n\\n // If y is zero, the result is always `UNIT`.\\n if (yUint == 0) {\\n return UNIT;\\n }\\n // If y is `UNIT`, the result is always x.\\n else if (yUint == uUNIT) {\\n return x;\\n }\\n\\n // If x is greater than `UNIT`, use the standard formula.\\n if (xUint > uUNIT) {\\n result = exp2(mul(log2(x), y));\\n }\\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\\n else {\\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\\n UD60x18 w = exp2(mul(log2(i), y));\\n result = wrap(uUNIT_SQUARED / w.unwrap());\\n }\\n}\\n\\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\\n/// algorithm \\\"exponentiation by squaring\\\".\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - The result must fit in UD60x18.\\n///\\n/// @param x The base as a UD60x18 number.\\n/// @param y The exponent as a uint256.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\\n // Calculate the first iteration of the loop in advance.\\n uint256 xUint = x.unwrap();\\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\\n\\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\\n for (y >>= 1; y > 0; y >>= 1) {\\n xUint = Common.mulDiv18(xUint, xUint);\\n\\n // Equivalent to `y % 2 == 1`.\\n if (y & 1 > 0) {\\n resultUint = Common.mulDiv18(resultUint, xUint);\\n }\\n }\\n result = wrap(resultUint);\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must be less than `MAX_UD60x18 / UNIT`.\\n///\\n/// @param x The UD60x18 number for which to calculate the square root.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n unchecked {\\n if (xUint > uMAX_UD60x18 / uUNIT) {\\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\\n }\\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\\n // In this case, the two numbers are both the square root.\\n result = wrap(Common.sqrt(xUint * uUNIT));\\n }\\n}\\n\",\"keccak256\":\"0x462144667aac3f96d5f8dba7aa68fe4c5a3f61e1d7bbbc81bee21168817f9c09\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\nimport \\\"./Helpers.sol\\\" as Helpers;\\nimport \\\"./Math.sol\\\" as Math;\\n\\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\\n/// @dev The value type is defined here so it can be imported in all other files.\\ntype UD60x18 is uint256;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD1x18,\\n Casting.intoUD2x18,\\n Casting.intoSD59x18,\\n Casting.intoUint128,\\n Casting.intoUint256,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes the functions in this library callable on the UD60x18 type.\\nusing {\\n Math.avg,\\n Math.ceil,\\n Math.div,\\n Math.exp,\\n Math.exp2,\\n Math.floor,\\n Math.frac,\\n Math.gm,\\n Math.inv,\\n Math.ln,\\n Math.log10,\\n Math.log2,\\n Math.mul,\\n Math.pow,\\n Math.powu,\\n Math.sqrt\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n HELPER FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes the functions in this library callable on the UD60x18 type.\\nusing {\\n Helpers.add,\\n Helpers.and,\\n Helpers.eq,\\n Helpers.gt,\\n Helpers.gte,\\n Helpers.isZero,\\n Helpers.lshift,\\n Helpers.lt,\\n Helpers.lte,\\n Helpers.mod,\\n Helpers.neq,\\n Helpers.not,\\n Helpers.or,\\n Helpers.rshift,\\n Helpers.sub,\\n Helpers.uncheckedAdd,\\n Helpers.uncheckedSub,\\n Helpers.xor\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n OPERATORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes it possible to use these operators on the UD60x18 type.\\nusing {\\n Helpers.add as +,\\n Helpers.and2 as &,\\n Math.div as /,\\n Helpers.eq as ==,\\n Helpers.gt as >,\\n Helpers.gte as >=,\\n Helpers.lt as <,\\n Helpers.lte as <=,\\n Helpers.or as |,\\n Helpers.mod as %,\\n Math.mul as *,\\n Helpers.neq as !=,\\n Helpers.not as ~,\\n Helpers.sub as -,\\n Helpers.xor as ^\\n} for UD60x18 global;\\n\",\"keccak256\":\"0xdd873b5124180d9b71498b3a7fe93b1c08c368bec741f7d5f8e17f78a0b70f31\",\"license\":\"MIT\"},\"contracts/DecentSablierStreamManagement.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.28;\\n\\nimport {Enum} from \\\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\\\";\\nimport {IAvatar} from \\\"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\\\";\\nimport {ISablierV2Lockup} from \\\"./interfaces/sablier/full/ISablierV2Lockup.sol\\\";\\nimport {Lockup} from \\\"./interfaces/sablier/full/types/DataTypes.sol\\\";\\n\\ncontract DecentSablierStreamManagement {\\n string public constant NAME = \\\"DecentSablierStreamManagement\\\";\\n\\n function withdrawMaxFromStream(\\n ISablierV2Lockup sablier,\\n address recipientHatAccount,\\n uint256 streamId,\\n address to\\n ) public {\\n // Check if there are funds to withdraw\\n uint128 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\\n if (withdrawableAmount == 0) {\\n return;\\n }\\n\\n // Proxy the Sablier withdrawMax call through IAvatar (Safe)\\n IAvatar(msg.sender).execTransactionFromModule(\\n recipientHatAccount,\\n 0,\\n abi.encodeWithSignature(\\n \\\"execute(address,uint256,bytes,uint8)\\\",\\n address(sablier),\\n 0,\\n abi.encodeWithSignature(\\n \\\"withdrawMax(uint256,address)\\\",\\n streamId,\\n to\\n ),\\n 0\\n ),\\n Enum.Operation.Call\\n );\\n }\\n\\n function cancelStream(ISablierV2Lockup sablier, uint256 streamId) public {\\n // Check if the stream can be cancelled\\n Lockup.Status streamStatus = sablier.statusOf(streamId);\\n if (\\n streamStatus != Lockup.Status.PENDING &&\\n streamStatus != Lockup.Status.STREAMING\\n ) {\\n return;\\n }\\n\\n IAvatar(msg.sender).execTransactionFromModule(\\n address(sablier),\\n 0,\\n abi.encodeWithSignature(\\\"cancel(uint256)\\\", streamId),\\n Enum.Operation.Call\\n );\\n }\\n}\\n\",\"keccak256\":\"0xf36be7e97936d82de0035b8bda2c53dbc52b9ca3b8efe305540a7632cb6fe6ab\",\"license\":\"MIT\"},\"contracts/interfaces/sablier/full/IAdminable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\n/// @title IAdminable\\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\\n/// in the constructor.\\ninterface IAdminable {\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin is transferred.\\n /// @param oldAdmin The address of the old admin.\\n /// @param newAdmin The address of the new admin.\\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice The address of the admin account or contract.\\n function admin() external view returns (address);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Transfers the contract admin to a new address.\\n ///\\n /// @dev Notes:\\n /// - Does not revert if the admin is the same.\\n /// - This function can potentially leave the contract without an admin, thereby removing any\\n /// functionality that is only available to the admin.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newAdmin The address of the new admin.\\n function transferAdmin(address newAdmin) external;\\n}\\n\",\"keccak256\":\"0xa279c49e51228b571329164e36250e82b2c1378e8b549194ab7dd90fca9c3b2b\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/IERC4096.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4906.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC165} from \\\"@openzeppelin/contracts/interfaces/IERC165.sol\\\";\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\n/// @title ERC-721 Metadata Update Extension\\ninterface IERC4906 is IERC165, IERC721 {\\n /// @dev This event emits when the metadata of a token is changed.\\n /// So that the third-party platforms such as NFT market could\\n /// timely update the images and related attributes of the NFT.\\n event MetadataUpdate(uint256 _tokenId);\\n\\n /// @dev This event emits when the metadata of a range of tokens is changed.\\n /// So that the third-party platforms such as NFT market could\\n /// timely update the images and related attributes of the NFTs.\\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\\n}\\n\",\"keccak256\":\"0xa34b9c52cbe36be860244f52256f1b05badf0cb797d208664b87337610d0e82d\",\"license\":\"MIT\"},\"contracts/interfaces/sablier/full/ISablierV2Lockup.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC4906} from \\\"./IERC4096.sol\\\";\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {IERC721Metadata} from \\\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\\\";\\nimport {UD60x18} from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\nimport {Lockup} from \\\"./types/DataTypes.sol\\\";\\nimport {IAdminable} from \\\"./IAdminable.sol\\\";\\nimport {ISablierV2NFTDescriptor} from \\\"./ISablierV2NFTDescriptor.sol\\\";\\n\\n/// @title ISablierV2Lockup\\n/// @notice Common logic between all Sablier V2 Lockup contracts.\\ninterface ISablierV2Lockup is\\n IAdminable, // 0 inherited components\\n IERC4906, // 2 inherited components\\n IERC721Metadata // 2 inherited components\\n{\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin allows a new recipient contract to hook to Sablier.\\n /// @param admin The address of the current contract admin.\\n /// @param recipient The address of the recipient contract put on the allowlist.\\n event AllowToHook(address indexed admin, address recipient);\\n\\n /// @notice Emitted when a stream is canceled.\\n /// @param streamId The ID of the stream.\\n /// @param sender The address of the stream's sender.\\n /// @param recipient The address of the stream's recipient.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\\n /// decimals.\\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\\n /// asset's decimals.\\n event CancelLockupStream(\\n uint256 streamId,\\n address indexed sender,\\n address indexed recipient,\\n IERC20 indexed asset,\\n uint128 senderAmount,\\n uint128 recipientAmount\\n );\\n\\n /// @notice Emitted when a sender gives up the right to cancel a stream.\\n /// @param streamId The ID of the stream.\\n event RenounceLockupStream(uint256 indexed streamId);\\n\\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\\n /// @param admin The address of the current contract admin.\\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\\n event SetNFTDescriptor(\\n address indexed admin,\\n ISablierV2NFTDescriptor oldNFTDescriptor,\\n ISablierV2NFTDescriptor newNFTDescriptor\\n );\\n\\n /// @notice Emitted when assets are withdrawn from a stream.\\n /// @param streamId The ID of the stream.\\n /// @param to The address that has received the withdrawn assets.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\\n event WithdrawFromLockupStream(\\n uint256 indexed streamId,\\n address indexed to,\\n IERC20 indexed asset,\\n uint128 amount\\n );\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Retrieves the address of the ERC-20 asset to be distributed.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\\n\\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getDepositedAmount(\\n uint256 streamId\\n ) external view returns (uint128 depositedAmount);\\n\\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getEndTime(\\n uint256 streamId\\n ) external view returns (uint40 endTime);\\n\\n /// @notice Retrieves the stream's recipient.\\n /// @dev Reverts if the NFT has been burned.\\n /// @param streamId The stream ID for the query.\\n function getRecipient(\\n uint256 streamId\\n ) external view returns (address recipient);\\n\\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\\n /// decimals. This amount is always zero unless the stream was canceled.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getRefundedAmount(\\n uint256 streamId\\n ) external view returns (uint128 refundedAmount);\\n\\n /// @notice Retrieves the stream's sender.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getSender(uint256 streamId) external view returns (address sender);\\n\\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getStartTime(\\n uint256 streamId\\n ) external view returns (uint40 startTime);\\n\\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getWithdrawnAmount(\\n uint256 streamId\\n ) external view returns (uint128 withdrawnAmount);\\n\\n /// @notice Retrieves a flag indicating whether the provided address is a contract allowed to hook to Sablier\\n /// when a stream is canceled or when assets are withdrawn.\\n /// @dev See {ISablierLockupRecipient} for more information.\\n function isAllowedToHook(\\n address recipient\\n ) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\\n /// flag is always `false`.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isCancelable(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isCold(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is depleted.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isDepleted(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream exists.\\n /// @dev Does not revert if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isStream(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isTransferable(\\n uint256 streamId\\n ) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isWarm(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves the maximum broker fee that can be charged by the broker, denoted as a fixed-point\\n /// number where 1e18 is 100%.\\n /// @dev This value is hard coded as a constant.\\n function MAX_BROKER_FEE() external view returns (UD60x18);\\n\\n /// @notice Counter for stream IDs, used in the create functions.\\n function nextStreamId() external view returns (uint256);\\n\\n /// @notice Contract that generates the non-fungible token URI.\\n function nftDescriptor() external view returns (ISablierV2NFTDescriptor);\\n\\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\\n /// of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function refundableAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 refundableAmount);\\n\\n /// @notice Retrieves the stream's status.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function statusOf(\\n uint256 streamId\\n ) external view returns (Lockup.Status status);\\n\\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n ///\\n /// Notes:\\n /// - Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\\n /// to the total amount withdrawn.\\n ///\\n /// @param streamId The stream ID for the query.\\n function streamedAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 streamedAmount);\\n\\n /// @notice Retrieves a flag indicating whether the stream was canceled.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function wasCanceled(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\\n /// decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function withdrawableAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 withdrawableAmount);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Allows a recipient contract to hook to Sablier when a stream is canceled or when assets are withdrawn.\\n /// Useful for implementing contracts that hold streams on behalf of users, such as vaults or staking contracts.\\n ///\\n /// @dev Emits an {AllowToHook} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the contract is already on the allowlist.\\n /// - This is an irreversible operation. The contract cannot be removed from the allowlist.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n /// - `recipient` must have a non-zero code size.\\n /// - `recipient` must implement {ISablierLockupRecipient}.\\n ///\\n /// @param recipient The address of the contract to allow for hooks.\\n function allowToHook(address recipient) external;\\n\\n /// @notice Burns the NFT associated with the stream.\\n ///\\n /// @dev Emits a {Transfer} event.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must reference a depleted stream.\\n /// - The NFT must exist.\\n /// - `msg.sender` must be either the NFT owner or an approved third party.\\n ///\\n /// @param streamId The ID of the stream NFT to burn.\\n function burn(uint256 streamId) external;\\n\\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\\n ///\\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\\n /// stream is marked as depleted.\\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - The stream must be warm and cancelable.\\n /// - `msg.sender` must be the stream's sender.\\n ///\\n /// @param streamId The ID of the stream to cancel.\\n function cancel(uint256 streamId) external;\\n\\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\\n ///\\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\\n ///\\n /// Notes:\\n /// - Refer to the notes in {cancel}.\\n ///\\n /// Requirements:\\n /// - All requirements from {cancel} must be met for each stream.\\n ///\\n /// @param streamIds The IDs of the streams to cancel.\\n function cancelMultiple(uint256[] calldata streamIds) external;\\n\\n /// @notice Removes the right of the stream's sender to cancel the stream.\\n ///\\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - This is an irreversible operation.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must reference a warm stream.\\n /// - `msg.sender` must be the stream's sender.\\n /// - The stream must be cancelable.\\n ///\\n /// @param streamId The ID of the stream to renounce.\\n function renounce(uint256 streamId) external;\\n\\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\\n ///\\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the NFT descriptor is the same.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\\n function setNFTDescriptor(\\n ISablierV2NFTDescriptor newNFTDescriptor\\n ) external;\\n\\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\\n ///\\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - This function attempts to call a hook on the recipient of the stream, unless `msg.sender` is the recipient.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must not reference a null or depleted stream.\\n /// - `to` must not be the zero address.\\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\\n /// - `to` must be the recipient if `msg.sender` is not the stream's recipient or an approved third party.\\n ///\\n /// @param streamId The ID of the stream to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\\n function withdraw(uint256 streamId, address to, uint128 amount) external;\\n\\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\\n ///\\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - Refer to the notes in {withdraw}.\\n ///\\n /// Requirements:\\n /// - Refer to the requirements in {withdraw}.\\n ///\\n /// @param streamId The ID of the stream to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\\n function withdrawMax(\\n uint256 streamId,\\n address to\\n ) external returns (uint128 withdrawnAmount);\\n\\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\\n /// NFT to `newRecipient`.\\n ///\\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\\n ///\\n /// Notes:\\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\\n /// - Refer to the notes in {withdraw}.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the stream's recipient.\\n /// - Refer to the requirements in {withdraw}.\\n /// - Refer to the requirements in {IERC721.transferFrom}.\\n ///\\n /// @param streamId The ID of the stream NFT to transfer.\\n /// @param newRecipient The address of the new owner of the stream NFT.\\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\\n function withdrawMaxAndTransfer(\\n uint256 streamId,\\n address newRecipient\\n ) external returns (uint128 withdrawnAmount);\\n\\n /// @notice Withdraws assets from streams to the recipient of each stream.\\n ///\\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\\n ///\\n /// Notes:\\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - There must be an equal number of `streamIds` and `amounts`.\\n /// - Each stream ID in the array must not reference a null or depleted stream.\\n /// - Each amount in the array must be greater than zero and must not exceed the withdrawable amount.\\n ///\\n /// @param streamIds The IDs of the streams to withdraw from.\\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\\n function withdrawMultiple(\\n uint256[] calldata streamIds,\\n uint128[] calldata amounts\\n ) external;\\n}\\n\",\"keccak256\":\"0x3e5541c38a901637bd310965deb5bbde73ef07fe4ee3c752cbec330c6b9d62a3\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/ISablierV2NFTDescriptor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC721Metadata} from \\\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\\\";\\n\\n/// @title ISablierV2NFTDescriptor\\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\\n/// @dev Inspired by Uniswap V3 Positions NFTs.\\ninterface ISablierV2NFTDescriptor {\\n /// @notice Produces the URI describing a particular stream NFT.\\n /// @dev This is a data URI with the JSON contents directly inlined.\\n /// @param sablier The address of the Sablier contract the stream was created in.\\n /// @param streamId The ID of the stream for which to produce a description.\\n /// @return uri The URI of the ERC721-compliant metadata.\\n function tokenURI(\\n IERC721Metadata sablier,\\n uint256 streamId\\n ) external view returns (string memory uri);\\n}\\n\",\"keccak256\":\"0x4ed430e553d14161e93efdaaacd1a502f49b38969c9d714b45d2e682a74fa0bc\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/types/DataTypes.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {UD2x18} from \\\"@prb/math/src/UD2x18.sol\\\";\\nimport {UD60x18} from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\n// DataTypes.sol\\n//\\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\\n//\\n// - Lockup\\n// - LockupDynamic\\n// - LockupLinear\\n// - LockupTranched\\n//\\n// You will notice that some structs contain \\\"slot\\\" annotations - they are used to indicate the\\n// storage layout of the struct. It is more gas efficient to group small data types together so\\n// that they fit in a single 32-byte slot.\\n\\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\\n/// @param account The address receiving the broker's fee.\\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\\nstruct Broker {\\n address account;\\n UD60x18 fee;\\n}\\n\\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\\nlibrary Lockup {\\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the asset's\\n /// decimals.\\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in the same slot\\n /// saves gas.\\n /// @param deposited The initial amount deposited in the stream, net of broker fee.\\n /// @param withdrawn The cumulative amount withdrawn from the stream.\\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\\n struct Amounts {\\n // slot 0\\n uint128 deposited;\\n uint128 withdrawn;\\n // slot 1\\n uint128 refunded;\\n }\\n\\n /// @notice Struct encapsulating (i) the deposit amount and (ii) the broker fee amount, both denoted in units of the\\n /// asset's decimals.\\n /// @param deposit The amount to deposit in the stream.\\n /// @param brokerFee The broker fee amount.\\n struct CreateAmounts {\\n uint128 deposit;\\n uint128 brokerFee;\\n }\\n\\n /// @notice Enum representing the different statuses of a stream.\\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\\n enum Status {\\n PENDING,\\n STREAMING,\\n SETTLED,\\n CANCELED,\\n DEPLETED\\n }\\n\\n /// @notice A common data structure to be stored in all {SablierV2Lockup} models.\\n /// @dev The fields are arranged like this to save gas via tight variable packing.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param endTime The Unix timestamp indicating the stream's end.\\n /// @param isCancelable Boolean indicating if the stream is cancelable.\\n /// @param wasCanceled Boolean indicating if the stream was canceled.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param isDepleted Boolean indicating if the stream is depleted.\\n /// @param isStream Boolean indicating if the struct entity exists.\\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\\n /// @param amounts Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the\\n /// asset's decimals.\\n struct Stream {\\n // slot 0\\n address sender;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n // slot 1\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n // slot 2 and 3\\n Lockup.Amounts amounts;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\\nlibrary LockupDynamic {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param segments Segments with durations used to compose the dynamic distribution function. Timestamps are\\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n SegmentWithDuration[] segments;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param segments Segments used to compose the dynamic distribution function.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n uint40 startTime;\\n Segment[] segments;\\n Broker broker;\\n }\\n\\n /// @notice Segment struct used in the Lockup Dynamic stream.\\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\\n /// @param timestamp The Unix timestamp indicating the segment's end.\\n struct Segment {\\n // slot 0\\n uint128 amount;\\n UD2x18 exponent;\\n uint40 timestamp;\\n }\\n\\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDurations}.\\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\\n /// @param duration The time difference in seconds between the segment and the previous one.\\n struct SegmentWithDuration {\\n uint128 amount;\\n UD2x18 exponent;\\n uint40 duration;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the segments.\\n struct StreamLD {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n Segment[] segments;\\n }\\n\\n /// @notice Struct encapsulating the LockupDynamic timestamps.\\n /// @param start The Unix timestamp indicating the stream's start.\\n /// @param end The Unix timestamp indicating the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 end;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\\nlibrary LockupLinear {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param durations Struct encapsulating (i) cliff period duration and (ii) total stream duration, both in seconds.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n Durations durations;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param timestamps Struct encapsulating (i) the stream's start time, (ii) cliff time, and (iii) end time, all as\\n /// Unix timestamps.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n Timestamps timestamps;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the cliff duration and the total duration.\\n /// @param cliff The cliff duration in seconds.\\n /// @param total The total duration in seconds.\\n struct Durations {\\n uint40 cliff;\\n uint40 total;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the cliff time.\\n struct StreamLL {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n uint40 endTime;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n uint40 cliffTime;\\n }\\n\\n /// @notice Struct encapsulating the LockupLinear timestamps.\\n /// @param start The Unix timestamp for the stream's start.\\n /// @param cliff The Unix timestamp for the cliff period's end. A value of zero means there is no cliff.\\n /// @param end The Unix timestamp for the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 cliff;\\n uint40 end;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupTranched}.\\nlibrary LockupTranched {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param tranches Tranches with durations used to compose the tranched distribution function. Timestamps are\\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n TrancheWithDuration[] tranches;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param tranches Tranches used to compose the tranched distribution function.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n uint40 startTime;\\n Tranche[] tranches;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the tranches.\\n struct StreamLT {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n Tranche[] tranches;\\n }\\n\\n /// @notice Struct encapsulating the LockupTranched timestamps.\\n /// @param start The Unix timestamp indicating the stream's start.\\n /// @param end The Unix timestamp indicating the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 end;\\n }\\n\\n /// @notice Tranche struct used in the Lockup Tranched stream.\\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\\n /// @param timestamp The Unix timestamp indicating the tranche's end.\\n struct Tranche {\\n // slot 0\\n uint128 amount;\\n uint40 timestamp;\\n }\\n\\n /// @notice Tranche struct used at runtime in {SablierV2LockupTranched.createWithDurations}.\\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\\n /// @param duration The time difference in seconds between the tranche and the previous one.\\n struct TrancheWithDuration {\\n uint128 amount;\\n uint40 duration;\\n }\\n}\\n\",\"keccak256\":\"0x727722c0ec71a76a947b935c9dfcac8fd846d6c3547dfbc8739c7109f3b95068\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", + "bytecode": "0x6080604052348015600f57600080fd5b506105fe8061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80636778d4b0146100465780637dc14a8e1461005b578063a3f4df7e1461006e575b600080fd5b6100596100543660046103d0565b6100c0565b005b610059610069366004610423565b610256565b6100aa6040518060400160405280601d81526020017f446563656e745361626c69657253747265616d4d616e6167656d656e7400000081525081565b6040516100b79190610495565b60405180910390f35b60405163d975dfed60e01b8152600481018390526000906001600160a01b0386169063d975dfed90602401602060405180830381865afa158015610108573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012c91906104af565b9050806001600160801b03166000036101455750610250565b336001600160a01b031663468721a7856000886000888860405160240161017f9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529181526020820180516001600160e01b031663ea5ead1960e01b179052516101bc939291906000906024016104d8565b60408051601f198184030181529181526020820180516001600160e01b0316635194544760e01b1790525160e085901b6001600160e01b031916815261020a9392919060009060040161052f565b6020604051808303816000875af1158015610229573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024d9190610585565b50505b50505050565b604051632b4d7bf560e21b8152600481018290526000906001600160a01b0384169063ad35efd490602401602060405180830381865afa15801561029e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c291906105a7565b905060008160048111156102d8576102d8610519565b141580156102f8575060018160048111156102f5576102f5610519565b14155b1561030257505050565b336001600160a01b031663468721a78460008560405160240161032791815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166340e58ee560e01b1790525160e085901b6001600160e01b03191681526103759392919060009060040161052f565b6020604051808303816000875af1158015610394573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102509190610585565b6001600160a01b03811681146103cd57600080fd5b50565b600080600080608085870312156103e657600080fd5b84356103f1816103b8565b93506020850135610401816103b8565b9250604085013591506060850135610418816103b8565b939692955090935050565b6000806040838503121561043657600080fd5b8235610441816103b8565b946020939093013593505050565b6000815180845260005b8181101561047557602081850181015186830182015201610459565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006104a8602083018461044f565b9392505050565b6000602082840312156104c157600080fd5b81516001600160801b03811681146104a857600080fd5b6001600160a01b038516815260ff841660208201526080604082018190526000906105059083018561044f565b905060ff8316606083015295945050505050565b634e487b7160e01b600052602160045260246000fd5b60018060a01b0385168152836020820152608060408201526000610556608083018561044f565b90506002831061057657634e487b7160e01b600052602160045260246000fd5b82606083015295945050505050565b60006020828403121561059757600080fd5b815180151581146104a857600080fd5b6000602082840312156105b957600080fd5b8151600581106104a857600080fdfea2646970667358221220c473750d62fe01ec9f421a499df8738e767b4a5341626c81a992fcdb3ee192de64736f6c634300081c0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80636778d4b0146100465780637dc14a8e1461005b578063a3f4df7e1461006e575b600080fd5b6100596100543660046103d0565b6100c0565b005b610059610069366004610423565b610256565b6100aa6040518060400160405280601d81526020017f446563656e745361626c69657253747265616d4d616e6167656d656e7400000081525081565b6040516100b79190610495565b60405180910390f35b60405163d975dfed60e01b8152600481018390526000906001600160a01b0386169063d975dfed90602401602060405180830381865afa158015610108573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012c91906104af565b9050806001600160801b03166000036101455750610250565b336001600160a01b031663468721a7856000886000888860405160240161017f9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529181526020820180516001600160e01b031663ea5ead1960e01b179052516101bc939291906000906024016104d8565b60408051601f198184030181529181526020820180516001600160e01b0316635194544760e01b1790525160e085901b6001600160e01b031916815261020a9392919060009060040161052f565b6020604051808303816000875af1158015610229573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024d9190610585565b50505b50505050565b604051632b4d7bf560e21b8152600481018290526000906001600160a01b0384169063ad35efd490602401602060405180830381865afa15801561029e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c291906105a7565b905060008160048111156102d8576102d8610519565b141580156102f8575060018160048111156102f5576102f5610519565b14155b1561030257505050565b336001600160a01b031663468721a78460008560405160240161032791815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166340e58ee560e01b1790525160e085901b6001600160e01b03191681526103759392919060009060040161052f565b6020604051808303816000875af1158015610394573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102509190610585565b6001600160a01b03811681146103cd57600080fd5b50565b600080600080608085870312156103e657600080fd5b84356103f1816103b8565b93506020850135610401816103b8565b9250604085013591506060850135610418816103b8565b939692955090935050565b6000806040838503121561043657600080fd5b8235610441816103b8565b946020939093013593505050565b6000815180845260005b8181101561047557602081850181015186830182015201610459565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006104a8602083018461044f565b9392505050565b6000602082840312156104c157600080fd5b81516001600160801b03811681146104a857600080fd5b6001600160a01b038516815260ff841660208201526080604082018190526000906105059083018561044f565b905060ff8316606083015295945050505050565b634e487b7160e01b600052602160045260246000fd5b60018060a01b0385168152836020820152608060408201526000610556608083018561044f565b90506002831061057657634e487b7160e01b600052602160045260246000fd5b82606083015295945050505050565b60006020828403121561059757600080fd5b815180151581146104a857600080fd5b6000602082840312156105b957600080fd5b8151600581106104a857600080fdfea2646970667358221220c473750d62fe01ec9f421a499df8738e767b4a5341626c81a992fcdb3ee192de64736f6c634300081c0033", + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/deployments/optimism/solcInputs/4511b61209438ca20d2458493e70bb24.json b/deployments/optimism/solcInputs/4511b61209438ca20d2458493e70bb24.json new file mode 100644 index 00000000..c068a9c4 --- /dev/null +++ b/deployments/optimism/solcInputs/4511b61209438ca20d2458493e70bb24.json @@ -0,0 +1,351 @@ +{ + "language": "Solidity", + "sources": { + "@gnosis.pm/safe-contracts/contracts/base/Executor.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\n\n/// @title Executor - A contract that can execute transactions\n/// @author Richard Meissner - \ncontract Executor {\n function execute(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 txGas\n ) internal returns (bool success) {\n if (operation == Enum.Operation.DelegateCall) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n success := delegatecall(txGas, to, add(data, 0x20), mload(data), 0, 0)\n }\n } else {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n success := call(txGas, to, value, add(data, 0x20), mload(data), 0, 0)\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/FallbackManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../common/SelfAuthorized.sol\";\n\n/// @title Fallback Manager - A contract that manages fallback calls made to this contract\n/// @author Richard Meissner - \ncontract FallbackManager is SelfAuthorized {\n event ChangedFallbackHandler(address handler);\n\n // keccak256(\"fallback_manager.handler.address\")\n bytes32 internal constant FALLBACK_HANDLER_STORAGE_SLOT = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5;\n\n function internalSetFallbackHandler(address handler) internal {\n bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, handler)\n }\n }\n\n /// @dev Allows to add a contract to handle fallback calls.\n /// Only fallback calls without value and with data will be forwarded.\n /// This can only be done via a Safe transaction.\n /// @param handler contract to handle fallbacks calls.\n function setFallbackHandler(address handler) public authorized {\n internalSetFallbackHandler(handler);\n emit ChangedFallbackHandler(handler);\n }\n\n // solhint-disable-next-line payable-fallback,no-complex-fallback\n fallback() external {\n bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let handler := sload(slot)\n if iszero(handler) {\n return(0, 0)\n }\n calldatacopy(0, 0, calldatasize())\n // The msg.sender address is shifted to the left by 12 bytes to remove the padding\n // Then the address without padding is stored right after the calldata\n mstore(calldatasize(), shl(96, caller()))\n // Add 20 bytes for the address appended add the end\n let success := call(gas(), handler, 0, 0, add(calldatasize(), 20), 0, 0)\n returndatacopy(0, 0, returndatasize())\n if iszero(success) {\n revert(0, returndatasize())\n }\n return(0, returndatasize())\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/GuardManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\n\ninterface Guard {\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external;\n\n function checkAfterExecution(bytes32 txHash, bool success) external;\n}\n\n/// @title Fallback Manager - A contract that manages fallback calls made to this contract\n/// @author Richard Meissner - \ncontract GuardManager is SelfAuthorized {\n event ChangedGuard(address guard);\n // keccak256(\"guard_manager.guard.address\")\n bytes32 internal constant GUARD_STORAGE_SLOT = 0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8;\n\n /// @dev Set a guard that checks transactions before execution\n /// @param guard The address of the guard to be used or the 0 address to disable the guard\n function setGuard(address guard) external authorized {\n bytes32 slot = GUARD_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, guard)\n }\n emit ChangedGuard(guard);\n }\n\n function getGuard() internal view returns (address guard) {\n bytes32 slot = GUARD_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n guard := sload(slot)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/ModuleManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\nimport \"./Executor.sol\";\n\n/// @title Module Manager - A contract that manages modules that can execute transactions via this contract\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract ModuleManager is SelfAuthorized, Executor {\n event EnabledModule(address module);\n event DisabledModule(address module);\n event ExecutionFromModuleSuccess(address indexed module);\n event ExecutionFromModuleFailure(address indexed module);\n\n address internal constant SENTINEL_MODULES = address(0x1);\n\n mapping(address => address) internal modules;\n\n function setupModules(address to, bytes memory data) internal {\n require(modules[SENTINEL_MODULES] == address(0), \"GS100\");\n modules[SENTINEL_MODULES] = SENTINEL_MODULES;\n if (to != address(0))\n // Setup has to complete successfully or transaction fails.\n require(execute(to, 0, data, Enum.Operation.DelegateCall, gasleft()), \"GS000\");\n }\n\n /// @dev Allows to add a module to the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Enables the module `module` for the Safe.\n /// @param module Module to be whitelisted.\n function enableModule(address module) public authorized {\n // Module address cannot be null or sentinel.\n require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n // Module cannot be added twice.\n require(modules[module] == address(0), \"GS102\");\n modules[module] = modules[SENTINEL_MODULES];\n modules[SENTINEL_MODULES] = module;\n emit EnabledModule(module);\n }\n\n /// @dev Allows to remove a module from the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Disables the module `module` for the Safe.\n /// @param prevModule Module that pointed to the module to be removed in the linked list\n /// @param module Module to be removed.\n function disableModule(address prevModule, address module) public authorized {\n // Validate module address and check that it corresponds to module index.\n require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n require(modules[prevModule] == module, \"GS103\");\n modules[prevModule] = modules[module];\n modules[module] = address(0);\n emit DisabledModule(module);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public virtual returns (bool success) {\n // Only whitelisted modules are allowed.\n require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), \"GS104\");\n // Execute transaction without further confirmations.\n success = execute(to, value, data, operation, gasleft());\n if (success) emit ExecutionFromModuleSuccess(msg.sender);\n else emit ExecutionFromModuleFailure(msg.sender);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModuleReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public returns (bool success, bytes memory returnData) {\n success = execTransactionFromModule(to, value, data, operation);\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // Load free memory location\n let ptr := mload(0x40)\n // We allocate memory for the return data by setting the free memory location to\n // current free memory location + data size + 32 bytes for data size value\n mstore(0x40, add(ptr, add(returndatasize(), 0x20)))\n // Store the size\n mstore(ptr, returndatasize())\n // Store the data\n returndatacopy(add(ptr, 0x20), 0, returndatasize())\n // Point the return data to the correct memory location\n returnData := ptr\n }\n }\n\n /// @dev Returns if an module is enabled\n /// @return True if the module is enabled\n function isModuleEnabled(address module) public view returns (bool) {\n return SENTINEL_MODULES != module && modules[module] != address(0);\n }\n\n /// @dev Returns array of modules.\n /// @param start Start of the page.\n /// @param pageSize Maximum number of modules that should be returned.\n /// @return array Array of modules.\n /// @return next Start of the next page.\n function getModulesPaginated(address start, uint256 pageSize) external view returns (address[] memory array, address next) {\n // Init array with max page size\n array = new address[](pageSize);\n\n // Populate return array\n uint256 moduleCount = 0;\n address currentModule = modules[start];\n while (currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {\n array[moduleCount] = currentModule;\n currentModule = modules[currentModule];\n moduleCount++;\n }\n next = currentModule;\n // Set correct size of returned array\n // solhint-disable-next-line no-inline-assembly\n assembly {\n mstore(array, moduleCount)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/OwnerManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/SelfAuthorized.sol\";\n\n/// @title OwnerManager - Manages a set of owners and a threshold to perform actions.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract OwnerManager is SelfAuthorized {\n event AddedOwner(address owner);\n event RemovedOwner(address owner);\n event ChangedThreshold(uint256 threshold);\n\n address internal constant SENTINEL_OWNERS = address(0x1);\n\n mapping(address => address) internal owners;\n uint256 internal ownerCount;\n uint256 internal threshold;\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n function setupOwners(address[] memory _owners, uint256 _threshold) internal {\n // Threshold can only be 0 at initialization.\n // Check ensures that setup function can only be called once.\n require(threshold == 0, \"GS200\");\n // Validate that threshold is smaller than number of added owners.\n require(_threshold <= _owners.length, \"GS201\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"GS202\");\n // Initializing Safe owners.\n address currentOwner = SENTINEL_OWNERS;\n for (uint256 i = 0; i < _owners.length; i++) {\n // Owner address cannot be null.\n address owner = _owners[i];\n require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, \"GS203\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"GS204\");\n owners[currentOwner] = owner;\n currentOwner = owner;\n }\n owners[currentOwner] = SENTINEL_OWNERS;\n ownerCount = _owners.length;\n threshold = _threshold;\n }\n\n /// @dev Allows to add a new owner to the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.\n /// @param owner New owner address.\n /// @param _threshold New threshold.\n function addOwnerWithThreshold(address owner, uint256 _threshold) public authorized {\n // Owner address cannot be null, the sentinel or the Safe itself.\n require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), \"GS203\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"GS204\");\n owners[owner] = owners[SENTINEL_OWNERS];\n owners[SENTINEL_OWNERS] = owner;\n ownerCount++;\n emit AddedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold) changeThreshold(_threshold);\n }\n\n /// @dev Allows to remove an owner from the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.\n /// @param prevOwner Owner that pointed to the owner to be removed in the linked list\n /// @param owner Owner address to be removed.\n /// @param _threshold New threshold.\n function removeOwner(\n address prevOwner,\n address owner,\n uint256 _threshold\n ) public authorized {\n // Only allow to remove an owner, if threshold can still be reached.\n require(ownerCount - 1 >= _threshold, \"GS201\");\n // Validate owner address and check that it corresponds to owner index.\n require(owner != address(0) && owner != SENTINEL_OWNERS, \"GS203\");\n require(owners[prevOwner] == owner, \"GS205\");\n owners[prevOwner] = owners[owner];\n owners[owner] = address(0);\n ownerCount--;\n emit RemovedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold) changeThreshold(_threshold);\n }\n\n /// @dev Allows to swap/replace an owner from the Safe with another address.\n /// This can only be done via a Safe transaction.\n /// @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.\n /// @param prevOwner Owner that pointed to the owner to be replaced in the linked list\n /// @param oldOwner Owner address to be replaced.\n /// @param newOwner New owner address.\n function swapOwner(\n address prevOwner,\n address oldOwner,\n address newOwner\n ) public authorized {\n // Owner address cannot be null, the sentinel or the Safe itself.\n require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), \"GS203\");\n // No duplicate owners allowed.\n require(owners[newOwner] == address(0), \"GS204\");\n // Validate oldOwner address and check that it corresponds to owner index.\n require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, \"GS203\");\n require(owners[prevOwner] == oldOwner, \"GS205\");\n owners[newOwner] = owners[oldOwner];\n owners[prevOwner] = newOwner;\n owners[oldOwner] = address(0);\n emit RemovedOwner(oldOwner);\n emit AddedOwner(newOwner);\n }\n\n /// @dev Allows to update the number of required confirmations by Safe owners.\n /// This can only be done via a Safe transaction.\n /// @notice Changes the threshold of the Safe to `_threshold`.\n /// @param _threshold New threshold.\n function changeThreshold(uint256 _threshold) public authorized {\n // Validate that threshold is smaller than number of owners.\n require(_threshold <= ownerCount, \"GS201\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"GS202\");\n threshold = _threshold;\n emit ChangedThreshold(threshold);\n }\n\n function getThreshold() public view returns (uint256) {\n return threshold;\n }\n\n function isOwner(address owner) public view returns (bool) {\n return owner != SENTINEL_OWNERS && owners[owner] != address(0);\n }\n\n /// @dev Returns array of owners.\n /// @return Array of Safe owners.\n function getOwners() public view returns (address[] memory) {\n address[] memory array = new address[](ownerCount);\n\n // populate return array\n uint256 index = 0;\n address currentOwner = owners[SENTINEL_OWNERS];\n while (currentOwner != SENTINEL_OWNERS) {\n array[index] = currentOwner;\n currentOwner = owners[currentOwner];\n index++;\n }\n return array;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/Enum.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Enum - Collection of enums\n/// @author Richard Meissner - \ncontract Enum {\n enum Operation {Call, DelegateCall}\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/EtherPaymentFallback.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title EtherPaymentFallback - A contract that has a fallback to accept ether payments\n/// @author Richard Meissner - \ncontract EtherPaymentFallback {\n event SafeReceived(address indexed sender, uint256 value);\n\n /// @dev Fallback function accepts Ether transactions.\n receive() external payable {\n emit SafeReceived(msg.sender, msg.value);\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SecuredTokenTransfer.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SecuredTokenTransfer - Secure token transfer\n/// @author Richard Meissner - \ncontract SecuredTokenTransfer {\n /// @dev Transfers a token and returns if it was a success\n /// @param token Token that should be transferred\n /// @param receiver Receiver to whom the token should be transferred\n /// @param amount The amount of tokens that should be transferred\n function transferToken(\n address token,\n address receiver,\n uint256 amount\n ) internal returns (bool transferred) {\n // 0xa9059cbb - keccack(\"transfer(address,uint256)\")\n bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // We write the return value to scratch space.\n // See https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory\n let success := call(sub(gas(), 10000), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n switch returndatasize()\n case 0 {\n transferred := success\n }\n case 0x20 {\n transferred := iszero(or(iszero(success), iszero(mload(0))))\n }\n default {\n transferred := 0\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SelfAuthorized.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SelfAuthorized - authorizes current contract to perform actions\n/// @author Richard Meissner - \ncontract SelfAuthorized {\n function requireSelfCall() private view {\n require(msg.sender == address(this), \"GS031\");\n }\n\n modifier authorized() {\n // This is a function call as it minimized the bytecode size\n requireSelfCall();\n _;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SignatureDecoder.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SignatureDecoder - Decodes signatures that a encoded as bytes\n/// @author Richard Meissner - \ncontract SignatureDecoder {\n /// @dev divides bytes signature into `uint8 v, bytes32 r, bytes32 s`.\n /// @notice Make sure to peform a bounds check for @param pos, to avoid out of bounds access on @param signatures\n /// @param pos which signature to read. A prior bounds check of this parameter should be performed, to avoid out of bounds access\n /// @param signatures concatenated rsv signatures\n function signatureSplit(bytes memory signatures, uint256 pos)\n internal\n pure\n returns (\n uint8 v,\n bytes32 r,\n bytes32 s\n )\n {\n // The signature format is a compact form of:\n // {bytes32 r}{bytes32 s}{uint8 v}\n // Compact means, uint8 is not padded to 32 bytes.\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let signaturePos := mul(0x41, pos)\n r := mload(add(signatures, add(signaturePos, 0x20)))\n s := mload(add(signatures, add(signaturePos, 0x40)))\n // Here we are loading the last 32 bytes, including 31 bytes\n // of 's'. There is no 'mload8' to do this.\n //\n // 'byte' is not working due to the Solidity parser, so lets\n // use the second best option, 'and'\n v := and(mload(add(signatures, add(signaturePos, 0x41))), 0xff)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/Singleton.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Singleton - Base for singleton contracts (should always be first super contract)\n/// This contract is tightly coupled to our proxy contract (see `proxies/GnosisSafeProxy.sol`)\n/// @author Richard Meissner - \ncontract Singleton {\n // singleton always needs to be first declared variable, to ensure that it is at the same location as in the Proxy contract.\n // It should also always be ensured that the address is stored alone (uses a full word)\n address private singleton;\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/StorageAccessible.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title StorageAccessible - generic base contract that allows callers to access all internal storage.\n/// @notice See https://github.com/gnosis/util-contracts/blob/bb5fe5fb5df6d8400998094fb1b32a178a47c3a1/contracts/StorageAccessible.sol\ncontract StorageAccessible {\n /**\n * @dev Reads `length` bytes of storage in the currents contract\n * @param offset - the offset in the current contract's storage in words to start reading from\n * @param length - the number of words (32 bytes) of data to read\n * @return the bytes that were read.\n */\n function getStorageAt(uint256 offset, uint256 length) public view returns (bytes memory) {\n bytes memory result = new bytes(length * 32);\n for (uint256 index = 0; index < length; index++) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let word := sload(add(offset, index))\n mstore(add(add(result, 0x20), mul(index, 0x20)), word)\n }\n }\n return result;\n }\n\n /**\n * @dev Performs a delegetecall on a targetContract in the context of self.\n * Internally reverts execution to avoid side effects (making it static).\n *\n * This method reverts with data equal to `abi.encode(bool(success), bytes(response))`.\n * Specifically, the `returndata` after a call to this method will be:\n * `success:bool || response.length:uint256 || response:bytes`.\n *\n * @param targetContract Address of the contract containing the code to execute.\n * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).\n */\n function simulateAndRevert(address targetContract, bytes memory calldataPayload) external {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let success := delegatecall(gas(), targetContract, add(calldataPayload, 0x20), mload(calldataPayload), 0, 0)\n\n mstore(0x00, success)\n mstore(0x20, returndatasize())\n returndatacopy(0x40, 0, returndatasize())\n revert(0, add(returndatasize(), 0x40))\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/external/GnosisSafeMath.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title GnosisSafeMath\n * @dev Math operations with safety checks that revert on error\n * Renamed from SafeMath to GnosisSafeMath to avoid conflicts\n * TODO: remove once open zeppelin update to solc 0.5.0\n */\nlibrary GnosisSafeMath {\n /**\n * @dev Multiplies two numbers, reverts on overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b);\n\n return c;\n }\n\n /**\n * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Adds two numbers, reverts on overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a);\n\n return c;\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 a >= b ? a : b;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/GnosisSafe.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./base/ModuleManager.sol\";\nimport \"./base/OwnerManager.sol\";\nimport \"./base/FallbackManager.sol\";\nimport \"./base/GuardManager.sol\";\nimport \"./common/EtherPaymentFallback.sol\";\nimport \"./common/Singleton.sol\";\nimport \"./common/SignatureDecoder.sol\";\nimport \"./common/SecuredTokenTransfer.sol\";\nimport \"./common/StorageAccessible.sol\";\nimport \"./interfaces/ISignatureValidator.sol\";\nimport \"./external/GnosisSafeMath.sol\";\n\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafe is\n EtherPaymentFallback,\n Singleton,\n ModuleManager,\n OwnerManager,\n SignatureDecoder,\n SecuredTokenTransfer,\n ISignatureValidatorConstants,\n FallbackManager,\n StorageAccessible,\n GuardManager\n{\n using GnosisSafeMath for uint256;\n\n string public constant VERSION = \"1.3.0\";\n\n // keccak256(\n // \"EIP712Domain(uint256 chainId,address verifyingContract)\"\n // );\n bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;\n\n // keccak256(\n // \"SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)\"\n // );\n bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;\n\n event SafeSetup(address indexed initiator, address[] owners, uint256 threshold, address initializer, address fallbackHandler);\n event ApproveHash(bytes32 indexed approvedHash, address indexed owner);\n event SignMsg(bytes32 indexed msgHash);\n event ExecutionFailure(bytes32 txHash, uint256 payment);\n event ExecutionSuccess(bytes32 txHash, uint256 payment);\n\n uint256 public nonce;\n bytes32 private _deprecatedDomainSeparator;\n // Mapping to keep track of all message hashes that have been approve by ALL REQUIRED owners\n mapping(bytes32 => uint256) public signedMessages;\n // Mapping to keep track of all hashes (message or transaction) that have been approve by ANY owners\n mapping(address => mapping(bytes32 => uint256)) public approvedHashes;\n\n // This constructor ensures that this contract can only be used as a master copy for Proxy contracts\n constructor() {\n // By setting the threshold it is not possible to call setup anymore,\n // so we create a Safe with 0 owners and threshold 1.\n // This is an unusable Safe, perfect for the singleton\n threshold = 1;\n }\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n /// @param to Contract address for optional delegate call.\n /// @param data Data payload for optional delegate call.\n /// @param fallbackHandler Handler for fallback calls to this contract\n /// @param paymentToken Token that should be used for the payment (0 is ETH)\n /// @param payment Value that should be paid\n /// @param paymentReceiver Adddress that should receive the payment (or 0 if tx.origin)\n function setup(\n address[] calldata _owners,\n uint256 _threshold,\n address to,\n bytes calldata data,\n address fallbackHandler,\n address paymentToken,\n uint256 payment,\n address payable paymentReceiver\n ) external {\n // setupOwners checks if the Threshold is already set, therefore preventing that this method is called twice\n setupOwners(_owners, _threshold);\n if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);\n // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules\n setupModules(to, data);\n\n if (payment > 0) {\n // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)\n // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment\n handlePayment(payment, 0, 1, paymentToken, paymentReceiver);\n }\n emit SafeSetup(msg.sender, _owners, _threshold, to, fallbackHandler);\n }\n\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\n /// Note: The fees are always transferred, even if the user transaction fails.\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @param safeTxGas Gas that should be used for the Safe transaction.\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Gas price that should be used for the payment calculation.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\n function execTransaction(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures\n ) public payable virtual returns (bool success) {\n bytes32 txHash;\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n bytes memory txHashData =\n encodeTransactionData(\n // Transaction info\n to,\n value,\n data,\n operation,\n safeTxGas,\n // Payment info\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n // Signature info\n nonce\n );\n // Increase nonce and execute transaction.\n nonce++;\n txHash = keccak256(txHashData);\n checkSignatures(txHash, txHashData, signatures);\n }\n address guard = getGuard();\n {\n if (guard != address(0)) {\n Guard(guard).checkTransaction(\n // Transaction info\n to,\n value,\n data,\n operation,\n safeTxGas,\n // Payment info\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n // Signature info\n signatures,\n msg.sender\n );\n }\n }\n // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)\n // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150\n require(gasleft() >= ((safeTxGas * 64) / 63).max(safeTxGas + 2500) + 500, \"GS010\");\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n uint256 gasUsed = gasleft();\n // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)\n // We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas\n success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);\n gasUsed = gasUsed.sub(gasleft());\n // If no safeTxGas and no gasPrice was set (e.g. both are 0), then the internal tx is required to be successful\n // This makes it possible to use `estimateGas` without issues, as it searches for the minimum gas where the tx doesn't revert\n require(success || safeTxGas != 0 || gasPrice != 0, \"GS013\");\n // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls\n uint256 payment = 0;\n if (gasPrice > 0) {\n payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);\n }\n if (success) emit ExecutionSuccess(txHash, payment);\n else emit ExecutionFailure(txHash, payment);\n }\n {\n if (guard != address(0)) {\n Guard(guard).checkAfterExecution(txHash, success);\n }\n }\n }\n\n function handlePayment(\n uint256 gasUsed,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver\n ) private returns (uint256 payment) {\n // solhint-disable-next-line avoid-tx-origin\n address payable receiver = refundReceiver == address(0) ? payable(tx.origin) : refundReceiver;\n if (gasToken == address(0)) {\n // For ETH we will only adjust the gas price to not be higher than the actual used gas price\n payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);\n require(receiver.send(payment), \"GS011\");\n } else {\n payment = gasUsed.add(baseGas).mul(gasPrice);\n require(transferToken(gasToken, receiver, payment), \"GS012\");\n }\n }\n\n /**\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n * @param data That should be signed (this is passed to an external validator contract)\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\n */\n function checkSignatures(\n bytes32 dataHash,\n bytes memory data,\n bytes memory signatures\n ) public view {\n // Load threshold to avoid multiple storage loads\n uint256 _threshold = threshold;\n // Check that a threshold is set\n require(_threshold > 0, \"GS001\");\n checkNSignatures(dataHash, data, signatures, _threshold);\n }\n\n /**\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n * @param data That should be signed (this is passed to an external validator contract)\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\n * @param requiredSignatures Amount of required valid signatures.\n */\n function checkNSignatures(\n bytes32 dataHash,\n bytes memory data,\n bytes memory signatures,\n uint256 requiredSignatures\n ) public view {\n // Check that the provided signature data is not too short\n require(signatures.length >= requiredSignatures.mul(65), \"GS020\");\n // There cannot be an owner with address 0.\n address lastOwner = address(0);\n address currentOwner;\n uint8 v;\n bytes32 r;\n bytes32 s;\n uint256 i;\n for (i = 0; i < requiredSignatures; i++) {\n (v, r, s) = signatureSplit(signatures, i);\n if (v == 0) {\n // If v is 0 then it is a contract signature\n // When handling contract signatures the address of the contract is encoded into r\n currentOwner = address(uint160(uint256(r)));\n\n // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes\n // This check is not completely accurate, since it is possible that more signatures than the threshold are send.\n // Here we only check that the pointer is not pointing inside the part that is being processed\n require(uint256(s) >= requiredSignatures.mul(65), \"GS021\");\n\n // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)\n require(uint256(s).add(32) <= signatures.length, \"GS022\");\n\n // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length\n uint256 contractSignatureLen;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n contractSignatureLen := mload(add(add(signatures, s), 0x20))\n }\n require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, \"GS023\");\n\n // Check signature\n bytes memory contractSignature;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s\n contractSignature := add(add(signatures, s), 0x20)\n }\n require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, \"GS024\");\n } else if (v == 1) {\n // If v is 1 then it is an approved hash\n // When handling approved hashes the address of the approver is encoded into r\n currentOwner = address(uint160(uint256(r)));\n // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction\n require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, \"GS025\");\n } else if (v > 30) {\n // If v > 30 then default va (27,28) has been adjusted for eth_sign flow\n // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover\n currentOwner = ecrecover(keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", dataHash)), v - 4, r, s);\n } else {\n // Default is the ecrecover flow with the provided data hash\n // Use ecrecover with the messageHash for EOA signatures\n currentOwner = ecrecover(dataHash, v, r, s);\n }\n require(currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS, \"GS026\");\n lastOwner = currentOwner;\n }\n }\n\n /// @dev Allows to estimate a Safe transaction.\n /// This method is only meant for estimation purpose, therefore the call will always revert and encode the result in the revert data.\n /// Since the `estimateGas` function includes refunds, call this method to get an estimated of the costs that are deducted from the safe with `execTransaction`\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @return Estimate without refunds and overhead fees (base transaction and payload data gas costs).\n /// @notice Deprecated in favor of common/StorageAccessible.sol and will be removed in next version.\n function requiredTxGas(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation\n ) external returns (uint256) {\n uint256 startGas = gasleft();\n // We don't provide an error message here, as we use it to return the estimate\n require(execute(to, value, data, operation, gasleft()));\n uint256 requiredGas = startGas - gasleft();\n // Convert response to string and return via error message\n revert(string(abi.encodePacked(requiredGas)));\n }\n\n /**\n * @dev Marks a hash as approved. This can be used to validate a hash that is used by a signature.\n * @param hashToApprove The hash that should be marked as approved for signatures that are verified by this contract.\n */\n function approveHash(bytes32 hashToApprove) external {\n require(owners[msg.sender] != address(0), \"GS030\");\n approvedHashes[msg.sender][hashToApprove] = 1;\n emit ApproveHash(hashToApprove, msg.sender);\n }\n\n /// @dev Returns the chain id used by this contract.\n function getChainId() public view returns (uint256) {\n uint256 id;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n id := chainid()\n }\n return id;\n }\n\n function domainSeparator() public view returns (bytes32) {\n return keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, getChainId(), this));\n }\n\n /// @dev Returns the bytes that are hashed to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Gas that should be used for the safe transaction.\n /// @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash bytes.\n function encodeTransactionData(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n ) public view returns (bytes memory) {\n bytes32 safeTxHash =\n keccak256(\n abi.encode(\n SAFE_TX_TYPEHASH,\n to,\n value,\n keccak256(data),\n operation,\n safeTxGas,\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n _nonce\n )\n );\n return abi.encodePacked(bytes1(0x19), bytes1(0x01), domainSeparator(), safeTxHash);\n }\n\n /// @dev Returns hash to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Fas that should be used for the safe transaction.\n /// @param baseGas Gas costs for data used to trigger the safe transaction.\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash.\n function getTransactionHash(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n ) public view returns (bytes32) {\n return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./GnosisSafe.sol\";\n\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafeL2 is GnosisSafe {\n event SafeMultiSigTransaction(\n address to,\n uint256 value,\n bytes data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes signatures,\n // We combine nonce, sender and threshold into one to avoid stack too deep\n // Dev note: additionalInfo should not contain `bytes`, as this complicates decoding\n bytes additionalInfo\n );\n\n event SafeModuleTransaction(address module, address to, uint256 value, bytes data, Enum.Operation operation);\n\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\n /// Note: The fees are always transferred, even if the user transaction fails.\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @param safeTxGas Gas that should be used for the Safe transaction.\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Gas price that should be used for the payment calculation.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\n function execTransaction(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures\n ) public payable override returns (bool) {\n bytes memory additionalInfo;\n {\n additionalInfo = abi.encode(nonce, msg.sender, threshold);\n }\n emit SafeMultiSigTransaction(\n to,\n value,\n data,\n operation,\n safeTxGas,\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n signatures,\n additionalInfo\n );\n return super.execTransaction(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, signatures);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public override returns (bool success) {\n emit SafeModuleTransaction(msg.sender, to, value, data, operation);\n success = super.execTransactionFromModule(to, value, data, operation);\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/interfaces/ISignatureValidator.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\ncontract ISignatureValidatorConstants {\n // bytes4(keccak256(\"isValidSignature(bytes,bytes)\")\n bytes4 internal constant EIP1271_MAGIC_VALUE = 0x20c13b0b;\n}\n\nabstract contract ISignatureValidator is ISignatureValidatorConstants {\n /**\n * @dev Should return whether the signature provided is valid for the provided data\n * @param _data Arbitrary length data signed on the behalf of address(this)\n * @param _signature Signature byte array associated with _data\n *\n * MUST return the bytes4 magic value 0x20c13b0b when function passes.\n * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)\n * MUST allow external calls\n */\n function isValidSignature(bytes memory _data, bytes memory _signature) public view virtual returns (bytes4);\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Multi Send Call Only - Allows to batch multiple transactions into one, but only calls\n/// @author Stefan George - \n/// @author Richard Meissner - \n/// @notice The guard logic is not required here as this contract doesn't support nested delegate calls\ncontract MultiSendCallOnly {\n /// @dev Sends multiple transactions and reverts all if one fails.\n /// @param transactions Encoded transactions. Each transaction is encoded as a packed bytes of\n /// operation has to be uint8(0) in this version (=> 1 byte),\n /// to as a address (=> 20 bytes),\n /// value as a uint256 (=> 32 bytes),\n /// data length as a uint256 (=> 32 bytes),\n /// data as bytes.\n /// see abi.encodePacked for more information on packed encoding\n /// @notice The code is for most part the same as the normal MultiSend (to keep compatibility),\n /// but reverts if a transaction tries to use a delegatecall.\n /// @notice This method is payable as delegatecalls keep the msg.value from the previous call\n /// If the calling method (e.g. execTransaction) received ETH this would revert otherwise\n function multiSend(bytes memory transactions) public payable {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let length := mload(transactions)\n let i := 0x20\n for {\n // Pre block is not used in \"while mode\"\n } lt(i, length) {\n // Post block is not used in \"while mode\"\n } {\n // First byte of the data is the operation.\n // We shift by 248 bits (256 - 8 [operation byte]) it right since mload will always load 32 bytes (a word).\n // This will also zero out unused data.\n let operation := shr(0xf8, mload(add(transactions, i)))\n // We offset the load address by 1 byte (operation byte)\n // We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data.\n let to := shr(0x60, mload(add(transactions, add(i, 0x01))))\n // We offset the load address by 21 byte (operation byte + 20 address bytes)\n let value := mload(add(transactions, add(i, 0x15)))\n // We offset the load address by 53 byte (operation byte + 20 address bytes + 32 value bytes)\n let dataLength := mload(add(transactions, add(i, 0x35)))\n // We offset the load address by 85 byte (operation byte + 20 address bytes + 32 value bytes + 32 data length bytes)\n let data := add(transactions, add(i, 0x55))\n let success := 0\n switch operation\n case 0 {\n success := call(gas(), to, value, data, dataLength, 0, 0)\n }\n // This version does not allow delegatecalls\n case 1 {\n revert(0, 0)\n }\n if eq(success, 0) {\n revert(0, 0)\n }\n // Next entry starts at 85 byte + data length\n i := add(i, add(0x55, dataLength))\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxy.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain\n/// @author Richard Meissner - \ninterface IProxy {\n function masterCopy() external view returns (address);\n}\n\n/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafeProxy {\n // singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.\n // To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`\n address internal singleton;\n\n /// @dev Constructor function sets address of singleton contract.\n /// @param _singleton Singleton address.\n constructor(address _singleton) {\n require(_singleton != address(0), \"Invalid singleton address provided\");\n singleton = _singleton;\n }\n\n /// @dev Fallback function forwards all transactions and returns all received return data.\n fallback() external payable {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)\n // 0xa619486e == keccak(\"masterCopy()\"). The value is right padded to 32-bytes with 0s\n if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {\n mstore(0, _singleton)\n return(0, 0x20)\n }\n calldatacopy(0, 0, calldatasize())\n let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)\n returndatacopy(0, 0, returndatasize())\n if eq(success, 0) {\n revert(0, returndatasize())\n }\n return(0, returndatasize())\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./GnosisSafeProxy.sol\";\nimport \"./IProxyCreationCallback.sol\";\n\n/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n/// @author Stefan George - \ncontract GnosisSafeProxyFactory {\n event ProxyCreation(GnosisSafeProxy proxy, address singleton);\n\n /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n /// @param singleton Address of singleton contract.\n /// @param data Payload for message call sent to new proxy contract.\n function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {\n proxy = new GnosisSafeProxy(singleton);\n if (data.length > 0)\n // solhint-disable-next-line no-inline-assembly\n assembly {\n if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {\n revert(0, 0)\n }\n }\n emit ProxyCreation(proxy, singleton);\n }\n\n /// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.\n function proxyRuntimeCode() public pure returns (bytes memory) {\n return type(GnosisSafeProxy).runtimeCode;\n }\n\n /// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.\n function proxyCreationCode() public pure returns (bytes memory) {\n return type(GnosisSafeProxy).creationCode;\n }\n\n /// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.\n /// This method is only meant as an utility to be called from other methods\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function deployProxyWithNonce(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce\n ) internal returns (GnosisSafeProxy proxy) {\n // If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it\n bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));\n bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));\n // solhint-disable-next-line no-inline-assembly\n assembly {\n proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)\n }\n require(address(proxy) != address(0), \"Create2 call failed\");\n }\n\n /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function createProxyWithNonce(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce\n ) public returns (GnosisSafeProxy proxy) {\n proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);\n if (initializer.length > 0)\n // solhint-disable-next-line no-inline-assembly\n assembly {\n if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {\n revert(0, 0)\n }\n }\n emit ProxyCreation(proxy, _singleton);\n }\n\n /// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n /// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.\n function createProxyWithCallback(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce,\n IProxyCreationCallback callback\n ) public returns (GnosisSafeProxy proxy) {\n uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));\n proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);\n if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);\n }\n\n /// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`\n /// This method is only meant for address calculation purpose when you use an initializer that would revert,\n /// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function calculateCreateProxyWithNonceAddress(\n address _singleton,\n bytes calldata initializer,\n uint256 saltNonce\n ) external returns (GnosisSafeProxy proxy) {\n proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);\n revert(string(abi.encodePacked(proxy)));\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/IProxyCreationCallback.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"./GnosisSafeProxy.sol\";\n\ninterface IProxyCreationCallback {\n function proxyCreated(\n GnosisSafeProxy proxy,\n address _singleton,\n bytes calldata initializer,\n uint256 saltNonce\n ) external;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/core/Module.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Module Interface - A contract that can pass messages to a Module Manager contract if enabled by that contract.\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../interfaces/IAvatar.sol\";\nimport \"../factory/FactoryFriendly.sol\";\nimport \"../guard/Guardable.sol\";\n\nabstract contract Module is FactoryFriendly, Guardable {\n /// @dev Address that will ultimately execute function calls.\n address public avatar;\n /// @dev Address that this module will pass transactions to.\n address public target;\n\n /// @dev Emitted each time the avatar is set.\n event AvatarSet(address indexed previousAvatar, address indexed newAvatar);\n /// @dev Emitted each time the Target is set.\n event TargetSet(address indexed previousTarget, address indexed newTarget);\n\n /// @dev Sets the avatar to a new avatar (`newAvatar`).\n /// @notice Can only be called by the current owner.\n function setAvatar(address _avatar) public onlyOwner {\n address previousAvatar = avatar;\n avatar = _avatar;\n emit AvatarSet(previousAvatar, _avatar);\n }\n\n /// @dev Sets the target to a new target (`newTarget`).\n /// @notice Can only be called by the current owner.\n function setTarget(address _target) public onlyOwner {\n address previousTarget = target;\n target = _target;\n emit TargetSet(previousTarget, _target);\n }\n\n /// @dev Passes a transaction to be executed by the avatar.\n /// @notice Can only be called by this contract.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function exec(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) internal returns (bool success) {\n /// Check if a transactioon guard is enabled.\n if (guard != address(0)) {\n IGuard(guard).checkTransaction(\n /// Transaction info used by module transactions.\n to,\n value,\n data,\n operation,\n /// Zero out the redundant transaction information only used for Safe multisig transctions.\n 0,\n 0,\n 0,\n address(0),\n payable(0),\n bytes(\"0x\"),\n msg.sender\n );\n }\n success = IAvatar(target).execTransactionFromModule(\n to,\n value,\n data,\n operation\n );\n if (guard != address(0)) {\n IGuard(guard).checkAfterExecution(bytes32(\"0x\"), success);\n }\n return success;\n }\n\n /// @dev Passes a transaction to be executed by the target and returns data.\n /// @notice Can only be called by this contract.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execAndReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) internal returns (bool success, bytes memory returnData) {\n /// Check if a transactioon guard is enabled.\n if (guard != address(0)) {\n IGuard(guard).checkTransaction(\n /// Transaction info used by module transactions.\n to,\n value,\n data,\n operation,\n /// Zero out the redundant transaction information only used for Safe multisig transctions.\n 0,\n 0,\n 0,\n address(0),\n payable(0),\n bytes(\"0x\"),\n msg.sender\n );\n }\n (success, returnData) = IAvatar(target)\n .execTransactionFromModuleReturnData(to, value, data, operation);\n if (guard != address(0)) {\n IGuard(guard).checkAfterExecution(bytes32(\"0x\"), success);\n }\n return (success, returnData);\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/factory/FactoryFriendly.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Zodiac FactoryFriendly - A contract that allows other contracts to be initializable and pass bytes as arguments to define contract state\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nabstract contract FactoryFriendly is OwnableUpgradeable {\n function setUp(bytes memory initializeParams) public virtual;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.8.0;\n\ncontract ModuleProxyFactory {\n event ModuleProxyCreation(\n address indexed proxy,\n address indexed masterCopy\n );\n\n /// `target` can not be zero.\n error ZeroAddress(address target);\n\n /// `address_` is already taken.\n error TakenAddress(address address_);\n\n /// @notice Initialization failed.\n error FailedInitialization();\n\n function createProxy(address target, bytes32 salt)\n internal\n returns (address result)\n {\n if (address(target) == address(0)) revert ZeroAddress(target);\n bytes memory deployment = abi.encodePacked(\n hex\"602d8060093d393df3363d3d373d3d3d363d73\",\n target,\n hex\"5af43d82803e903d91602b57fd5bf3\"\n );\n // solhint-disable-next-line no-inline-assembly\n assembly {\n result := create2(0, add(deployment, 0x20), mload(deployment), salt)\n }\n if (result == address(0)) revert TakenAddress(result);\n }\n\n function deployModule(\n address masterCopy,\n bytes memory initializer,\n uint256 saltNonce\n ) public returns (address proxy) {\n proxy = createProxy(\n masterCopy,\n keccak256(abi.encodePacked(keccak256(initializer), saltNonce))\n );\n (bool success, ) = proxy.call(initializer);\n if (!success) revert FailedInitialization();\n\n emit ModuleProxyCreation(proxy, masterCopy);\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/guard/BaseGuard.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport \"../interfaces/IGuard.sol\";\n\nabstract contract BaseGuard is IERC165 {\n function supportsInterface(bytes4 interfaceId)\n external\n pure\n override\n returns (bool)\n {\n return\n interfaceId == type(IGuard).interfaceId || // 0xe6d7a83a\n interfaceId == type(IERC165).interfaceId; // 0x01ffc9a7\n }\n\n /// @dev Module transactions only use the first four parameters: to, value, data, and operation.\n /// Module.sol hardcodes the remaining parameters as 0 since they are not used for module transactions.\n /// @notice This interface is used to maintain compatibilty with Gnosis Safe transaction guards.\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external virtual;\n\n function checkAfterExecution(bytes32 txHash, bool success) external virtual;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/guard/Guardable.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"./BaseGuard.sol\";\n\n/// @title Guardable - A contract that manages fallback calls made to this contract\ncontract Guardable is OwnableUpgradeable {\n address public guard;\n\n event ChangedGuard(address guard);\n\n /// `guard_` does not implement IERC165.\n error NotIERC165Compliant(address guard_);\n\n /// @dev Set a guard that checks transactions before execution.\n /// @param _guard The address of the guard to be used or the 0 address to disable the guard.\n function setGuard(address _guard) external onlyOwner {\n if (_guard != address(0)) {\n if (!BaseGuard(_guard).supportsInterface(type(IGuard).interfaceId))\n revert NotIERC165Compliant(_guard);\n }\n guard = _guard;\n emit ChangedGuard(guard);\n }\n\n function getGuard() external view returns (address _guard) {\n return guard;\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Zodiac Avatar - A contract that manages modules that can execute transactions via this contract.\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\n\ninterface IAvatar {\n event EnabledModule(address module);\n event DisabledModule(address module);\n event ExecutionFromModuleSuccess(address indexed module);\n event ExecutionFromModuleFailure(address indexed module);\n\n /// @dev Enables a module on the avatar.\n /// @notice Can only be called by the avatar.\n /// @notice Modules should be stored as a linked list.\n /// @notice Must emit EnabledModule(address module) if successful.\n /// @param module Module to be enabled.\n function enableModule(address module) external;\n\n /// @dev Disables a module on the avatar.\n /// @notice Can only be called by the avatar.\n /// @notice Must emit DisabledModule(address module) if successful.\n /// @param prevModule Address that pointed to the module to be removed in the linked list\n /// @param module Module to be removed.\n function disableModule(address prevModule, address module) external;\n\n /// @dev Allows a Module to execute a transaction.\n /// @notice Can only be called by an enabled module.\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) external returns (bool success);\n\n /// @dev Allows a Module to execute a transaction and return data\n /// @notice Can only be called by an enabled module.\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execTransactionFromModuleReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) external returns (bool success, bytes memory returnData);\n\n /// @dev Returns if an module is enabled\n /// @return True if the module is enabled\n function isModuleEnabled(address module) external view returns (bool);\n\n /// @dev Returns array of modules.\n /// @param start Start of the page.\n /// @param pageSize Maximum number of modules that should be returned.\n /// @return array Array of modules.\n /// @return next Start of the next page.\n function getModulesPaginated(address start, uint256 pageSize)\n external\n view\n returns (address[] memory array, address next);\n}\n" + }, + "@gnosis.pm/zodiac/contracts/interfaces/IGuard.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\n\ninterface IGuard {\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external;\n\n function checkAfterExecution(bytes32 txHash, bool success) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 * By default, the owner account will be the one that deploys the contract. This\n * can 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 OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\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 require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing 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 require(newOwner != address(0), \"Ownable: new owner is the zero address\");\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/governance/utils/IVotesUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotesUpgradeable {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\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 * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\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 Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 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. Equivalent to `reinitializer(1)`.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\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 * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\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 modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\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 require(_initializing, \"Initializable: contract is not initializing\");\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 function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20Upgradeable.sol\";\nimport \"./extensions/IERC20MetadataUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC20_init_unchained(name_, symbol_);\n }\n\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[45] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20PermitUpgradeable.sol\";\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/cryptography/draft-EIP712Upgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {\n using CountersUpgradeable for CountersUpgradeable.Counter;\n\n mapping(address => CountersUpgradeable.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n function __ERC20Permit_init(string memory name) internal onlyInitializing {\n __EIP712_init_unchained(name, \"1\");\n }\n\n function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSAUpgradeable.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n CountersUpgradeable.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20SnapshotUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC20Snapshot.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/ArraysUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances and\n * total supply at the time are recorded for later access.\n *\n * This can be used to safely create mechanisms based on token balances such as trustless dividends or weighted voting.\n * In naive implementations it's possible to perform a \"double spend\" attack by reusing the same balance from different\n * accounts. By using snapshots to calculate dividends or voting power, those attacks no longer apply. It can also be\n * used to create an efficient ERC20 forking mechanism.\n *\n * Snapshots are created by the internal {_snapshot} function, which will emit the {Snapshot} event and return a\n * snapshot id. To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with the snapshot\n * id. To get the balance of an account at the time of a snapshot, call the {balanceOfAt} function with the snapshot id\n * and the account address.\n *\n * NOTE: Snapshot policy can be customized by overriding the {_getCurrentSnapshotId} method. For example, having it\n * return `block.number` will trigger the creation of snapshot at the beginning of each new block. When overriding this\n * function, be careful about the monotonicity of its result. Non-monotonic snapshot ids will break the contract.\n *\n * Implementing snapshots for every block using this method will incur significant gas costs. For a gas-efficient\n * alternative consider {ERC20Votes}.\n *\n * ==== Gas Costs\n *\n * Snapshots are efficient. Snapshot creation is _O(1)_. Retrieval of balances or total supply from a snapshot is _O(log\n * n)_ in the number of snapshots that have been created, although _n_ for a specific account will generally be much\n * smaller since identical balances in subsequent snapshots are stored as a single entry.\n *\n * There is a constant overhead for normal ERC20 transfers due to the additional snapshot bookkeeping. This overhead is\n * only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent\n * transfers will have normal cost until the next snapshot, and so on.\n */\n\nabstract contract ERC20SnapshotUpgradeable is Initializable, ERC20Upgradeable {\n function __ERC20Snapshot_init() internal onlyInitializing {\n }\n\n function __ERC20Snapshot_init_unchained() internal onlyInitializing {\n }\n // Inspired by Jordi Baylina's MiniMeToken to record historical balances:\n // https://github.com/Giveth/minime/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol\n\n using ArraysUpgradeable for uint256[];\n using CountersUpgradeable for CountersUpgradeable.Counter;\n\n // Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a\n // Snapshot struct, but that would impede usage of functions that work on an array.\n struct Snapshots {\n uint256[] ids;\n uint256[] values;\n }\n\n mapping(address => Snapshots) private _accountBalanceSnapshots;\n Snapshots private _totalSupplySnapshots;\n\n // Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid.\n CountersUpgradeable.Counter private _currentSnapshotId;\n\n /**\n * @dev Emitted by {_snapshot} when a snapshot identified by `id` is created.\n */\n event Snapshot(uint256 id);\n\n /**\n * @dev Creates a new snapshot and returns its snapshot id.\n *\n * Emits a {Snapshot} event that contains the same id.\n *\n * {_snapshot} is `internal` and you have to decide how to expose it externally. Its usage may be restricted to a\n * set of accounts, for example using {AccessControl}, or it may be open to the public.\n *\n * [WARNING]\n * ====\n * While an open way of calling {_snapshot} is required for certain trust minimization mechanisms such as forking,\n * you must consider that it can potentially be used by attackers in two ways.\n *\n * First, it can be used to increase the cost of retrieval of values from snapshots, although it will grow\n * logarithmically thus rendering this attack ineffective in the long term. Second, it can be used to target\n * specific accounts and increase the cost of ERC20 transfers for them, in the ways specified in the Gas Costs\n * section above.\n *\n * We haven't measured the actual numbers; if this is something you're interested in please reach out to us.\n * ====\n */\n function _snapshot() internal virtual returns (uint256) {\n _currentSnapshotId.increment();\n\n uint256 currentId = _getCurrentSnapshotId();\n emit Snapshot(currentId);\n return currentId;\n }\n\n /**\n * @dev Get the current snapshotId\n */\n function _getCurrentSnapshotId() internal view virtual returns (uint256) {\n return _currentSnapshotId.current();\n }\n\n /**\n * @dev Retrieves the balance of `account` at the time `snapshotId` was created.\n */\n function balanceOfAt(address account, uint256 snapshotId) public view virtual returns (uint256) {\n (bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]);\n\n return snapshotted ? value : balanceOf(account);\n }\n\n /**\n * @dev Retrieves the total supply at the time `snapshotId` was created.\n */\n function totalSupplyAt(uint256 snapshotId) public view virtual returns (uint256) {\n (bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots);\n\n return snapshotted ? value : totalSupply();\n }\n\n // Update balance and/or total supply snapshots before the values are modified. This is implemented\n // in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations.\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n if (from == address(0)) {\n // mint\n _updateAccountSnapshot(to);\n _updateTotalSupplySnapshot();\n } else if (to == address(0)) {\n // burn\n _updateAccountSnapshot(from);\n _updateTotalSupplySnapshot();\n } else {\n // transfer\n _updateAccountSnapshot(from);\n _updateAccountSnapshot(to);\n }\n }\n\n function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) {\n require(snapshotId > 0, \"ERC20Snapshot: id is 0\");\n require(snapshotId <= _getCurrentSnapshotId(), \"ERC20Snapshot: nonexistent id\");\n\n // When a valid snapshot is queried, there are three possibilities:\n // a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was never\n // created for this id, and all stored snapshot ids are smaller than the requested one. The value that corresponds\n // to this id is the current one.\n // b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with the\n // requested id, and its value is the one to return.\n // c) More snapshots were created after the requested one, and the queried value was later modified. There will be\n // no entry for the requested id: the value that corresponds to it is that of the smallest snapshot id that is\n // larger than the requested one.\n //\n // In summary, we need to find an element in an array, returning the index of the smallest value that is larger if\n // it is not found, unless said value doesn't exist (e.g. when all values are smaller). Arrays.findUpperBound does\n // exactly this.\n\n uint256 index = snapshots.ids.findUpperBound(snapshotId);\n\n if (index == snapshots.ids.length) {\n return (false, 0);\n } else {\n return (true, snapshots.values[index]);\n }\n }\n\n function _updateAccountSnapshot(address account) private {\n _updateSnapshot(_accountBalanceSnapshots[account], balanceOf(account));\n }\n\n function _updateTotalSupplySnapshot() private {\n _updateSnapshot(_totalSupplySnapshots, totalSupply());\n }\n\n function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private {\n uint256 currentId = _getCurrentSnapshotId();\n if (_lastSnapshotId(snapshots.ids) < currentId) {\n snapshots.ids.push(currentId);\n snapshots.values.push(currentValue);\n }\n }\n\n function _lastSnapshotId(uint256[] storage ids) private view returns (uint256) {\n if (ids.length == 0) {\n return 0;\n } else {\n return ids[ids.length - 1];\n }\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[46] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Votes.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-ERC20PermitUpgradeable.sol\";\nimport \"../../../utils/math/MathUpgradeable.sol\";\nimport \"../../../governance/utils/IVotesUpgradeable.sol\";\nimport \"../../../utils/math/SafeCastUpgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's,\n * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1.\n *\n * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module.\n *\n * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either\n * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting\n * power can be queried through the public accessors {getVotes} and {getPastVotes}.\n *\n * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it\n * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.\n *\n * _Available since v4.2._\n */\nabstract contract ERC20VotesUpgradeable is Initializable, IVotesUpgradeable, ERC20PermitUpgradeable {\n function __ERC20Votes_init() internal onlyInitializing {\n }\n\n function __ERC20Votes_init_unchained() internal onlyInitializing {\n }\n struct Checkpoint {\n uint32 fromBlock;\n uint224 votes;\n }\n\n bytes32 private constant _DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n mapping(address => address) private _delegates;\n mapping(address => Checkpoint[]) private _checkpoints;\n Checkpoint[] private _totalSupplyCheckpoints;\n\n /**\n * @dev Get the `pos`-th checkpoint for `account`.\n */\n function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) {\n return _checkpoints[account][pos];\n }\n\n /**\n * @dev Get number of checkpoints for `account`.\n */\n function numCheckpoints(address account) public view virtual returns (uint32) {\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\n }\n\n /**\n * @dev Get the address `account` is currently delegating to.\n */\n function delegates(address account) public view virtual override returns (address) {\n return _delegates[account];\n }\n\n /**\n * @dev Gets the current votes balance for `account`\n */\n function getVotes(address account) public view virtual override returns (uint256) {\n uint256 pos = _checkpoints[account].length;\n return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;\n }\n\n /**\n * @dev Retrieve the number of votes for `account` at the end of `blockNumber`.\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_checkpoints[account], blockNumber);\n }\n\n /**\n * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances.\n * It is but NOT the sum of all the delegated votes!\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastTotalSupply(uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber);\n }\n\n /**\n * @dev Lookup a value in a list of (sorted) checkpoints.\n */\n function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) {\n // We run a binary search to look for the earliest checkpoint taken after `blockNumber`.\n //\n // During the loop, the index of the wanted checkpoint remains in the range [low-1, high).\n // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.\n // - If the middle checkpoint is after `blockNumber`, we look in [low, mid)\n // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high)\n // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not\n // out of bounds (in which case we're looking too far in the past and the result is 0).\n // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is\n // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out\n // the same.\n uint256 high = ckpts.length;\n uint256 low = 0;\n while (low < high) {\n uint256 mid = MathUpgradeable.average(low, high);\n if (ckpts[mid].fromBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n return high == 0 ? 0 : ckpts[high - 1].votes;\n }\n\n /**\n * @dev Delegate votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) public virtual override {\n _delegate(_msgSender(), delegatee);\n }\n\n /**\n * @dev Delegates votes from signer to `delegatee`\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= expiry, \"ERC20Votes: signature expired\");\n address signer = ECDSAUpgradeable.recover(\n _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))),\n v,\n r,\n s\n );\n require(nonce == _useNonce(signer), \"ERC20Votes: invalid nonce\");\n _delegate(signer, delegatee);\n }\n\n /**\n * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).\n */\n function _maxSupply() internal view virtual returns (uint224) {\n return type(uint224).max;\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been increased.\n */\n function _mint(address account, uint256 amount) internal virtual override {\n super._mint(account, amount);\n require(totalSupply() <= _maxSupply(), \"ERC20Votes: total supply risks overflowing votes\");\n\n _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been decreased.\n */\n function _burn(address account, uint256 amount) internal virtual override {\n super._burn(account, amount);\n\n _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);\n }\n\n /**\n * @dev Move voting power when tokens are transferred.\n *\n * Emits a {DelegateVotesChanged} event.\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._afterTokenTransfer(from, to, amount);\n\n _moveVotingPower(delegates(from), delegates(to), amount);\n }\n\n /**\n * @dev Change delegation for `delegator` to `delegatee`.\n *\n * Emits events {DelegateChanged} and {DelegateVotesChanged}.\n */\n function _delegate(address delegator, address delegatee) internal virtual {\n address currentDelegate = delegates(delegator);\n uint256 delegatorBalance = balanceOf(delegator);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _moveVotingPower(\n address src,\n address dst,\n uint256 amount\n ) private {\n if (src != dst && amount > 0) {\n if (src != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);\n emit DelegateVotesChanged(src, oldWeight, newWeight);\n }\n\n if (dst != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\n }\n }\n }\n\n function _writeCheckpoint(\n Checkpoint[] storage ckpts,\n function(uint256, uint256) view returns (uint256) op,\n uint256 delta\n ) private returns (uint256 oldWeight, uint256 newWeight) {\n uint256 pos = ckpts.length;\n oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes;\n newWeight = op(oldWeight, delta);\n\n if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {\n ckpts[pos - 1].votes = SafeCastUpgradeable.toUint224(newWeight);\n } else {\n ckpts.push(Checkpoint({fromBlock: SafeCastUpgradeable.toUint32(block.number), votes: SafeCastUpgradeable.toUint224(newWeight)}));\n }\n }\n\n function _add(uint256 a, uint256 b) private pure returns (uint256) {\n return a + b;\n }\n\n function _subtract(uint256 a, uint256 b) private pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[47] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20WrapperUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/ERC20Wrapper.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../utils/SafeERC20Upgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Extension of the ERC20 token contract to support token wrapping.\n *\n * Users can deposit and withdraw \"underlying tokens\" and receive a matching number of \"wrapped tokens\". This is useful\n * in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the\n * wrapping of an existing \"basic\" ERC20 into a governance token.\n *\n * _Available since v4.2._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20WrapperUpgradeable is Initializable, ERC20Upgradeable {\n IERC20Upgradeable public underlying;\n\n function __ERC20Wrapper_init(IERC20Upgradeable underlyingToken) internal onlyInitializing {\n __ERC20Wrapper_init_unchained(underlyingToken);\n }\n\n function __ERC20Wrapper_init_unchained(IERC20Upgradeable underlyingToken) internal onlyInitializing {\n underlying = underlyingToken;\n }\n\n /**\n * @dev See {ERC20-decimals}.\n */\n function decimals() public view virtual override returns (uint8) {\n try IERC20MetadataUpgradeable(address(underlying)).decimals() returns (uint8 value) {\n return value;\n } catch {\n return super.decimals();\n }\n }\n\n /**\n * @dev Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.\n */\n function depositFor(address account, uint256 amount) public virtual returns (bool) {\n SafeERC20Upgradeable.safeTransferFrom(underlying, _msgSender(), address(this), amount);\n _mint(account, amount);\n return true;\n }\n\n /**\n * @dev Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.\n */\n function withdrawTo(address account, uint256 amount) public virtual returns (bool) {\n _burn(_msgSender(), amount);\n SafeERC20Upgradeable.safeTransfer(underlying, account, amount);\n return true;\n }\n\n /**\n * @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal\n * function that can be exposed with access control if desired.\n */\n function _recover(address account) internal virtual returns (uint256) {\n uint256 value = underlying.balanceOf(address(this)) - totalSupply();\n _mint(account, value);\n return value;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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 function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\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 /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ArraysUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Arrays.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\n\n/**\n * @dev Collection of functions related to array types.\n */\nlibrary ArraysUpgradeable {\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 * `array` is expected to be sorted in ascending order, and to contain no\n * repeated elements.\n */\n function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {\n if (array.length == 0) {\n return 0;\n }\n\n uint256 low = 0;\n uint256 high = array.length;\n\n while (low < high) {\n uint256 mid = MathUpgradeable.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 down (it does integer division with truncation).\n if (array[mid] > 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 && array[low - 1] == element) {\n return low - 1;\n } else {\n return low;\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary CountersUpgradeable {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSAUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 52\n */\nabstract contract EIP712Upgradeable is Initializable {\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n __EIP712_init_unchained(name, version);\n }\n\n function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev The hash of the name parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712NameHash() internal virtual view returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /**\n * @dev The hash of the version parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712VersionHash() internal virtual view returns (bytes32) {\n return _HASHED_VERSION;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\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 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 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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / 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 prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\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 works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\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^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`.\n // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.\n // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.\n // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a\n // good first aproximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1;\n uint256 x = a;\n if (x >> 128 > 0) {\n x >>= 128;\n result <<= 64;\n }\n if (x >> 64 > 0) {\n x >>= 64;\n result <<= 32;\n }\n if (x >> 32 > 0) {\n x >>= 32;\n result <<= 16;\n }\n if (x >> 16 > 0) {\n x >>= 16;\n result <<= 8;\n }\n if (x >> 8 > 0) {\n x >>= 8;\n result <<= 4;\n }\n if (x >> 4 > 0) {\n x >>= 4;\n result <<= 2;\n }\n if (x >> 2 > 0) {\n result <<= 1;\n }\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n uint256 result = sqrt(a);\n if (rounding == Rounding.Up && result * result < a) {\n result += 1;\n }\n return result;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX 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 *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\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 * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\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 * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\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 * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\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 * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\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 * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\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 * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\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 * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\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 * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\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 * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\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 * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\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 * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\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 * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\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 * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\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 * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\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 * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\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 * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\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 * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\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 * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\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 * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\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 * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\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 * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\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 * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\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 * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\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 * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\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 * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\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 * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\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 * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\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 * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\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 * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\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 * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\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 * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\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 * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\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 * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248) {\n require(value >= type(int248).min && value <= type(int248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return int248(value);\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 * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240) {\n require(value >= type(int240).min && value <= type(int240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return int240(value);\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 * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232) {\n require(value >= type(int232).min && value <= type(int232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return int232(value);\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 * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224) {\n require(value >= type(int224).min && value <= type(int224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return int224(value);\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 * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216) {\n require(value >= type(int216).min && value <= type(int216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return int216(value);\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 * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208) {\n require(value >= type(int208).min && value <= type(int208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return int208(value);\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 * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200) {\n require(value >= type(int200).min && value <= type(int200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return int200(value);\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 * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192) {\n require(value >= type(int192).min && value <= type(int192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return int192(value);\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 * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184) {\n require(value >= type(int184).min && value <= type(int184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return int184(value);\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 * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176) {\n require(value >= type(int176).min && value <= type(int176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return int176(value);\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 * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168) {\n require(value >= type(int168).min && value <= type(int168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return int168(value);\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 * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160) {\n require(value >= type(int160).min && value <= type(int160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return int160(value);\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 * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152) {\n require(value >= type(int152).min && value <= type(int152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return int152(value);\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 * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144) {\n require(value >= type(int144).min && value <= type(int144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return int144(value);\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 * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136) {\n require(value >= type(int136).min && value <= type(int136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return int136(value);\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 * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128) {\n require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return int128(value);\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 * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120) {\n require(value >= type(int120).min && value <= type(int120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return int120(value);\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 * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112) {\n require(value >= type(int112).min && value <= type(int112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return int112(value);\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 * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104) {\n require(value >= type(int104).min && value <= type(int104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return int104(value);\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 * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96) {\n require(value >= type(int96).min && value <= type(int96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return int96(value);\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 * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88) {\n require(value >= type(int88).min && value <= type(int88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return int88(value);\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 * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80) {\n require(value >= type(int80).min && value <= type(int80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return int80(value);\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 * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72) {\n require(value >= type(int72).min && value <= type(int72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return int72(value);\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 * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64) {\n require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return int64(value);\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 * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56) {\n require(value >= type(int56).min && value <= type(int56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return int56(value);\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 * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48) {\n require(value >= type(int48).min && value <= type(int48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return int48(value);\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 * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40) {\n require(value >= type(int40).min && value <= type(int40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return int40(value);\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 * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32) {\n require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return int32(value);\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 * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24) {\n require(value >= type(int24).min && value <= type(int24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return int24(value);\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 * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16) {\n require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return int16(value);\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 * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8) {\n require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return int8(value);\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 * _Available since v3.0._\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 require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@openzeppelin/contracts/governance/utils/IVotes.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotes {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/ERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\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 /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\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" + }, + "@openzeppelin/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 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 *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165Storage.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Storage.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ERC165.sol\";\n\n/**\n * @dev Storage based implementation of the {IERC165} interface.\n *\n * Contracts may inherit from this and call {_registerInterface} to declare\n * their support of an interface.\n */\nabstract contract ERC165Storage is ERC165 {\n /**\n * @dev Mapping of interface ids to whether or not it's supported.\n */\n mapping(bytes4 => bool) private _supportedInterfaces;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return super.supportsInterface(interfaceId) || _supportedInterfaces[interfaceId];\n }\n\n /**\n * @dev Registers the contract as an implementer of the interface defined by\n * `interfaceId`. Support of the actual ERC165 interface is automatic and\n * registering its interface id is not required.\n *\n * See {IERC165-supportsInterface}.\n *\n * Requirements:\n *\n * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).\n */\n function _registerInterface(bytes4 interfaceId) internal virtual {\n require(interfaceId != 0xffffffff, \"ERC165: invalid interface id\");\n _supportedInterfaces[interfaceId] = true;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\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[EIP 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" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@prb/math/src/Common.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\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 works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\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^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n" + }, + "@prb/math/src/sd1x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n" + }, + "@prb/math/src/sd1x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint64 constant uUNIT = 1e18;\n" + }, + "@prb/math/src/sd1x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n" + }, + "@prb/math/src/sd1x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n" + }, + "@prb/math/src/sd59x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n" + }, + "@prb/math/src/sd59x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev Any value less than this returns 0 in {exp}.\nint256 constant uEXP_MIN_THRESHOLD = -41_446531673892822322;\nSD59x18 constant EXP_MIN_THRESHOLD = SD59x18.wrap(uEXP_MIN_THRESHOLD);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Any value less than this returns 0 in {exp2}.\nint256 constant uEXP2_MIN_THRESHOLD = -59_794705707972522261;\nSD59x18 constant EXP2_MIN_THRESHOLD = SD59x18.wrap(uEXP2_MIN_THRESHOLD);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n" + }, + "@prb/math/src/sd59x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n" + }, + "@prb/math/src/sd59x18/Helpers.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" + }, + "@prb/math/src/sd59x18/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uEXP_MIN_THRESHOLD,\n uEXP2_MIN_THRESHOLD,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // Any input less than the threshold returns zero.\n // This check also prevents an overflow for very small numbers.\n if (xInt < uEXP_MIN_THRESHOLD) {\n return ZERO;\n }\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than the threshold is truncated to zero.\n if (xInt < uEXP2_MIN_THRESHOLD) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n" + }, + "@prb/math/src/sd59x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n" + }, + "@prb/math/src/UD2x18.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗╚════██╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║ █████╔╝ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══╝ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud2x18/Casting.sol\";\nimport \"./ud2x18/Constants.sol\";\nimport \"./ud2x18/Errors.sol\";\nimport \"./ud2x18/ValueType.sol\";\n" + }, + "@prb/math/src/ud2x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n" + }, + "@prb/math/src/ud2x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\nuint64 constant uUNIT = 1e18;\n" + }, + "@prb/math/src/ud2x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n" + }, + "@prb/math/src/ud2x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n" + }, + "@prb/math/src/UD60x18.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n" + }, + "@prb/math/src/ud60x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n" + }, + "@prb/math/src/ud60x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n" + }, + "@prb/math/src/ud60x18/Conversions.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n" + }, + "@prb/math/src/ud60x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n" + }, + "@prb/math/src/ud60x18/Helpers.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" + }, + "@prb/math/src/ud60x18/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n///\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n" + }, + "@prb/math/src/ud60x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n" + }, + "contracts/DecentSablierStreamManagement.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.28;\n\nimport {Enum} from \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport {IAvatar} from \"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\";\nimport {ISablierV2Lockup} from \"./interfaces/sablier/full/ISablierV2Lockup.sol\";\nimport {Lockup} from \"./interfaces/sablier/full/types/DataTypes.sol\";\n\ncontract DecentSablierStreamManagement {\n string public constant NAME = \"DecentSablierStreamManagement\";\n\n function withdrawMaxFromStream(\n ISablierV2Lockup sablier,\n address recipientHatAccount,\n uint256 streamId,\n address to\n ) public {\n // Check if there are funds to withdraw\n uint128 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\n if (withdrawableAmount == 0) {\n return;\n }\n\n // Proxy the Sablier withdrawMax call through IAvatar (Safe)\n IAvatar(msg.sender).execTransactionFromModule(\n recipientHatAccount,\n 0,\n abi.encodeWithSignature(\n \"execute(address,uint256,bytes,uint8)\",\n address(sablier),\n 0,\n abi.encodeWithSignature(\n \"withdrawMax(uint256,address)\",\n streamId,\n to\n ),\n 0\n ),\n Enum.Operation.Call\n );\n }\n\n function cancelStream(ISablierV2Lockup sablier, uint256 streamId) public {\n // Check if the stream can be cancelled\n Lockup.Status streamStatus = sablier.statusOf(streamId);\n if (\n streamStatus != Lockup.Status.PENDING &&\n streamStatus != Lockup.Status.STREAMING\n ) {\n return;\n }\n\n IAvatar(msg.sender).execTransactionFromModule(\n address(sablier),\n 0,\n abi.encodeWithSignature(\"cancel(uint256)\", streamId),\n Enum.Operation.Call\n );\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol';\n" + }, + "contracts/interfaces/hats/IHats.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0\n// Copyright (C) 2023 Haberdasher Labs\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see .\n\npragma solidity >=0.8.13;\n\ninterface IHats {\n function mintTopHat(\n address _target,\n string memory _details,\n string memory _imageURI\n ) external returns (uint256 topHatId);\n\n function createHat(\n uint256 _admin,\n string calldata _details,\n uint32 _maxSupply,\n address _eligibility,\n address _toggle,\n bool _mutable,\n string calldata _imageURI\n ) external returns (uint256 newHatId);\n\n function mintHat(\n uint256 _hatId,\n address _wearer\n ) external returns (bool success);\n\n function transferHat(uint256 _hatId, address _from, address _to) external;\n}\n" + }, + "contracts/interfaces/IERC6551Registry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IERC6551Registry {\n /**\n * @dev Creates a token bound account for a non-fungible token.\n *\n * If account has already been created, returns the account address without calling create2.\n *\n * Emits ERC6551AccountCreated event.\n *\n * @return account The address of the token bound account\n */\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address account);\n}\n" + }, + "contracts/interfaces/sablier/full/IAdminable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\n/// @title IAdminable\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\n/// in the constructor.\ninterface IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin is transferred.\n /// @param oldAdmin The address of the old admin.\n /// @param newAdmin The address of the new admin.\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice The address of the admin account or contract.\n function admin() external view returns (address);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Transfers the contract admin to a new address.\n ///\n /// @dev Notes:\n /// - Does not revert if the admin is the same.\n /// - This function can potentially leave the contract without an admin, thereby removing any\n /// functionality that is only available to the admin.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newAdmin The address of the new admin.\n function transferAdmin(address newAdmin) external;\n}\n" + }, + "contracts/interfaces/sablier/full/IERC4096.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4906.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\n/// @title ERC-721 Metadata Update Extension\ninterface IERC4906 is IERC165, IERC721 {\n /// @dev This event emits when the metadata of a token is changed.\n /// So that the third-party platforms such as NFT market could\n /// timely update the images and related attributes of the NFT.\n event MetadataUpdate(uint256 _tokenId);\n\n /// @dev This event emits when the metadata of a range of tokens is changed.\n /// So that the third-party platforms such as NFT market could\n /// timely update the images and related attributes of the NFTs.\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n}\n" + }, + "contracts/interfaces/sablier/full/ISablierV2Lockup.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC4906} from \"./IERC4096.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IERC721Metadata} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\nimport {UD60x18} from \"@prb/math/src/UD60x18.sol\";\n\nimport {Lockup} from \"./types/DataTypes.sol\";\nimport {IAdminable} from \"./IAdminable.sol\";\nimport {ISablierV2NFTDescriptor} from \"./ISablierV2NFTDescriptor.sol\";\n\n/// @title ISablierV2Lockup\n/// @notice Common logic between all Sablier V2 Lockup contracts.\ninterface ISablierV2Lockup is\n IAdminable, // 0 inherited components\n IERC4906, // 2 inherited components\n IERC721Metadata // 2 inherited components\n{\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin allows a new recipient contract to hook to Sablier.\n /// @param admin The address of the current contract admin.\n /// @param recipient The address of the recipient contract put on the allowlist.\n event AllowToHook(address indexed admin, address recipient);\n\n /// @notice Emitted when a stream is canceled.\n /// @param streamId The ID of the stream.\n /// @param sender The address of the stream's sender.\n /// @param recipient The address of the stream's recipient.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\n /// decimals.\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\n /// asset's decimals.\n event CancelLockupStream(\n uint256 streamId,\n address indexed sender,\n address indexed recipient,\n IERC20 indexed asset,\n uint128 senderAmount,\n uint128 recipientAmount\n );\n\n /// @notice Emitted when a sender gives up the right to cancel a stream.\n /// @param streamId The ID of the stream.\n event RenounceLockupStream(uint256 indexed streamId);\n\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\n /// @param admin The address of the current contract admin.\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n event SetNFTDescriptor(\n address indexed admin,\n ISablierV2NFTDescriptor oldNFTDescriptor,\n ISablierV2NFTDescriptor newNFTDescriptor\n );\n\n /// @notice Emitted when assets are withdrawn from a stream.\n /// @param streamId The ID of the stream.\n /// @param to The address that has received the withdrawn assets.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\n event WithdrawFromLockupStream(\n uint256 indexed streamId,\n address indexed to,\n IERC20 indexed asset,\n uint128 amount\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the address of the ERC-20 asset to be distributed.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\n\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getDepositedAmount(\n uint256 streamId\n ) external view returns (uint128 depositedAmount);\n\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getEndTime(\n uint256 streamId\n ) external view returns (uint40 endTime);\n\n /// @notice Retrieves the stream's recipient.\n /// @dev Reverts if the NFT has been burned.\n /// @param streamId The stream ID for the query.\n function getRecipient(\n uint256 streamId\n ) external view returns (address recipient);\n\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\n /// decimals. This amount is always zero unless the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getRefundedAmount(\n uint256 streamId\n ) external view returns (uint128 refundedAmount);\n\n /// @notice Retrieves the stream's sender.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getSender(uint256 streamId) external view returns (address sender);\n\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getStartTime(\n uint256 streamId\n ) external view returns (uint40 startTime);\n\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getWithdrawnAmount(\n uint256 streamId\n ) external view returns (uint128 withdrawnAmount);\n\n /// @notice Retrieves a flag indicating whether the provided address is a contract allowed to hook to Sablier\n /// when a stream is canceled or when assets are withdrawn.\n /// @dev See {ISablierLockupRecipient} for more information.\n function isAllowedToHook(\n address recipient\n ) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\n /// flag is always `false`.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isCancelable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isCold(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isDepleted(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream exists.\n /// @dev Does not revert if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isStream(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isTransferable(\n uint256 streamId\n ) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isWarm(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves the maximum broker fee that can be charged by the broker, denoted as a fixed-point\n /// number where 1e18 is 100%.\n /// @dev This value is hard coded as a constant.\n function MAX_BROKER_FEE() external view returns (UD60x18);\n\n /// @notice Counter for stream IDs, used in the create functions.\n function nextStreamId() external view returns (uint256);\n\n /// @notice Contract that generates the non-fungible token URI.\n function nftDescriptor() external view returns (ISablierV2NFTDescriptor);\n\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\n /// of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function refundableAmountOf(\n uint256 streamId\n ) external view returns (uint128 refundableAmount);\n\n /// @notice Retrieves the stream's status.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function statusOf(\n uint256 streamId\n ) external view returns (Lockup.Status status);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n ///\n /// Notes:\n /// - Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\n /// to the total amount withdrawn.\n ///\n /// @param streamId The stream ID for the query.\n function streamedAmountOf(\n uint256 streamId\n ) external view returns (uint128 streamedAmount);\n\n /// @notice Retrieves a flag indicating whether the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function wasCanceled(uint256 streamId) external view returns (bool result);\n\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\n /// decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function withdrawableAmountOf(\n uint256 streamId\n ) external view returns (uint128 withdrawableAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Allows a recipient contract to hook to Sablier when a stream is canceled or when assets are withdrawn.\n /// Useful for implementing contracts that hold streams on behalf of users, such as vaults or staking contracts.\n ///\n /// @dev Emits an {AllowToHook} event.\n ///\n /// Notes:\n /// - Does not revert if the contract is already on the allowlist.\n /// - This is an irreversible operation. The contract cannot be removed from the allowlist.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n /// - `recipient` must have a non-zero code size.\n /// - `recipient` must implement {ISablierLockupRecipient}.\n ///\n /// @param recipient The address of the contract to allow for hooks.\n function allowToHook(address recipient) external;\n\n /// @notice Burns the NFT associated with the stream.\n ///\n /// @dev Emits a {Transfer} event.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a depleted stream.\n /// - The NFT must exist.\n /// - `msg.sender` must be either the NFT owner or an approved third party.\n ///\n /// @param streamId The ID of the stream NFT to burn.\n function burn(uint256 streamId) external;\n\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\n ///\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\n /// stream is marked as depleted.\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - The stream must be warm and cancelable.\n /// - `msg.sender` must be the stream's sender.\n ///\n /// @param streamId The ID of the stream to cancel.\n function cancel(uint256 streamId) external;\n\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\n ///\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - Refer to the notes in {cancel}.\n ///\n /// Requirements:\n /// - All requirements from {cancel} must be met for each stream.\n ///\n /// @param streamIds The IDs of the streams to cancel.\n function cancelMultiple(uint256[] calldata streamIds) external;\n\n /// @notice Removes the right of the stream's sender to cancel the stream.\n ///\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This is an irreversible operation.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a warm stream.\n /// - `msg.sender` must be the stream's sender.\n /// - The stream must be cancelable.\n ///\n /// @param streamId The ID of the stream to renounce.\n function renounce(uint256 streamId) external;\n\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\n ///\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\n ///\n /// Notes:\n /// - Does not revert if the NFT descriptor is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n function setNFTDescriptor(\n ISablierV2NFTDescriptor newNFTDescriptor\n ) external;\n\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of the stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must not reference a null or depleted stream.\n /// - `to` must not be the zero address.\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\n /// - `to` must be the recipient if `msg.sender` is not the stream's recipient or an approved third party.\n ///\n /// @param streamId The ID of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\n function withdraw(uint256 streamId, address to, uint128 amount) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - Refer to the requirements in {withdraw}.\n ///\n /// @param streamId The ID of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\n function withdrawMax(\n uint256 streamId,\n address to\n ) external returns (uint128 withdrawnAmount);\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\n /// NFT to `newRecipient`.\n ///\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\n ///\n /// Notes:\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - `msg.sender` must be the stream's recipient.\n /// - Refer to the requirements in {withdraw}.\n /// - Refer to the requirements in {IERC721.transferFrom}.\n ///\n /// @param streamId The ID of the stream NFT to transfer.\n /// @param newRecipient The address of the new owner of the stream NFT.\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\n function withdrawMaxAndTransfer(\n uint256 streamId,\n address newRecipient\n ) external returns (uint128 withdrawnAmount);\n\n /// @notice Withdraws assets from streams to the recipient of each stream.\n ///\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - There must be an equal number of `streamIds` and `amounts`.\n /// - Each stream ID in the array must not reference a null or depleted stream.\n /// - Each amount in the array must be greater than zero and must not exceed the withdrawable amount.\n ///\n /// @param streamIds The IDs of the streams to withdraw from.\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\n function withdrawMultiple(\n uint256[] calldata streamIds,\n uint128[] calldata amounts\n ) external;\n}\n" + }, + "contracts/interfaces/sablier/full/ISablierV2NFTDescriptor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC721Metadata} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\n/// @title ISablierV2NFTDescriptor\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\n/// @dev Inspired by Uniswap V3 Positions NFTs.\ninterface ISablierV2NFTDescriptor {\n /// @notice Produces the URI describing a particular stream NFT.\n /// @dev This is a data URI with the JSON contents directly inlined.\n /// @param sablier The address of the Sablier contract the stream was created in.\n /// @param streamId The ID of the stream for which to produce a description.\n /// @return uri The URI of the ERC721-compliant metadata.\n function tokenURI(\n IERC721Metadata sablier,\n uint256 streamId\n ) external view returns (string memory uri);\n}\n" + }, + "contracts/interfaces/sablier/full/types/DataTypes.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {UD2x18} from \"@prb/math/src/UD2x18.sol\";\nimport {UD60x18} from \"@prb/math/src/UD60x18.sol\";\n\n// DataTypes.sol\n//\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\n//\n// - Lockup\n// - LockupDynamic\n// - LockupLinear\n// - LockupTranched\n//\n// You will notice that some structs contain \"slot\" annotations - they are used to indicate the\n// storage layout of the struct. It is more gas efficient to group small data types together so\n// that they fit in a single 32-byte slot.\n\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\n/// @param account The address receiving the broker's fee.\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\nstruct Broker {\n address account;\n UD60x18 fee;\n}\n\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\nlibrary Lockup {\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the asset's\n /// decimals.\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in the same slot\n /// saves gas.\n /// @param deposited The initial amount deposited in the stream, net of broker fee.\n /// @param withdrawn The cumulative amount withdrawn from the stream.\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\n struct Amounts {\n // slot 0\n uint128 deposited;\n uint128 withdrawn;\n // slot 1\n uint128 refunded;\n }\n\n /// @notice Struct encapsulating (i) the deposit amount and (ii) the broker fee amount, both denoted in units of the\n /// asset's decimals.\n /// @param deposit The amount to deposit in the stream.\n /// @param brokerFee The broker fee amount.\n struct CreateAmounts {\n uint128 deposit;\n uint128 brokerFee;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING,\n STREAMING,\n SETTLED,\n CANCELED,\n DEPLETED\n }\n\n /// @notice A common data structure to be stored in all {SablierV2Lockup} models.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address distributing the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\nlibrary LockupDynamic {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param segments Segments with durations used to compose the dynamic distribution function. Timestamps are\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n SegmentWithDuration[] segments;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param segments Segments used to compose the dynamic distribution function.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n uint40 startTime;\n Segment[] segments;\n Broker broker;\n }\n\n /// @notice Segment struct used in the Lockup Dynamic stream.\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\n /// @param timestamp The Unix timestamp indicating the segment's end.\n struct Segment {\n // slot 0\n uint128 amount;\n UD2x18 exponent;\n uint40 timestamp;\n }\n\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDurations}.\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\n /// @param duration The time difference in seconds between the segment and the previous one.\n struct SegmentWithDuration {\n uint128 amount;\n UD2x18 exponent;\n uint40 duration;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the segments.\n struct StreamLD {\n address sender;\n address recipient;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n Segment[] segments;\n }\n\n /// @notice Struct encapsulating the LockupDynamic timestamps.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 end;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\nlibrary LockupLinear {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param durations Struct encapsulating (i) cliff period duration and (ii) total stream duration, both in seconds.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Durations durations;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param timestamps Struct encapsulating (i) the stream's start time, (ii) cliff time, and (iii) end time, all as\n /// Unix timestamps.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the cliff duration and the total duration.\n /// @param cliff The cliff duration in seconds.\n /// @param total The total duration in seconds.\n struct Durations {\n uint40 cliff;\n uint40 total;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the cliff time.\n struct StreamLL {\n address sender;\n address recipient;\n uint40 startTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n uint40 endTime;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n uint40 cliffTime;\n }\n\n /// @notice Struct encapsulating the LockupLinear timestamps.\n /// @param start The Unix timestamp for the stream's start.\n /// @param cliff The Unix timestamp for the cliff period's end. A value of zero means there is no cliff.\n /// @param end The Unix timestamp for the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupTranched}.\nlibrary LockupTranched {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param tranches Tranches with durations used to compose the tranched distribution function. Timestamps are\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n TrancheWithDuration[] tranches;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param tranches Tranches used to compose the tranched distribution function.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n uint40 startTime;\n Tranche[] tranches;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the tranches.\n struct StreamLT {\n address sender;\n address recipient;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n Tranche[] tranches;\n }\n\n /// @notice Struct encapsulating the LockupTranched timestamps.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 end;\n }\n\n /// @notice Tranche struct used in the Lockup Tranched stream.\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\n /// @param timestamp The Unix timestamp indicating the tranche's end.\n struct Tranche {\n // slot 0\n uint128 amount;\n uint40 timestamp;\n }\n\n /// @notice Tranche struct used at runtime in {SablierV2LockupTranched.createWithDurations}.\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\n /// @param duration The time difference in seconds between the tranche and the previous one.\n struct TrancheWithDuration {\n uint128 amount;\n uint40 duration;\n }\n}\n" + }, + "contracts/interfaces/sablier/ISablierV2LockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {LockupLinear} from \"./LockupLinear.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface ISablierV2LockupLinear {\n function createWithTimestamps(\n LockupLinear.CreateWithTimestamps calldata params\n ) external returns (uint256 streamId);\n}\n" + }, + "contracts/interfaces/sablier/LockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nlibrary LockupLinear {\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n struct Broker {\n address account;\n uint256 fee;\n }\n}\n" + }, + "contracts/mocks/ERC6551Registry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IERC6551Registry {\n /**\n * @dev The registry MUST emit the ERC6551AccountCreated event upon successful account creation.\n */\n event ERC6551AccountCreated(\n address account,\n address indexed implementation,\n bytes32 salt,\n uint256 chainId,\n address indexed tokenContract,\n uint256 indexed tokenId\n );\n\n /**\n * @dev The registry MUST revert with AccountCreationFailed error if the create2 operation fails.\n */\n error AccountCreationFailed();\n\n /**\n * @dev Creates a token bound account for a non-fungible token.\n *\n * If account has already been created, returns the account address without calling create2.\n *\n * Emits ERC6551AccountCreated event.\n *\n * @return account The address of the token bound account\n */\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address account);\n\n /**\n * @dev Returns the computed token bound account address for a non-fungible token.\n *\n * @return account The address of the token bound account\n */\n function account(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external view returns (address account);\n}\n\ncontract ERC6551Registry is IERC6551Registry {\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address) {\n assembly {\n // Memory Layout:\n // ----\n // 0x00 0xff (1 byte)\n // 0x01 registry (address) (20 bytes)\n // 0x15 salt (bytes32) (32 bytes)\n // 0x35 Bytecode Hash (bytes32) (32 bytes)\n // ----\n // 0x55 ERC-1167 Constructor + Header (20 bytes)\n // 0x69 implementation (address) (20 bytes)\n // 0x5D ERC-1167 Footer (15 bytes)\n // 0x8C salt (uint256) (32 bytes)\n // 0xAC chainId (uint256) (32 bytes)\n // 0xCC tokenContract (address) (32 bytes)\n // 0xEC tokenId (uint256) (32 bytes)\n\n // Silence unused variable warnings\n pop(chainId)\n\n // Copy bytecode + constant data to memory\n calldatacopy(0x8c, 0x24, 0x80) // salt, chainId, tokenContract, tokenId\n mstore(0x6c, 0x5af43d82803e903d91602b57fd5bf3) // ERC-1167 footer\n mstore(0x5d, implementation) // implementation\n mstore(0x49, 0x3d60ad80600a3d3981f3363d3d373d3d3d363d73) // ERC-1167 constructor + header\n\n // Copy create2 computation data to memory\n mstore8(0x00, 0xff) // 0xFF\n mstore(0x35, keccak256(0x55, 0xb7)) // keccak256(bytecode)\n mstore(0x01, shl(96, address())) // registry address\n mstore(0x15, salt) // salt\n\n // Compute account address\n let computed := keccak256(0x00, 0x55)\n\n // If the account has not yet been deployed\n if iszero(extcodesize(computed)) {\n // Deploy account contract\n let deployed := create2(0, 0x55, 0xb7, salt)\n\n // Revert if the deployment fails\n if iszero(deployed) {\n mstore(0x00, 0x20188a59) // `AccountCreationFailed()`\n revert(0x1c, 0x04)\n }\n\n // Store account address in memory before salt and chainId\n mstore(0x6c, deployed)\n\n // Emit the ERC6551AccountCreated event\n log4(\n 0x6c,\n 0x60,\n // `ERC6551AccountCreated(address,address,bytes32,uint256,address,uint256)`\n 0x79f19b3655ee38b1ce526556b7731a20c8f218fbda4a3990b6cc4172fdf88722,\n implementation,\n tokenContract,\n tokenId\n )\n\n // Return the account address\n return(0x6c, 0x20)\n }\n\n // Otherwise, return the computed account address\n mstore(0x00, shr(96, shl(96, computed)))\n return(0x00, 0x20)\n }\n }\n\n function account(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external view returns (address) {\n assembly {\n // Silence unused variable warnings\n pop(chainId)\n pop(tokenContract)\n pop(tokenId)\n\n // Copy bytecode + constant data to memory\n calldatacopy(0x8c, 0x24, 0x80) // salt, chainId, tokenContract, tokenId\n mstore(0x6c, 0x5af43d82803e903d91602b57fd5bf3) // ERC-1167 footer\n mstore(0x5d, implementation) // implementation\n mstore(0x49, 0x3d60ad80600a3d3981f3363d3d373d3d3d363d73) // ERC-1167 constructor + header\n\n // Copy create2 computation data to memory\n mstore8(0x00, 0xff) // 0xFF\n mstore(0x35, keccak256(0x55, 0xb7)) // keccak256(bytecode)\n mstore(0x01, shl(96, address())) // registry address\n mstore(0x15, salt) // salt\n\n // Store computed account address in memory\n mstore(0x00, shr(96, shl(96, keccak256(0x00, 0x55))))\n\n // Return computed account address\n return(0x00, 0x20)\n }\n }\n}\n" + }, + "contracts/mocks/MockContract.sol": { + "content": "//SPDX-License-Identifier: Unlicense\n\npragma solidity ^0.8.19;\n\n/**\n * Mock contract for testing\n */\ncontract MockContract {\n event DidSomething(string message);\n\n error Reverting();\n\n function doSomething() public {\n doSomethingWithParam(\"doSomething()\");\n }\n\n function doSomethingWithParam(string memory _message) public {\n emit DidSomething(_message);\n }\n\n function returnSomething(string memory _s)\n external\n pure\n returns (string memory)\n {\n return _s;\n }\n\n function revertSomething() external pure {\n revert Reverting();\n }\n}\n" + }, + "contracts/mocks/MockLockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nlibrary MockLockupLinear {\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n struct Broker {\n address account;\n uint256 fee;\n }\n\n struct Stream {\n address sender;\n uint40 startTime;\n uint40 endTime;\n uint40 cliffTime;\n bool cancelable;\n bool wasCanceled;\n address asset;\n bool transferable;\n uint128 totalAmount;\n address recipient;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING,\n STREAMING,\n SETTLED,\n CANCELED,\n DEPLETED\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/polygon/DecentSablierStreamManagement.json b/deployments/polygon/DecentSablierStreamManagement.json new file mode 100644 index 00000000..795367d5 --- /dev/null +++ b/deployments/polygon/DecentSablierStreamManagement.json @@ -0,0 +1,116 @@ +{ + "address": "0xcd6c149b3C0FE7284005869fa15080e85887c8F1", + "abi": [ + { + "inputs": [], + "name": "NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ISablierV2Lockup", + "name": "sablier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + } + ], + "name": "cancelStream", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ISablierV2Lockup", + "name": "sablier", + "type": "address" + }, + { + "internalType": "address", + "name": "recipientHatAccount", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "withdrawMaxFromStream", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x79bc48a59de268be4623c5a7a2e419da30b95b8bb7119f60e59f097c5aa30dba", + "receipt": { + "to": null, + "from": "0xb5Ca125166C1987A35EDD550E16846Fa1e1D9bB3", + "contractAddress": "0xcd6c149b3C0FE7284005869fa15080e85887c8F1", + "transactionIndex": 26, + "gasUsed": "384441", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000008000000000000000800000000000000000000100000000000000000000000000000000000000000000000000000800100080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000100000000000004000000000000000000001000000000000000000000000000000100004000000000000000000200000000000000000000000000000000000000000000000100000", + "blockHash": "0x2ba2274d8334e11975c51b3ec0bb574f93ac83042f9fd1863b28b6e183999f9d", + "transactionHash": "0x79bc48a59de268be4623c5a7a2e419da30b95b8bb7119f60e59f097c5aa30dba", + "logs": [ + { + "transactionIndex": 26, + "blockNumber": 62872232, + "transactionHash": "0x79bc48a59de268be4623c5a7a2e419da30b95b8bb7119f60e59f097c5aa30dba", + "address": "0x0000000000000000000000000000000000001010", + "topics": [ + "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", + "0x0000000000000000000000000000000000000000000000000000000000001010", + "0x000000000000000000000000b5ca125166c1987a35edd550e16846fa1e1d9bb3", + "0x00000000000000000000000083d69448f88bf9c701c1b93f43e1f753d39b2632" + ], + "data": "0x0000000000000000000000000000000000000000000000000032e47e5c4a2ad2000000000000000000000000000000000000000000000000344315f1bf0ff3a9000000000000000000000000000000000000000000000ba51a4e83ca9587c9510000000000000000000000000000000000000000000000003410317362c5c8d7000000000000000000000000000000000000000000000ba51a816848f1d1f423", + "logIndex": 91, + "blockHash": "0x2ba2274d8334e11975c51b3ec0bb574f93ac83042f9fd1863b28b6e183999f9d" + } + ], + "blockNumber": 62872232, + "cumulativeGasUsed": "3140534", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4511b61209438ca20d2458493e70bb24", + "metadata": "{\"compiler\":{\"version\":\"0.8.28+commit.7893614a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"NAME\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISablierV2Lockup\",\"name\":\"sablier\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"streamId\",\"type\":\"uint256\"}],\"name\":\"cancelStream\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISablierV2Lockup\",\"name\":\"sablier\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipientHatAccount\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"streamId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"withdrawMaxFromStream\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/DecentSablierStreamManagement.sol\":\"DecentSablierStreamManagement\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only\\npragma solidity >=0.7.0 <0.9.0;\\n\\n/// @title Enum - Collection of enums\\n/// @author Richard Meissner - \\ncontract Enum {\\n enum Operation {Call, DelegateCall}\\n}\\n\",\"keccak256\":\"0x473e45b1a5cc47be494b0e123c9127f0c11c1e0992a321ae5a644c0bfdb2c14f\",\"license\":\"LGPL-3.0-only\"},\"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only\\n\\n/// @title Zodiac Avatar - A contract that manages modules that can execute transactions via this contract.\\npragma solidity >=0.7.0 <0.9.0;\\n\\nimport \\\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\\\";\\n\\ninterface IAvatar {\\n event EnabledModule(address module);\\n event DisabledModule(address module);\\n event ExecutionFromModuleSuccess(address indexed module);\\n event ExecutionFromModuleFailure(address indexed module);\\n\\n /// @dev Enables a module on the avatar.\\n /// @notice Can only be called by the avatar.\\n /// @notice Modules should be stored as a linked list.\\n /// @notice Must emit EnabledModule(address module) if successful.\\n /// @param module Module to be enabled.\\n function enableModule(address module) external;\\n\\n /// @dev Disables a module on the avatar.\\n /// @notice Can only be called by the avatar.\\n /// @notice Must emit DisabledModule(address module) if successful.\\n /// @param prevModule Address that pointed to the module to be removed in the linked list\\n /// @param module Module to be removed.\\n function disableModule(address prevModule, address module) external;\\n\\n /// @dev Allows a Module to execute a transaction.\\n /// @notice Can only be called by an enabled module.\\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\\n function execTransactionFromModule(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation\\n ) external returns (bool success);\\n\\n /// @dev Allows a Module to execute a transaction and return data\\n /// @notice Can only be called by an enabled module.\\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\\n function execTransactionFromModuleReturnData(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation\\n ) external returns (bool success, bytes memory returnData);\\n\\n /// @dev Returns if an module is enabled\\n /// @return True if the module is enabled\\n function isModuleEnabled(address module) external view returns (bool);\\n\\n /// @dev Returns array of modules.\\n /// @param start Start of the page.\\n /// @param pageSize Maximum number of modules that should be returned.\\n /// @return array Array of modules.\\n /// @return next Start of the next page.\\n function getModulesPaginated(address start, uint256 pageSize)\\n external\\n view\\n returns (address[] memory array, address next);\\n}\\n\",\"keccak256\":\"0xcd5508ffe596eef8fbccfd5fc4f10a34397773547ce64e212d48b5212865ec1f\",\"license\":\"LGPL-3.0-only\"},\"@openzeppelin/contracts/interfaces/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/introspection/IERC165.sol\\\";\\n\",\"keccak256\":\"0xd04b0f06e0666f29cf7cccc82894de541e19bb30a765b107b1e40bb7fe5f7d7a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xed6a749c5373af398105ce6ee3ac4763aa450ea7285d268c85d9eeca809cdb1f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Metadata is IERC721 {\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x75b829ff2f26c14355d1cba20e16fe7b29ca58eb5fef665ede48bc0f9c6c74b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\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[EIP 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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@prb/math/src/Common.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n// Common.sol\\n//\\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\\n// always operate with SD59x18 and UD60x18 numbers.\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CUSTOM ERRORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\\n\\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\\n\\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\\nerror PRBMath_MulDivSigned_InputTooSmall();\\n\\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CONSTANTS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @dev The maximum value a uint128 number can have.\\nuint128 constant MAX_UINT128 = type(uint128).max;\\n\\n/// @dev The maximum value a uint40 number can have.\\nuint40 constant MAX_UINT40 = type(uint40).max;\\n\\n/// @dev The unit number, which the decimal precision of the fixed-point types.\\nuint256 constant UNIT = 1e18;\\n\\n/// @dev The unit number inverted mod 2^256.\\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\\n\\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\\n/// bit in the binary representation of `UNIT`.\\nuint256 constant UNIT_LPOTD = 262144;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method.\\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(uint256 x) pure returns (uint256 result) {\\n unchecked {\\n // Start from 0.5 in the 192.64-bit fixed-point format.\\n result = 0x800000000000000000000000000000000000000000000000;\\n\\n // The following logic multiplies the result by $\\\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\\n //\\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\\n // we know that `x & 0xFF` is also 1.\\n if (x & 0xFF00000000000000 > 0) {\\n if (x & 0x8000000000000000 > 0) {\\n result = (result * 0x16A09E667F3BCC909) >> 64;\\n }\\n if (x & 0x4000000000000000 > 0) {\\n result = (result * 0x1306FE0A31B7152DF) >> 64;\\n }\\n if (x & 0x2000000000000000 > 0) {\\n result = (result * 0x1172B83C7D517ADCE) >> 64;\\n }\\n if (x & 0x1000000000000000 > 0) {\\n result = (result * 0x10B5586CF9890F62A) >> 64;\\n }\\n if (x & 0x800000000000000 > 0) {\\n result = (result * 0x1059B0D31585743AE) >> 64;\\n }\\n if (x & 0x400000000000000 > 0) {\\n result = (result * 0x102C9A3E778060EE7) >> 64;\\n }\\n if (x & 0x200000000000000 > 0) {\\n result = (result * 0x10163DA9FB33356D8) >> 64;\\n }\\n if (x & 0x100000000000000 > 0) {\\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\\n }\\n }\\n\\n if (x & 0xFF000000000000 > 0) {\\n if (x & 0x80000000000000 > 0) {\\n result = (result * 0x10058C86DA1C09EA2) >> 64;\\n }\\n if (x & 0x40000000000000 > 0) {\\n result = (result * 0x1002C605E2E8CEC50) >> 64;\\n }\\n if (x & 0x20000000000000 > 0) {\\n result = (result * 0x100162F3904051FA1) >> 64;\\n }\\n if (x & 0x10000000000000 > 0) {\\n result = (result * 0x1000B175EFFDC76BA) >> 64;\\n }\\n if (x & 0x8000000000000 > 0) {\\n result = (result * 0x100058BA01FB9F96D) >> 64;\\n }\\n if (x & 0x4000000000000 > 0) {\\n result = (result * 0x10002C5CC37DA9492) >> 64;\\n }\\n if (x & 0x2000000000000 > 0) {\\n result = (result * 0x1000162E525EE0547) >> 64;\\n }\\n if (x & 0x1000000000000 > 0) {\\n result = (result * 0x10000B17255775C04) >> 64;\\n }\\n }\\n\\n if (x & 0xFF0000000000 > 0) {\\n if (x & 0x800000000000 > 0) {\\n result = (result * 0x1000058B91B5BC9AE) >> 64;\\n }\\n if (x & 0x400000000000 > 0) {\\n result = (result * 0x100002C5C89D5EC6D) >> 64;\\n }\\n if (x & 0x200000000000 > 0) {\\n result = (result * 0x10000162E43F4F831) >> 64;\\n }\\n if (x & 0x100000000000 > 0) {\\n result = (result * 0x100000B1721BCFC9A) >> 64;\\n }\\n if (x & 0x80000000000 > 0) {\\n result = (result * 0x10000058B90CF1E6E) >> 64;\\n }\\n if (x & 0x40000000000 > 0) {\\n result = (result * 0x1000002C5C863B73F) >> 64;\\n }\\n if (x & 0x20000000000 > 0) {\\n result = (result * 0x100000162E430E5A2) >> 64;\\n }\\n if (x & 0x10000000000 > 0) {\\n result = (result * 0x1000000B172183551) >> 64;\\n }\\n }\\n\\n if (x & 0xFF00000000 > 0) {\\n if (x & 0x8000000000 > 0) {\\n result = (result * 0x100000058B90C0B49) >> 64;\\n }\\n if (x & 0x4000000000 > 0) {\\n result = (result * 0x10000002C5C8601CC) >> 64;\\n }\\n if (x & 0x2000000000 > 0) {\\n result = (result * 0x1000000162E42FFF0) >> 64;\\n }\\n if (x & 0x1000000000 > 0) {\\n result = (result * 0x10000000B17217FBB) >> 64;\\n }\\n if (x & 0x800000000 > 0) {\\n result = (result * 0x1000000058B90BFCE) >> 64;\\n }\\n if (x & 0x400000000 > 0) {\\n result = (result * 0x100000002C5C85FE3) >> 64;\\n }\\n if (x & 0x200000000 > 0) {\\n result = (result * 0x10000000162E42FF1) >> 64;\\n }\\n if (x & 0x100000000 > 0) {\\n result = (result * 0x100000000B17217F8) >> 64;\\n }\\n }\\n\\n if (x & 0xFF000000 > 0) {\\n if (x & 0x80000000 > 0) {\\n result = (result * 0x10000000058B90BFC) >> 64;\\n }\\n if (x & 0x40000000 > 0) {\\n result = (result * 0x1000000002C5C85FE) >> 64;\\n }\\n if (x & 0x20000000 > 0) {\\n result = (result * 0x100000000162E42FF) >> 64;\\n }\\n if (x & 0x10000000 > 0) {\\n result = (result * 0x1000000000B17217F) >> 64;\\n }\\n if (x & 0x8000000 > 0) {\\n result = (result * 0x100000000058B90C0) >> 64;\\n }\\n if (x & 0x4000000 > 0) {\\n result = (result * 0x10000000002C5C860) >> 64;\\n }\\n if (x & 0x2000000 > 0) {\\n result = (result * 0x1000000000162E430) >> 64;\\n }\\n if (x & 0x1000000 > 0) {\\n result = (result * 0x10000000000B17218) >> 64;\\n }\\n }\\n\\n if (x & 0xFF0000 > 0) {\\n if (x & 0x800000 > 0) {\\n result = (result * 0x1000000000058B90C) >> 64;\\n }\\n if (x & 0x400000 > 0) {\\n result = (result * 0x100000000002C5C86) >> 64;\\n }\\n if (x & 0x200000 > 0) {\\n result = (result * 0x10000000000162E43) >> 64;\\n }\\n if (x & 0x100000 > 0) {\\n result = (result * 0x100000000000B1721) >> 64;\\n }\\n if (x & 0x80000 > 0) {\\n result = (result * 0x10000000000058B91) >> 64;\\n }\\n if (x & 0x40000 > 0) {\\n result = (result * 0x1000000000002C5C8) >> 64;\\n }\\n if (x & 0x20000 > 0) {\\n result = (result * 0x100000000000162E4) >> 64;\\n }\\n if (x & 0x10000 > 0) {\\n result = (result * 0x1000000000000B172) >> 64;\\n }\\n }\\n\\n if (x & 0xFF00 > 0) {\\n if (x & 0x8000 > 0) {\\n result = (result * 0x100000000000058B9) >> 64;\\n }\\n if (x & 0x4000 > 0) {\\n result = (result * 0x10000000000002C5D) >> 64;\\n }\\n if (x & 0x2000 > 0) {\\n result = (result * 0x1000000000000162E) >> 64;\\n }\\n if (x & 0x1000 > 0) {\\n result = (result * 0x10000000000000B17) >> 64;\\n }\\n if (x & 0x800 > 0) {\\n result = (result * 0x1000000000000058C) >> 64;\\n }\\n if (x & 0x400 > 0) {\\n result = (result * 0x100000000000002C6) >> 64;\\n }\\n if (x & 0x200 > 0) {\\n result = (result * 0x10000000000000163) >> 64;\\n }\\n if (x & 0x100 > 0) {\\n result = (result * 0x100000000000000B1) >> 64;\\n }\\n }\\n\\n if (x & 0xFF > 0) {\\n if (x & 0x80 > 0) {\\n result = (result * 0x10000000000000059) >> 64;\\n }\\n if (x & 0x40 > 0) {\\n result = (result * 0x1000000000000002C) >> 64;\\n }\\n if (x & 0x20 > 0) {\\n result = (result * 0x10000000000000016) >> 64;\\n }\\n if (x & 0x10 > 0) {\\n result = (result * 0x1000000000000000B) >> 64;\\n }\\n if (x & 0x8 > 0) {\\n result = (result * 0x10000000000000006) >> 64;\\n }\\n if (x & 0x4 > 0) {\\n result = (result * 0x10000000000000003) >> 64;\\n }\\n if (x & 0x2 > 0) {\\n result = (result * 0x10000000000000001) >> 64;\\n }\\n if (x & 0x1 > 0) {\\n result = (result * 0x10000000000000001) >> 64;\\n }\\n }\\n\\n // In the code snippet below, two operations are executed simultaneously:\\n //\\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\\n //\\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\\n // integer part, $2^n$.\\n result *= UNIT;\\n result >>= (191 - (x >> 64));\\n }\\n}\\n\\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\\n///\\n/// @dev See the note on \\\"msb\\\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\\n///\\n/// Each step in this implementation is equivalent to this high-level code:\\n///\\n/// ```solidity\\n/// if (x >= 2 ** 128) {\\n/// x >>= 128;\\n/// result += 128;\\n/// }\\n/// ```\\n///\\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\\n///\\n/// The Yul instructions used below are:\\n///\\n/// - \\\"gt\\\" is \\\"greater than\\\"\\n/// - \\\"or\\\" is the OR bitwise operator\\n/// - \\\"shl\\\" is \\\"shift left\\\"\\n/// - \\\"shr\\\" is \\\"shift right\\\"\\n///\\n/// @param x The uint256 number for which to find the index of the most significant bit.\\n/// @return result The index of the most significant bit as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction msb(uint256 x) pure returns (uint256 result) {\\n // 2^128\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^64\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^32\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(5, gt(x, 0xFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^16\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(4, gt(x, 0xFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^8\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(3, gt(x, 0xFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^4\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(2, gt(x, 0xF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^2\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(1, gt(x, 0x3))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^1\\n // No need to shift x any more.\\n assembly (\\\"memory-safe\\\") {\\n let factor := gt(x, 0x1)\\n result := or(result, factor)\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f7denominator with 512-bit precision.\\n///\\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - The denominator must not be zero.\\n/// - The result must fit in uint256.\\n///\\n/// @param x The multiplicand as a uint256.\\n/// @param y The multiplier as a uint256.\\n/// @param denominator The divisor as a uint256.\\n/// @return result The result as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly (\\\"memory-safe\\\") {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n unchecked {\\n return prod0 / denominator;\\n }\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n if (prod1 >= denominator) {\\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\\n }\\n\\n ////////////////////////////////////////////////////////////////////////////\\n // 512 by 256 division\\n ////////////////////////////////////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly (\\\"memory-safe\\\") {\\n // Compute remainder using the mulmod Yul instruction.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512-bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n unchecked {\\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\\n uint256 lpotdod = denominator & (~denominator + 1);\\n uint256 flippedLpotdod;\\n\\n assembly (\\\"memory-safe\\\") {\\n // Factor powers of two out of denominator.\\n denominator := div(denominator, lpotdod)\\n\\n // Divide [prod1 prod0] by lpotdod.\\n prod0 := div(prod0, lpotdod)\\n\\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * flippedLpotdod;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\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 works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\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^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f71e18 with 512-bit precision.\\n///\\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\\n///\\n/// Notes:\\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\\n/// - The result is rounded toward zero.\\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\\n///\\n/// $$\\n/// \\\\begin{cases}\\n/// x * y = MAX\\\\_UINT256 * UNIT \\\\\\\\\\n/// (x * y) \\\\% UNIT \\\\geq \\\\frac{UNIT}{2}\\n/// \\\\end{cases}\\n/// $$\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {mulDiv}.\\n/// - The result must fit in uint256.\\n///\\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\\n uint256 prod0;\\n uint256 prod1;\\n assembly (\\\"memory-safe\\\") {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n if (prod1 == 0) {\\n unchecked {\\n return prod0 / UNIT;\\n }\\n }\\n\\n if (prod1 >= UNIT) {\\n revert PRBMath_MulDiv18_Overflow(x, y);\\n }\\n\\n uint256 remainder;\\n assembly (\\\"memory-safe\\\") {\\n remainder := mulmod(x, y, UNIT)\\n result :=\\n mul(\\n or(\\n div(sub(prod0, remainder), UNIT_LPOTD),\\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\\n ),\\n UNIT_INVERSE\\n )\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f7denominator with 512-bit precision.\\n///\\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {mulDiv}.\\n/// - None of the inputs can be `type(int256).min`.\\n/// - The result must fit in int256.\\n///\\n/// @param x The multiplicand as an int256.\\n/// @param y The multiplier as an int256.\\n/// @param denominator The divisor as an int256.\\n/// @return result The result as an int256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\\n revert PRBMath_MulDivSigned_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x, y and the denominator.\\n uint256 xAbs;\\n uint256 yAbs;\\n uint256 dAbs;\\n unchecked {\\n xAbs = x < 0 ? uint256(-x) : uint256(x);\\n yAbs = y < 0 ? uint256(-y) : uint256(y);\\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\\n }\\n\\n // Compute the absolute value of x*y\\u00f7denominator. The result must fit in int256.\\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\\n if (resultAbs > uint256(type(int256).max)) {\\n revert PRBMath_MulDivSigned_Overflow(x, y);\\n }\\n\\n // Get the signs of x, y and the denominator.\\n uint256 sx;\\n uint256 sy;\\n uint256 sd;\\n assembly (\\\"memory-safe\\\") {\\n // \\\"sgt\\\" is the \\\"signed greater than\\\" assembly instruction and \\\"sub(0,1)\\\" is -1 in two's complement.\\n sx := sgt(x, sub(0, 1))\\n sy := sgt(y, sub(0, 1))\\n sd := sgt(denominator, sub(0, 1))\\n }\\n\\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\\n // If there are, the result should be negative. Otherwise, it should be positive.\\n unchecked {\\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\\n }\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - If x is not a perfect square, the result is rounded down.\\n/// - Credits to OpenZeppelin for the explanations in comments below.\\n///\\n/// @param x The uint256 number for which to calculate the square root.\\n/// @return result The result as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(uint256 x) pure returns (uint256 result) {\\n if (x == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of x is a power of 2 such that we have:\\n //\\n // $$\\n // msb(x) <= x <= 2*msb(x)$\\n // $$\\n //\\n // We write $msb(x)$ as $2^k$, and we get:\\n //\\n // $$\\n // k = log_2(x)\\n // $$\\n //\\n // Thus, we can write the initial inequality as:\\n //\\n // $$\\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\\\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\\\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\\n // $$\\n //\\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\\n uint256 xAux = uint256(x);\\n result = 1;\\n if (xAux >= 2 ** 128) {\\n xAux >>= 128;\\n result <<= 64;\\n }\\n if (xAux >= 2 ** 64) {\\n xAux >>= 64;\\n result <<= 32;\\n }\\n if (xAux >= 2 ** 32) {\\n xAux >>= 32;\\n result <<= 16;\\n }\\n if (xAux >= 2 ** 16) {\\n xAux >>= 16;\\n result <<= 8;\\n }\\n if (xAux >= 2 ** 8) {\\n xAux >>= 8;\\n result <<= 4;\\n }\\n if (xAux >= 2 ** 4) {\\n xAux >>= 4;\\n result <<= 2;\\n }\\n if (xAux >= 2 ** 2) {\\n result <<= 1;\\n }\\n\\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\\n // precision into the expected uint128 result.\\n unchecked {\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n\\n // If x is not a perfect square, round the result toward zero.\\n uint256 roundedResult = x / result;\\n if (result >= roundedResult) {\\n result = roundedResult;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaa374e2c26cc93e8c22a6953804ee05f811597ef5fa82f76824378b22944778b\",\"license\":\"MIT\"},\"@prb/math/src/UD2x18.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n/*\\n\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2588\\u2588\\u2554\\u2550\\u2550\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u2588\\u2588\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u255a\\u2550\\u255d \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\n\\n\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u255d\\n\\n*/\\n\\nimport \\\"./ud2x18/Casting.sol\\\";\\nimport \\\"./ud2x18/Constants.sol\\\";\\nimport \\\"./ud2x18/Errors.sol\\\";\\nimport \\\"./ud2x18/ValueType.sol\\\";\\n\",\"keccak256\":\"0xfb624e24cd8bb790fa08e7827819de85504a86e20e961fa4ad126c65b6d90641\",\"license\":\"MIT\"},\"@prb/math/src/UD60x18.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n/*\\n\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2588\\u2588\\u2554\\u2550\\u2550\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u2588\\u2588\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u255a\\u2550\\u255d \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\n\\n\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2588\\u2588\\u2588\\u2588\\u2557\\u255a\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551 \\u255a\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u255d \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u255d\\n\\n*/\\n\\nimport \\\"./ud60x18/Casting.sol\\\";\\nimport \\\"./ud60x18/Constants.sol\\\";\\nimport \\\"./ud60x18/Conversions.sol\\\";\\nimport \\\"./ud60x18/Errors.sol\\\";\\nimport \\\"./ud60x18/Helpers.sol\\\";\\nimport \\\"./ud60x18/Math.sol\\\";\\nimport \\\"./ud60x18/ValueType.sol\\\";\\n\",\"keccak256\":\"0xb98c6f74275914d279e8af6c502c2b1f50d5f6e1ed418d3b0153f5a193206c48\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts an SD1x18 number into SD59x18.\\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\\n}\\n\\n/// @notice Casts an SD1x18 number into UD2x18.\\n/// - x must be positive.\\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\\n }\\n result = UD2x18.wrap(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into UD60x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\\n }\\n result = UD60x18.wrap(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint256.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\\n }\\n result = uint256(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\\n }\\n result = uint128(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\\n }\\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\\n }\\n result = uint40(uint64(xInt));\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\\n result = SD1x18.wrap(x);\\n}\\n\\n/// @notice Unwraps an SD1x18 number into int64.\\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\\n result = SD1x18.unwrap(x);\\n}\\n\\n/// @notice Wraps an int64 number into SD1x18.\\nfunction wrap(int64 x) pure returns (SD1x18 result) {\\n result = SD1x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x9e49e2b37c1bb845861740805edaaef3fe951a7b96eef16ce84fbf76e8278670\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @dev Euler's number as an SD1x18 number.\\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum value an SD1x18 number can have.\\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\\n\\n/// @dev The maximum value an SD1x18 number can have.\\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\\n\\n/// @dev PI as an SD1x18 number.\\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of SD1x18.\\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\\nint64 constant uUNIT = 1e18;\\n\",\"keccak256\":\"0x6496165b80552785a4b65a239b96e2a5fedf62fe54f002eeed72d75e566d7585\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\\n\",\"keccak256\":\"0x836cb42ba619ca369fd4765bc47fefc3c3621369c5861882af14660aca5057ee\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\n\\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\\n/// storage.\\ntype SD1x18 is int64;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD59x18,\\n Casting.intoUD2x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for SD1x18 global;\\n\",\"keccak256\":\"0x2f86f1aa9fca42f40808b51a879b406ac51817647bdb9642f8a79dd8fdb754a7\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { MAX_UINT128, MAX_UINT40 } from \\\"../Common.sol\\\";\\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { uMAX_UD2x18 } from \\\"../ud2x18/Constants.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts an SD59x18 number into int256.\\n/// @dev This is basically a functional alias for {unwrap}.\\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\\n result = SD59x18.unwrap(x);\\n}\\n\\n/// @notice Casts an SD59x18 number into SD1x18.\\n/// @dev Requirements:\\n/// - x must be greater than or equal to `uMIN_SD1x18`.\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < uMIN_SD1x18) {\\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\\n }\\n if (xInt > uMAX_SD1x18) {\\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into UD2x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `uMAX_UD2x18`.\\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\\n }\\n if (xInt > int256(uint256(uMAX_UD2x18))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\\n }\\n result = UD2x18.wrap(uint64(uint256(xInt)));\\n}\\n\\n/// @notice Casts an SD59x18 number into UD60x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\\n }\\n result = UD60x18.wrap(uint256(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into uint256.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\\n }\\n result = uint256(xInt);\\n}\\n\\n/// @notice Casts an SD59x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `uMAX_UINT128`.\\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\\n }\\n if (xInt > int256(uint256(MAX_UINT128))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\\n }\\n result = uint128(uint256(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\\n }\\n if (xInt > int256(uint256(MAX_UINT40))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(uint256(xInt));\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\\n/// @notice Unwraps an SD59x18 number into int256.\\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\\n result = SD59x18.unwrap(x);\\n}\\n\\n/// @notice Wraps an int256 number into SD59x18.\\nfunction wrap(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x3b21b60ec2998c3ae32f647412da51d3683b3f183a807198cc8d157499484f99\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n// NOTICE: the \\\"u\\\" prefix stands for \\\"unwrapped\\\".\\n\\n/// @dev Euler's number as an SD59x18 number.\\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum input permitted in {exp}.\\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\\n\\n/// @dev Any value less than this returns 0 in {exp}.\\nint256 constant uEXP_MIN_THRESHOLD = -41_446531673892822322;\\nSD59x18 constant EXP_MIN_THRESHOLD = SD59x18.wrap(uEXP_MIN_THRESHOLD);\\n\\n/// @dev The maximum input permitted in {exp2}.\\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\\n\\n/// @dev Any value less than this returns 0 in {exp2}.\\nint256 constant uEXP2_MIN_THRESHOLD = -59_794705707972522261;\\nSD59x18 constant EXP2_MIN_THRESHOLD = SD59x18.wrap(uEXP2_MIN_THRESHOLD);\\n\\n/// @dev Half the UNIT number.\\nint256 constant uHALF_UNIT = 0.5e18;\\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\\n\\n/// @dev $log_2(10)$ as an SD59x18 number.\\nint256 constant uLOG2_10 = 3_321928094887362347;\\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\\n\\n/// @dev $log_2(e)$ as an SD59x18 number.\\nint256 constant uLOG2_E = 1_442695040888963407;\\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\\n\\n/// @dev The maximum value an SD59x18 number can have.\\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\\n\\n/// @dev The maximum whole value an SD59x18 number can have.\\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\\n\\n/// @dev The minimum value an SD59x18 number can have.\\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\\n\\n/// @dev The minimum whole value an SD59x18 number can have.\\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\\n\\n/// @dev PI as an SD59x18 number.\\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of SD59x18.\\nint256 constant uUNIT = 1e18;\\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\\n\\n/// @dev The unit number squared.\\nint256 constant uUNIT_SQUARED = 1e36;\\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\\n\\n/// @dev Zero as an SD59x18 number.\\nSD59x18 constant ZERO = SD59x18.wrap(0);\\n\",\"keccak256\":\"0x9bcb8dd6b3e886d140ad1c32747a4f6d29a492529ceb835be878ae837aa6cc3a\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Abs_MinSD59x18();\\n\\n/// @notice Thrown when ceiling a number overflows SD59x18.\\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\\n\\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Div_InputTooSmall();\\n\\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\\n\\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\\n\\n/// @notice Thrown when flooring a number underflows SD59x18.\\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\\n\\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Mul_InputTooSmall();\\n\\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\\n\\n/// @notice Thrown when taking the square root of a negative number.\\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\\n\\n/// @notice Thrown when the calculating the square root overflows SD59x18.\\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\\n\",\"keccak256\":\"0xa6d00fe5efa215ac0df25c896e3da99a12fb61e799644b2ec32da947313d3db4\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() + y.unwrap());\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() & bits);\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() & y.unwrap());\\n}\\n\\n/// @notice Implements the equal (=) operation in the SD59x18 type.\\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() == y.unwrap();\\n}\\n\\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() > y.unwrap();\\n}\\n\\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() >= y.unwrap();\\n}\\n\\n/// @notice Implements a zero comparison check function in the SD59x18 type.\\nfunction isZero(SD59x18 x) pure returns (bool result) {\\n result = x.unwrap() == 0;\\n}\\n\\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() << bits);\\n}\\n\\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() < y.unwrap();\\n}\\n\\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() <= y.unwrap();\\n}\\n\\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() % y.unwrap());\\n}\\n\\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() != y.unwrap();\\n}\\n\\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(~x.unwrap());\\n}\\n\\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() | y.unwrap());\\n}\\n\\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() >> bits);\\n}\\n\\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() - y.unwrap());\\n}\\n\\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(-x.unwrap());\\n}\\n\\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() + y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() - y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(-x.unwrap());\\n }\\n}\\n\\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() ^ y.unwrap());\\n}\\n\",\"keccak256\":\"0x208570f1657cf730cb6c3d81aa14030e0d45cf906cdedea5059369d7df4bb716\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport {\\n uEXP_MAX_INPUT,\\n uEXP2_MAX_INPUT,\\n uEXP_MIN_THRESHOLD,\\n uEXP2_MIN_THRESHOLD,\\n uHALF_UNIT,\\n uLOG2_10,\\n uLOG2_E,\\n uMAX_SD59x18,\\n uMAX_WHOLE_SD59x18,\\n uMIN_SD59x18,\\n uMIN_WHOLE_SD59x18,\\n UNIT,\\n uUNIT,\\n uUNIT_SQUARED,\\n ZERO\\n} from \\\"./Constants.sol\\\";\\nimport { wrap } from \\\"./Helpers.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Calculates the absolute value of x.\\n///\\n/// @dev Requirements:\\n/// - x must be greater than `MIN_SD59x18`.\\n///\\n/// @param x The SD59x18 number for which to calculate the absolute value.\\n/// @param result The absolute value of x as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\\n }\\n result = xInt < 0 ? wrap(-xInt) : x;\\n}\\n\\n/// @notice Calculates the arithmetic average of x and y.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// @param x The first operand as an SD59x18 number.\\n/// @param y The second operand as an SD59x18 number.\\n/// @return result The arithmetic average as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n\\n unchecked {\\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\\n int256 sum = (xInt >> 1) + (yInt >> 1);\\n\\n if (sum < 0) {\\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\\n assembly (\\\"memory-safe\\\") {\\n result := add(sum, and(or(xInt, yInt), 1))\\n }\\n } else {\\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\\n result = wrap(sum + (xInt & yInt & 1));\\n }\\n }\\n}\\n\\n/// @notice Yields the smallest whole number greater than or equal to x.\\n///\\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\\n///\\n/// @param x The SD59x18 number to ceil.\\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt > uMAX_WHOLE_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\\n }\\n\\n int256 remainder = xInt % uUNIT;\\n if (remainder == 0) {\\n result = x;\\n } else {\\n unchecked {\\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\\n int256 resultInt = xInt - remainder;\\n if (xInt > 0) {\\n resultInt += uUNIT;\\n }\\n result = wrap(resultInt);\\n }\\n }\\n}\\n\\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\\n///\\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\\n/// values separately.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n/// - None of the inputs can be `MIN_SD59x18`.\\n/// - The denominator must not be zero.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The numerator as an SD59x18 number.\\n/// @param y The denominator as an SD59x18 number.\\n/// @param result The quotient as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x and y.\\n uint256 xAbs;\\n uint256 yAbs;\\n unchecked {\\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\\n }\\n\\n // Compute the absolute value (x*UNIT\\u00f7y). The resulting value must fit in SD59x18.\\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\\n }\\n\\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\\n // negative, 0 for positive or zero).\\n bool sameSign = (xInt ^ yInt) > -1;\\n\\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\\n unchecked {\\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\\n }\\n}\\n\\n/// @notice Calculates the natural exponent of x using the following formula:\\n///\\n/// $$\\n/// e^x = 2^{x * log_2{e}}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {exp2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}.\\n/// - x must be less than 133_084258667509499441.\\n///\\n/// @param x The exponent as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n\\n // Any input less than the threshold returns zero.\\n // This check also prevents an overflow for very small numbers.\\n if (xInt < uEXP_MIN_THRESHOLD) {\\n return ZERO;\\n }\\n\\n // This check prevents values greater than 192e18 from being passed to {exp2}.\\n if (xInt > uEXP_MAX_INPUT) {\\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Inline the fixed-point multiplication to save gas.\\n int256 doubleUnitProduct = xInt * uLOG2_E;\\n result = exp2(wrap(doubleUnitProduct / uUNIT));\\n }\\n}\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\\n///\\n/// $$\\n/// 2^{-x} = \\\\frac{1}{2^x}\\n/// $$\\n///\\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\\n///\\n/// Notes:\\n/// - If x is less than -59_794705707972522261, the result is zero.\\n///\\n/// Requirements:\\n/// - x must be less than 192e18.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The exponent as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n // The inverse of any number less than the threshold is truncated to zero.\\n if (xInt < uEXP2_MIN_THRESHOLD) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Inline the fixed-point inversion to save gas.\\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\\n }\\n } else {\\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\\n if (xInt > uEXP2_MAX_INPUT) {\\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Convert x to the 192.64-bit fixed-point format.\\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\\n\\n // It is safe to cast the result to int256 due to the checks above.\\n result = wrap(int256(Common.exp2(x_192x64)));\\n }\\n }\\n}\\n\\n/// @notice Yields the greatest whole number less than or equal to x.\\n///\\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\\n///\\n/// @param x The SD59x18 number to floor.\\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < uMIN_WHOLE_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\\n }\\n\\n int256 remainder = xInt % uUNIT;\\n if (remainder == 0) {\\n result = x;\\n } else {\\n unchecked {\\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\\n int256 resultInt = xInt - remainder;\\n if (xInt < 0) {\\n resultInt -= uUNIT;\\n }\\n result = wrap(resultInt);\\n }\\n }\\n}\\n\\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\\n/// of the radix point for negative numbers.\\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\\n/// @param x The SD59x18 number to get the fractional part of.\\n/// @param result The fractional part of x as an SD59x18 number.\\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() % uUNIT);\\n}\\n\\n/// @notice Calculates the geometric mean of x and y, i.e. $\\\\sqrt{x * y}$.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x * y must fit in SD59x18.\\n/// - x * y must not be negative, since complex numbers are not supported.\\n///\\n/// @param x The first operand as an SD59x18 number.\\n/// @param y The second operand as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == 0 || yInt == 0) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\\n int256 xyInt = xInt * yInt;\\n if (xyInt / xInt != yInt) {\\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\\n }\\n\\n // The product must not be negative, since complex numbers are not supported.\\n if (xyInt < 0) {\\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\\n }\\n\\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\\n // during multiplication. See the comments in {Common.sqrt}.\\n uint256 resultUint = Common.sqrt(uint256(xyInt));\\n result = wrap(int256(resultUint));\\n }\\n}\\n\\n/// @notice Calculates the inverse of x.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must not be zero.\\n///\\n/// @param x The SD59x18 number for which to calculate the inverse.\\n/// @return result The inverse as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(uUNIT_SQUARED / x.unwrap());\\n}\\n\\n/// @notice Calculates the natural logarithm of x using the following formula:\\n///\\n/// $$\\n/// ln{x} = log_2{x} / log_2{e}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\\n/// @return result The natural logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\\n // {log2} can return is ~195_205294292027477728.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\\n}\\n\\n/// @notice Calculates the common logarithm of x using the following formula:\\n///\\n/// $$\\n/// log_{10}{x} = log_2{x} / log_2{10}\\n/// $$\\n///\\n/// However, if x is an exact power of ten, a hard coded value is returned.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The SD59x18 number for which to calculate the common logarithm.\\n/// @return result The common logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\\n }\\n\\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\\n // prettier-ignore\\n assembly (\\\"memory-safe\\\") {\\n switch x\\n case 1 { result := mul(uUNIT, sub(0, 18)) }\\n case 10 { result := mul(uUNIT, sub(1, 18)) }\\n case 100 { result := mul(uUNIT, sub(2, 18)) }\\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\\n case 1000000000000000000 { result := 0 }\\n case 10000000000000000000 { result := uUNIT }\\n case 100000000000000000000 { result := mul(uUNIT, 2) }\\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\\n default { result := uMAX_SD59x18 }\\n }\\n\\n if (result.unwrap() == uMAX_SD59x18) {\\n unchecked {\\n // Inline the fixed-point division to save gas.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\\n }\\n }\\n}\\n\\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\\n///\\n/// $$\\n/// log_2{x} = n + log_2{y}, \\\\text{ where } y = x*2^{-n}, \\\\ y \\\\in [1, 2)\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, the input is inverted:\\n///\\n/// $$\\n/// log_2{x} = -log_2{\\\\frac{1}{x}}\\n/// $$\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\\n///\\n/// Notes:\\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\\n///\\n/// Requirements:\\n/// - x must be greater than zero.\\n///\\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\\n/// @return result The binary logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt <= 0) {\\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\\n }\\n\\n unchecked {\\n int256 sign;\\n if (xInt >= uUNIT) {\\n sign = 1;\\n } else {\\n sign = -1;\\n // Inline the fixed-point inversion to save gas.\\n xInt = uUNIT_SQUARED / xInt;\\n }\\n\\n // Calculate the integer part of the logarithm.\\n uint256 n = Common.msb(uint256(xInt / uUNIT));\\n\\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\\n int256 resultInt = int256(n) * uUNIT;\\n\\n // Calculate $y = x * 2^{-n}$.\\n int256 y = xInt >> n;\\n\\n // If y is the unit number, the fractional part is zero.\\n if (y == uUNIT) {\\n return wrap(resultInt * sign);\\n }\\n\\n // Calculate the fractional part via the iterative approximation.\\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\\n int256 DOUBLE_UNIT = 2e18;\\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\\n y = (y * y) / uUNIT;\\n\\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\\n if (y >= DOUBLE_UNIT) {\\n // Add the 2^{-m} factor to the logarithm.\\n resultInt = resultInt + delta;\\n\\n // Halve y, which corresponds to z/2 in the Wikipedia article.\\n y >>= 1;\\n }\\n }\\n resultInt *= sign;\\n result = wrap(resultInt);\\n }\\n}\\n\\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv18}.\\n/// - None of the inputs can be `MIN_SD59x18`.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The multiplicand as an SD59x18 number.\\n/// @param y The multiplier as an SD59x18 number.\\n/// @return result The product as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x and y.\\n uint256 xAbs;\\n uint256 yAbs;\\n unchecked {\\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\\n }\\n\\n // Compute the absolute value (x*y\\u00f7UNIT). The resulting value must fit in SD59x18.\\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\\n }\\n\\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\\n // negative, 0 for positive or zero).\\n bool sameSign = (xInt ^ yInt) > -1;\\n\\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\\n unchecked {\\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\\n }\\n}\\n\\n/// @notice Raises x to the power of y using the following formula:\\n///\\n/// $$\\n/// x^y = 2^{log_2{x} * y}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\\n///\\n/// @param x The base as an SD59x18 number.\\n/// @param y Exponent to raise x to, as an SD59x18 number\\n/// @return result x raised to power y, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n\\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\\n if (xInt == 0) {\\n return yInt == 0 ? UNIT : ZERO;\\n }\\n // If x is `UNIT`, the result is always `UNIT`.\\n else if (xInt == uUNIT) {\\n return UNIT;\\n }\\n\\n // If y is zero, the result is always `UNIT`.\\n if (yInt == 0) {\\n return UNIT;\\n }\\n // If y is `UNIT`, the result is always x.\\n else if (yInt == uUNIT) {\\n return x;\\n }\\n\\n // Calculate the result using the formula.\\n result = exp2(mul(log2(x), y));\\n}\\n\\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\\n/// algorithm \\\"exponentiation by squaring\\\".\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The base as an SD59x18 number.\\n/// @param y The exponent as a uint256.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\\n uint256 xAbs = uint256(abs(x).unwrap());\\n\\n // Calculate the first iteration of the loop in advance.\\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\\n\\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\\n uint256 yAux = y;\\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\\n xAbs = Common.mulDiv18(xAbs, xAbs);\\n\\n // Equivalent to `y % 2 == 1`.\\n if (yAux & 1 > 0) {\\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\\n }\\n }\\n\\n // The result must fit in SD59x18.\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\\n }\\n\\n unchecked {\\n // Is the base negative and the exponent odd? If yes, the result should be negative.\\n int256 resultInt = int256(resultAbs);\\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\\n if (isNegative) {\\n resultInt = -resultInt;\\n }\\n result = wrap(resultInt);\\n }\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - Only the positive root is returned.\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x cannot be negative, since complex numbers are not supported.\\n/// - x must be less than `MAX_SD59x18 / UNIT`.\\n///\\n/// @param x The SD59x18 number for which to calculate the square root.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\\n }\\n if (xInt > uMAX_SD59x18 / uUNIT) {\\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\\n }\\n\\n unchecked {\\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\\n // In this case, the two numbers are both the square root.\\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\\n result = wrap(int256(resultUint));\\n }\\n}\\n\",\"keccak256\":\"0xa074831139fc89ca0e5a36086b30eb50896bb6770cd5823461b1f2769017d2f0\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\nimport \\\"./Helpers.sol\\\" as Helpers;\\nimport \\\"./Math.sol\\\" as Math;\\n\\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type int256.\\ntype SD59x18 is int256;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoInt256,\\n Casting.intoSD1x18,\\n Casting.intoUD2x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Math.abs,\\n Math.avg,\\n Math.ceil,\\n Math.div,\\n Math.exp,\\n Math.exp2,\\n Math.floor,\\n Math.frac,\\n Math.gm,\\n Math.inv,\\n Math.log10,\\n Math.log2,\\n Math.ln,\\n Math.mul,\\n Math.pow,\\n Math.powu,\\n Math.sqrt\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n HELPER FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Helpers.add,\\n Helpers.and,\\n Helpers.eq,\\n Helpers.gt,\\n Helpers.gte,\\n Helpers.isZero,\\n Helpers.lshift,\\n Helpers.lt,\\n Helpers.lte,\\n Helpers.mod,\\n Helpers.neq,\\n Helpers.not,\\n Helpers.or,\\n Helpers.rshift,\\n Helpers.sub,\\n Helpers.uncheckedAdd,\\n Helpers.uncheckedSub,\\n Helpers.uncheckedUnary,\\n Helpers.xor\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n OPERATORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes it possible to use these operators on the SD59x18 type.\\nusing {\\n Helpers.add as +,\\n Helpers.and2 as &,\\n Math.div as /,\\n Helpers.eq as ==,\\n Helpers.gt as >,\\n Helpers.gte as >=,\\n Helpers.lt as <,\\n Helpers.lte as <=,\\n Helpers.mod as %,\\n Math.mul as *,\\n Helpers.neq as !=,\\n Helpers.not as ~,\\n Helpers.or as |,\\n Helpers.sub as -,\\n Helpers.unary as -,\\n Helpers.xor as ^\\n} for SD59x18 global;\\n\",\"keccak256\":\"0xe03112d145dcd5863aff24e5f381debaae29d446acd5666f3d640e3d9af738d7\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport { uMAX_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts a UD2x18 number into SD1x18.\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\\n uint64 xUint = UD2x18.unwrap(x);\\n if (xUint > uint64(uMAX_SD1x18)) {\\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(xUint));\\n}\\n\\n/// @notice Casts a UD2x18 number into SD59x18.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\\n}\\n\\n/// @notice Casts a UD2x18 number into UD60x18.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint128.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\\n result = uint128(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint256.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\\n result = uint256(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\\n uint64 xUint = UD2x18.unwrap(x);\\n if (xUint > uint64(Common.MAX_UINT40)) {\\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(xUint);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\\n result = UD2x18.wrap(x);\\n}\\n\\n/// @notice Unwrap a UD2x18 number into uint64.\\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\\n result = UD2x18.unwrap(x);\\n}\\n\\n/// @notice Wraps a uint64 number into UD2x18.\\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\\n result = UD2x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x9b1a35d432ef951a415fae8098b3c609a99b630a3d5464b3c8e1efa8893eea07\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @dev Euler's number as a UD2x18 number.\\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum value a UD2x18 number can have.\\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\\n\\n/// @dev PI as a UD2x18 number.\\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of UD2x18.\\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\\nuint64 constant uUNIT = 1e18;\\n\",\"keccak256\":\"0x29b0e050c865899e1fb9022b460a7829cdee248c44c4299f068ba80695eec3fc\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\\n\\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\\n\",\"keccak256\":\"0xdf1e22f0b4c8032bcc8b7f63fe3984e1387f3dc7b2e9ab381822249f75376d33\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\n\\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\\n/// storage.\\ntype UD2x18 is uint64;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD1x18,\\n Casting.intoSD59x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for UD2x18 global;\\n\",\"keccak256\":\"0x2802edc9869db116a0b5c490cc5f8554742f747183fa30ac5e9c80bb967e61a1\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { MAX_UINT128, MAX_UINT40 } from \\\"../Common.sol\\\";\\nimport { uMAX_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { uMAX_SD59x18 } from \\\"../sd59x18/Constants.sol\\\";\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { uMAX_UD2x18 } from \\\"../ud2x18/Constants.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts a UD60x18 number into SD1x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uint256(int256(uMAX_SD1x18))) {\\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(uint64(xUint)));\\n}\\n\\n/// @notice Casts a UD60x18 number into UD2x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_UD2x18`.\\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uMAX_UD2x18) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\\n }\\n result = UD2x18.wrap(uint64(xUint));\\n}\\n\\n/// @notice Casts a UD60x18 number into SD59x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_SD59x18`.\\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uint256(uMAX_SD59x18)) {\\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\\n }\\n result = SD59x18.wrap(int256(xUint));\\n}\\n\\n/// @notice Casts a UD60x18 number into uint128.\\n/// @dev This is basically an alias for {unwrap}.\\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x);\\n}\\n\\n/// @notice Casts a UD60x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT128`.\\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > MAX_UINT128) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\\n }\\n result = uint128(xUint);\\n}\\n\\n/// @notice Casts a UD60x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > MAX_UINT40) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(xUint);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\\n/// @notice Unwraps a UD60x18 number into uint256.\\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x);\\n}\\n\\n/// @notice Wraps a uint256 number into the UD60x18 value type.\\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x5bb532da36921cbdac64d1f16de5d366ef1f664502e3b7c07d0ad06917551f85\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n// NOTICE: the \\\"u\\\" prefix stands for \\\"unwrapped\\\".\\n\\n/// @dev Euler's number as a UD60x18 number.\\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum input permitted in {exp}.\\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\\n\\n/// @dev The maximum input permitted in {exp2}.\\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\\n\\n/// @dev Half the UNIT number.\\nuint256 constant uHALF_UNIT = 0.5e18;\\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\\n\\n/// @dev $log_2(10)$ as a UD60x18 number.\\nuint256 constant uLOG2_10 = 3_321928094887362347;\\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\\n\\n/// @dev $log_2(e)$ as a UD60x18 number.\\nuint256 constant uLOG2_E = 1_442695040888963407;\\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\\n\\n/// @dev The maximum value a UD60x18 number can have.\\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\\n\\n/// @dev The maximum whole value a UD60x18 number can have.\\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\\n\\n/// @dev PI as a UD60x18 number.\\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of UD60x18.\\nuint256 constant uUNIT = 1e18;\\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\\n\\n/// @dev The unit number squared.\\nuint256 constant uUNIT_SQUARED = 1e36;\\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\\n\\n/// @dev Zero as a UD60x18 number.\\nUD60x18 constant ZERO = UD60x18.wrap(0);\\n\",\"keccak256\":\"0x2b80d26153d3fdcfb3a9ca772d9309d31ed1275f5b8b54c3ffb54d3652b37d90\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Conversions.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { uMAX_UD60x18, uUNIT } from \\\"./Constants.sol\\\";\\nimport { PRBMath_UD60x18_Convert_Overflow } from \\\"./Errors.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\\n/// @dev The result is rounded toward zero.\\n/// @param x The UD60x18 number to convert.\\n/// @return result The same number in basic integer form.\\nfunction convert(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x) / uUNIT;\\n}\\n\\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\\n///\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\\n///\\n/// @param x The basic integer to convert.\\n/// @param result The same number converted to UD60x18.\\nfunction convert(uint256 x) pure returns (UD60x18 result) {\\n if (x > uMAX_UD60x18 / uUNIT) {\\n revert PRBMath_UD60x18_Convert_Overflow(x);\\n }\\n unchecked {\\n result = UD60x18.wrap(x * uUNIT);\\n }\\n}\\n\",\"keccak256\":\"0xaf7fc2523413822de3b66ba339fe2884fb3b8c6f6cf38ec90a2c3e3aae71df6b\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when ceiling a number overflows UD60x18.\\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\\n\\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\\n\\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when taking the logarithm of a number less than 1.\\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\\n\\n/// @notice Thrown when calculating the square root overflows UD60x18.\\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\\n\",\"keccak256\":\"0xa8c60d4066248df22c49c882873efbc017344107edabc48c52209abbc39cb1e3\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() + y.unwrap());\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() & bits);\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() & y.unwrap());\\n}\\n\\n/// @notice Implements the equal operation (==) in the UD60x18 type.\\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() == y.unwrap();\\n}\\n\\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() > y.unwrap();\\n}\\n\\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() >= y.unwrap();\\n}\\n\\n/// @notice Implements a zero comparison check function in the UD60x18 type.\\nfunction isZero(UD60x18 x) pure returns (bool result) {\\n // This wouldn't work if x could be negative.\\n result = x.unwrap() == 0;\\n}\\n\\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() << bits);\\n}\\n\\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() < y.unwrap();\\n}\\n\\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() <= y.unwrap();\\n}\\n\\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() % y.unwrap());\\n}\\n\\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() != y.unwrap();\\n}\\n\\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\\n result = wrap(~x.unwrap());\\n}\\n\\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() | y.unwrap());\\n}\\n\\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() >> bits);\\n}\\n\\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() - y.unwrap());\\n}\\n\\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() + y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() - y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() ^ y.unwrap());\\n}\\n\",\"keccak256\":\"0xf5faff881391d2c060029499a666cc5f0bea90a213150bb476fae8f02a5df268\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport {\\n uEXP_MAX_INPUT,\\n uEXP2_MAX_INPUT,\\n uHALF_UNIT,\\n uLOG2_10,\\n uLOG2_E,\\n uMAX_UD60x18,\\n uMAX_WHOLE_UD60x18,\\n UNIT,\\n uUNIT,\\n uUNIT_SQUARED,\\n ZERO\\n} from \\\"./Constants.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Calculates the arithmetic average of x and y using the following formula:\\n///\\n/// $$\\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\\n/// $$\\n///\\n/// In English, this is what this formula does:\\n///\\n/// 1. AND x and y.\\n/// 2. Calculate half of XOR x and y.\\n/// 3. Add the two results together.\\n///\\n/// This technique is known as SWAR, which stands for \\\"SIMD within a register\\\". You can read more about it here:\\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// @param x The first operand as a UD60x18 number.\\n/// @param y The second operand as a UD60x18 number.\\n/// @return result The arithmetic average as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n unchecked {\\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\\n }\\n}\\n\\n/// @notice Yields the smallest whole number greater than or equal to x.\\n///\\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\\n///\\n/// @param x The UD60x18 number to ceil.\\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n if (xUint > uMAX_WHOLE_UD60x18) {\\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\\n }\\n\\n assembly (\\\"memory-safe\\\") {\\n // Equivalent to `x % UNIT`.\\n let remainder := mod(x, uUNIT)\\n\\n // Equivalent to `UNIT - remainder`.\\n let delta := sub(uUNIT, remainder)\\n\\n // Equivalent to `x + remainder > 0 ? delta : 0`.\\n result := add(x, mul(delta, gt(remainder, 0)))\\n }\\n}\\n\\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\\n///\\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n///\\n/// @param x The numerator as a UD60x18 number.\\n/// @param y The denominator as a UD60x18 number.\\n/// @param result The quotient as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\\n}\\n\\n/// @notice Calculates the natural exponent of x using the following formula:\\n///\\n/// $$\\n/// e^x = 2^{x * log_2{e}}\\n/// $$\\n///\\n/// @dev Requirements:\\n/// - x must be less than 133_084258667509499441.\\n///\\n/// @param x The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n // This check prevents values greater than 192e18 from being passed to {exp2}.\\n if (xUint > uEXP_MAX_INPUT) {\\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Inline the fixed-point multiplication to save gas.\\n uint256 doubleUnitProduct = xUint * uLOG2_E;\\n result = exp2(wrap(doubleUnitProduct / uUNIT));\\n }\\n}\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method.\\n///\\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\\n///\\n/// Requirements:\\n/// - x must be less than 192e18.\\n/// - The result must fit in UD60x18.\\n///\\n/// @param x The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\\n if (xUint > uEXP2_MAX_INPUT) {\\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\\n }\\n\\n // Convert x to the 192.64-bit fixed-point format.\\n uint256 x_192x64 = (xUint << 64) / uUNIT;\\n\\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\\n result = wrap(Common.exp2(x_192x64));\\n}\\n\\n/// @notice Yields the greatest whole number less than or equal to x.\\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n/// @param x The UD60x18 number to floor.\\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\\n assembly (\\\"memory-safe\\\") {\\n // Equivalent to `x % UNIT`.\\n let remainder := mod(x, uUNIT)\\n\\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\\n result := sub(x, mul(remainder, gt(remainder, 0)))\\n }\\n}\\n\\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\\n/// @param x The UD60x18 number to get the fractional part of.\\n/// @param result The fractional part of x as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\\n assembly (\\\"memory-safe\\\") {\\n result := mod(x, uUNIT)\\n }\\n}\\n\\n/// @notice Calculates the geometric mean of x and y, i.e. $\\\\sqrt{x * y}$, rounding down.\\n///\\n/// @dev Requirements:\\n/// - x * y must fit in UD60x18.\\n///\\n/// @param x The first operand as a UD60x18 number.\\n/// @param y The second operand as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n if (xUint == 0 || yUint == 0) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Checking for overflow this way is faster than letting Solidity do it.\\n uint256 xyUint = xUint * yUint;\\n if (xyUint / xUint != yUint) {\\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\\n }\\n\\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\\n // during multiplication. See the comments in {Common.sqrt}.\\n result = wrap(Common.sqrt(xyUint));\\n }\\n}\\n\\n/// @notice Calculates the inverse of x.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must not be zero.\\n///\\n/// @param x The UD60x18 number for which to calculate the inverse.\\n/// @return result The inverse as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(uUNIT_SQUARED / x.unwrap());\\n }\\n}\\n\\n/// @notice Calculates the natural logarithm of x using the following formula:\\n///\\n/// $$\\n/// ln{x} = log_2{x} / log_2{e}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\\n/// @return result The natural logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\\n unchecked {\\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\\n // {log2} can return is ~196_205294292027477728.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\\n }\\n}\\n\\n/// @notice Calculates the common logarithm of x using the following formula:\\n///\\n/// $$\\n/// log_{10}{x} = log_2{x} / log_2{10}\\n/// $$\\n///\\n/// However, if x is an exact power of ten, a hard coded value is returned.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The UD60x18 number for which to calculate the common logarithm.\\n/// @return result The common logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n if (xUint < uUNIT) {\\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\\n }\\n\\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\\n // prettier-ignore\\n assembly (\\\"memory-safe\\\") {\\n switch x\\n case 1 { result := mul(uUNIT, sub(0, 18)) }\\n case 10 { result := mul(uUNIT, sub(1, 18)) }\\n case 100 { result := mul(uUNIT, sub(2, 18)) }\\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\\n case 1000000000000000000 { result := 0 }\\n case 10000000000000000000 { result := uUNIT }\\n case 100000000000000000000 { result := mul(uUNIT, 2) }\\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\\n default { result := uMAX_UD60x18 }\\n }\\n\\n if (result.unwrap() == uMAX_UD60x18) {\\n unchecked {\\n // Inline the fixed-point division to save gas.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\\n }\\n }\\n}\\n\\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\\n///\\n/// $$\\n/// log_2{x} = n + log_2{y}, \\\\text{ where } y = x*2^{-n}, \\\\ y \\\\in [1, 2)\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, the input is inverted:\\n///\\n/// $$\\n/// log_2{x} = -log_2{\\\\frac{1}{x}}\\n/// $$\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\\n///\\n/// Notes:\\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\\n///\\n/// Requirements:\\n/// - x must be greater than zero.\\n///\\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\\n/// @return result The binary logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n if (xUint < uUNIT) {\\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\\n }\\n\\n unchecked {\\n // Calculate the integer part of the logarithm.\\n uint256 n = Common.msb(xUint / uUNIT);\\n\\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\\n // n is at most 255 and UNIT is 1e18.\\n uint256 resultUint = n * uUNIT;\\n\\n // Calculate $y = x * 2^{-n}$.\\n uint256 y = xUint >> n;\\n\\n // If y is the unit number, the fractional part is zero.\\n if (y == uUNIT) {\\n return wrap(resultUint);\\n }\\n\\n // Calculate the fractional part via the iterative approximation.\\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\\n uint256 DOUBLE_UNIT = 2e18;\\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\\n y = (y * y) / uUNIT;\\n\\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\\n if (y >= DOUBLE_UNIT) {\\n // Add the 2^{-m} factor to the logarithm.\\n resultUint += delta;\\n\\n // Halve y, which corresponds to z/2 in the Wikipedia article.\\n y >>= 1;\\n }\\n }\\n result = wrap(resultUint);\\n }\\n}\\n\\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\\n///\\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n///\\n/// @dev See the documentation in {Common.mulDiv18}.\\n/// @param x The multiplicand as a UD60x18 number.\\n/// @param y The multiplier as a UD60x18 number.\\n/// @return result The product as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\\n}\\n\\n/// @notice Raises x to the power of y.\\n///\\n/// For $1 \\\\leq x \\\\leq \\\\infty$, the following standard formula is used:\\n///\\n/// $$\\n/// x^y = 2^{log_2{x} * y}\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\\n///\\n/// $$\\n/// i = \\\\frac{1}{x}\\n/// w = 2^{log_2{i} * y}\\n/// x^y = \\\\frac{1}{w}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2} and {mul}.\\n/// - Returns `UNIT` for 0^0.\\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\\n///\\n/// @param x The base as a UD60x18 number.\\n/// @param y The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n\\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\\n if (xUint == 0) {\\n return yUint == 0 ? UNIT : ZERO;\\n }\\n // If x is `UNIT`, the result is always `UNIT`.\\n else if (xUint == uUNIT) {\\n return UNIT;\\n }\\n\\n // If y is zero, the result is always `UNIT`.\\n if (yUint == 0) {\\n return UNIT;\\n }\\n // If y is `UNIT`, the result is always x.\\n else if (yUint == uUNIT) {\\n return x;\\n }\\n\\n // If x is greater than `UNIT`, use the standard formula.\\n if (xUint > uUNIT) {\\n result = exp2(mul(log2(x), y));\\n }\\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\\n else {\\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\\n UD60x18 w = exp2(mul(log2(i), y));\\n result = wrap(uUNIT_SQUARED / w.unwrap());\\n }\\n}\\n\\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\\n/// algorithm \\\"exponentiation by squaring\\\".\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - The result must fit in UD60x18.\\n///\\n/// @param x The base as a UD60x18 number.\\n/// @param y The exponent as a uint256.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\\n // Calculate the first iteration of the loop in advance.\\n uint256 xUint = x.unwrap();\\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\\n\\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\\n for (y >>= 1; y > 0; y >>= 1) {\\n xUint = Common.mulDiv18(xUint, xUint);\\n\\n // Equivalent to `y % 2 == 1`.\\n if (y & 1 > 0) {\\n resultUint = Common.mulDiv18(resultUint, xUint);\\n }\\n }\\n result = wrap(resultUint);\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must be less than `MAX_UD60x18 / UNIT`.\\n///\\n/// @param x The UD60x18 number for which to calculate the square root.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n unchecked {\\n if (xUint > uMAX_UD60x18 / uUNIT) {\\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\\n }\\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\\n // In this case, the two numbers are both the square root.\\n result = wrap(Common.sqrt(xUint * uUNIT));\\n }\\n}\\n\",\"keccak256\":\"0x462144667aac3f96d5f8dba7aa68fe4c5a3f61e1d7bbbc81bee21168817f9c09\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\nimport \\\"./Helpers.sol\\\" as Helpers;\\nimport \\\"./Math.sol\\\" as Math;\\n\\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\\n/// @dev The value type is defined here so it can be imported in all other files.\\ntype UD60x18 is uint256;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD1x18,\\n Casting.intoUD2x18,\\n Casting.intoSD59x18,\\n Casting.intoUint128,\\n Casting.intoUint256,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes the functions in this library callable on the UD60x18 type.\\nusing {\\n Math.avg,\\n Math.ceil,\\n Math.div,\\n Math.exp,\\n Math.exp2,\\n Math.floor,\\n Math.frac,\\n Math.gm,\\n Math.inv,\\n Math.ln,\\n Math.log10,\\n Math.log2,\\n Math.mul,\\n Math.pow,\\n Math.powu,\\n Math.sqrt\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n HELPER FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes the functions in this library callable on the UD60x18 type.\\nusing {\\n Helpers.add,\\n Helpers.and,\\n Helpers.eq,\\n Helpers.gt,\\n Helpers.gte,\\n Helpers.isZero,\\n Helpers.lshift,\\n Helpers.lt,\\n Helpers.lte,\\n Helpers.mod,\\n Helpers.neq,\\n Helpers.not,\\n Helpers.or,\\n Helpers.rshift,\\n Helpers.sub,\\n Helpers.uncheckedAdd,\\n Helpers.uncheckedSub,\\n Helpers.xor\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n OPERATORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes it possible to use these operators on the UD60x18 type.\\nusing {\\n Helpers.add as +,\\n Helpers.and2 as &,\\n Math.div as /,\\n Helpers.eq as ==,\\n Helpers.gt as >,\\n Helpers.gte as >=,\\n Helpers.lt as <,\\n Helpers.lte as <=,\\n Helpers.or as |,\\n Helpers.mod as %,\\n Math.mul as *,\\n Helpers.neq as !=,\\n Helpers.not as ~,\\n Helpers.sub as -,\\n Helpers.xor as ^\\n} for UD60x18 global;\\n\",\"keccak256\":\"0xdd873b5124180d9b71498b3a7fe93b1c08c368bec741f7d5f8e17f78a0b70f31\",\"license\":\"MIT\"},\"contracts/DecentSablierStreamManagement.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.28;\\n\\nimport {Enum} from \\\"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\\\";\\nimport {IAvatar} from \\\"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\\\";\\nimport {ISablierV2Lockup} from \\\"./interfaces/sablier/full/ISablierV2Lockup.sol\\\";\\nimport {Lockup} from \\\"./interfaces/sablier/full/types/DataTypes.sol\\\";\\n\\ncontract DecentSablierStreamManagement {\\n string public constant NAME = \\\"DecentSablierStreamManagement\\\";\\n\\n function withdrawMaxFromStream(\\n ISablierV2Lockup sablier,\\n address recipientHatAccount,\\n uint256 streamId,\\n address to\\n ) public {\\n // Check if there are funds to withdraw\\n uint128 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\\n if (withdrawableAmount == 0) {\\n return;\\n }\\n\\n // Proxy the Sablier withdrawMax call through IAvatar (Safe)\\n IAvatar(msg.sender).execTransactionFromModule(\\n recipientHatAccount,\\n 0,\\n abi.encodeWithSignature(\\n \\\"execute(address,uint256,bytes,uint8)\\\",\\n address(sablier),\\n 0,\\n abi.encodeWithSignature(\\n \\\"withdrawMax(uint256,address)\\\",\\n streamId,\\n to\\n ),\\n 0\\n ),\\n Enum.Operation.Call\\n );\\n }\\n\\n function cancelStream(ISablierV2Lockup sablier, uint256 streamId) public {\\n // Check if the stream can be cancelled\\n Lockup.Status streamStatus = sablier.statusOf(streamId);\\n if (\\n streamStatus != Lockup.Status.PENDING &&\\n streamStatus != Lockup.Status.STREAMING\\n ) {\\n return;\\n }\\n\\n IAvatar(msg.sender).execTransactionFromModule(\\n address(sablier),\\n 0,\\n abi.encodeWithSignature(\\\"cancel(uint256)\\\", streamId),\\n Enum.Operation.Call\\n );\\n }\\n}\\n\",\"keccak256\":\"0xf36be7e97936d82de0035b8bda2c53dbc52b9ca3b8efe305540a7632cb6fe6ab\",\"license\":\"MIT\"},\"contracts/interfaces/sablier/full/IAdminable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\n/// @title IAdminable\\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\\n/// in the constructor.\\ninterface IAdminable {\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin is transferred.\\n /// @param oldAdmin The address of the old admin.\\n /// @param newAdmin The address of the new admin.\\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice The address of the admin account or contract.\\n function admin() external view returns (address);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Transfers the contract admin to a new address.\\n ///\\n /// @dev Notes:\\n /// - Does not revert if the admin is the same.\\n /// - This function can potentially leave the contract without an admin, thereby removing any\\n /// functionality that is only available to the admin.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newAdmin The address of the new admin.\\n function transferAdmin(address newAdmin) external;\\n}\\n\",\"keccak256\":\"0xa279c49e51228b571329164e36250e82b2c1378e8b549194ab7dd90fca9c3b2b\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/IERC4096.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4906.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC165} from \\\"@openzeppelin/contracts/interfaces/IERC165.sol\\\";\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\n/// @title ERC-721 Metadata Update Extension\\ninterface IERC4906 is IERC165, IERC721 {\\n /// @dev This event emits when the metadata of a token is changed.\\n /// So that the third-party platforms such as NFT market could\\n /// timely update the images and related attributes of the NFT.\\n event MetadataUpdate(uint256 _tokenId);\\n\\n /// @dev This event emits when the metadata of a range of tokens is changed.\\n /// So that the third-party platforms such as NFT market could\\n /// timely update the images and related attributes of the NFTs.\\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\\n}\\n\",\"keccak256\":\"0xa34b9c52cbe36be860244f52256f1b05badf0cb797d208664b87337610d0e82d\",\"license\":\"MIT\"},\"contracts/interfaces/sablier/full/ISablierV2Lockup.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC4906} from \\\"./IERC4096.sol\\\";\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {IERC721Metadata} from \\\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\\\";\\nimport {UD60x18} from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\nimport {Lockup} from \\\"./types/DataTypes.sol\\\";\\nimport {IAdminable} from \\\"./IAdminable.sol\\\";\\nimport {ISablierV2NFTDescriptor} from \\\"./ISablierV2NFTDescriptor.sol\\\";\\n\\n/// @title ISablierV2Lockup\\n/// @notice Common logic between all Sablier V2 Lockup contracts.\\ninterface ISablierV2Lockup is\\n IAdminable, // 0 inherited components\\n IERC4906, // 2 inherited components\\n IERC721Metadata // 2 inherited components\\n{\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin allows a new recipient contract to hook to Sablier.\\n /// @param admin The address of the current contract admin.\\n /// @param recipient The address of the recipient contract put on the allowlist.\\n event AllowToHook(address indexed admin, address recipient);\\n\\n /// @notice Emitted when a stream is canceled.\\n /// @param streamId The ID of the stream.\\n /// @param sender The address of the stream's sender.\\n /// @param recipient The address of the stream's recipient.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\\n /// decimals.\\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\\n /// asset's decimals.\\n event CancelLockupStream(\\n uint256 streamId,\\n address indexed sender,\\n address indexed recipient,\\n IERC20 indexed asset,\\n uint128 senderAmount,\\n uint128 recipientAmount\\n );\\n\\n /// @notice Emitted when a sender gives up the right to cancel a stream.\\n /// @param streamId The ID of the stream.\\n event RenounceLockupStream(uint256 indexed streamId);\\n\\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\\n /// @param admin The address of the current contract admin.\\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\\n event SetNFTDescriptor(\\n address indexed admin,\\n ISablierV2NFTDescriptor oldNFTDescriptor,\\n ISablierV2NFTDescriptor newNFTDescriptor\\n );\\n\\n /// @notice Emitted when assets are withdrawn from a stream.\\n /// @param streamId The ID of the stream.\\n /// @param to The address that has received the withdrawn assets.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\\n event WithdrawFromLockupStream(\\n uint256 indexed streamId,\\n address indexed to,\\n IERC20 indexed asset,\\n uint128 amount\\n );\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Retrieves the address of the ERC-20 asset to be distributed.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\\n\\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getDepositedAmount(\\n uint256 streamId\\n ) external view returns (uint128 depositedAmount);\\n\\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getEndTime(\\n uint256 streamId\\n ) external view returns (uint40 endTime);\\n\\n /// @notice Retrieves the stream's recipient.\\n /// @dev Reverts if the NFT has been burned.\\n /// @param streamId The stream ID for the query.\\n function getRecipient(\\n uint256 streamId\\n ) external view returns (address recipient);\\n\\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\\n /// decimals. This amount is always zero unless the stream was canceled.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getRefundedAmount(\\n uint256 streamId\\n ) external view returns (uint128 refundedAmount);\\n\\n /// @notice Retrieves the stream's sender.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getSender(uint256 streamId) external view returns (address sender);\\n\\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getStartTime(\\n uint256 streamId\\n ) external view returns (uint40 startTime);\\n\\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function getWithdrawnAmount(\\n uint256 streamId\\n ) external view returns (uint128 withdrawnAmount);\\n\\n /// @notice Retrieves a flag indicating whether the provided address is a contract allowed to hook to Sablier\\n /// when a stream is canceled or when assets are withdrawn.\\n /// @dev See {ISablierLockupRecipient} for more information.\\n function isAllowedToHook(\\n address recipient\\n ) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\\n /// flag is always `false`.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isCancelable(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isCold(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is depleted.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isDepleted(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream exists.\\n /// @dev Does not revert if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isStream(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isTransferable(\\n uint256 streamId\\n ) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function isWarm(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves the maximum broker fee that can be charged by the broker, denoted as a fixed-point\\n /// number where 1e18 is 100%.\\n /// @dev This value is hard coded as a constant.\\n function MAX_BROKER_FEE() external view returns (UD60x18);\\n\\n /// @notice Counter for stream IDs, used in the create functions.\\n function nextStreamId() external view returns (uint256);\\n\\n /// @notice Contract that generates the non-fungible token URI.\\n function nftDescriptor() external view returns (ISablierV2NFTDescriptor);\\n\\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\\n /// of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function refundableAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 refundableAmount);\\n\\n /// @notice Retrieves the stream's status.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function statusOf(\\n uint256 streamId\\n ) external view returns (Lockup.Status status);\\n\\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n ///\\n /// Notes:\\n /// - Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\\n /// to the total amount withdrawn.\\n ///\\n /// @param streamId The stream ID for the query.\\n function streamedAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 streamedAmount);\\n\\n /// @notice Retrieves a flag indicating whether the stream was canceled.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function wasCanceled(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\\n /// decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream ID for the query.\\n function withdrawableAmountOf(\\n uint256 streamId\\n ) external view returns (uint128 withdrawableAmount);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Allows a recipient contract to hook to Sablier when a stream is canceled or when assets are withdrawn.\\n /// Useful for implementing contracts that hold streams on behalf of users, such as vaults or staking contracts.\\n ///\\n /// @dev Emits an {AllowToHook} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the contract is already on the allowlist.\\n /// - This is an irreversible operation. The contract cannot be removed from the allowlist.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n /// - `recipient` must have a non-zero code size.\\n /// - `recipient` must implement {ISablierLockupRecipient}.\\n ///\\n /// @param recipient The address of the contract to allow for hooks.\\n function allowToHook(address recipient) external;\\n\\n /// @notice Burns the NFT associated with the stream.\\n ///\\n /// @dev Emits a {Transfer} event.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must reference a depleted stream.\\n /// - The NFT must exist.\\n /// - `msg.sender` must be either the NFT owner or an approved third party.\\n ///\\n /// @param streamId The ID of the stream NFT to burn.\\n function burn(uint256 streamId) external;\\n\\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\\n ///\\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\\n /// stream is marked as depleted.\\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - The stream must be warm and cancelable.\\n /// - `msg.sender` must be the stream's sender.\\n ///\\n /// @param streamId The ID of the stream to cancel.\\n function cancel(uint256 streamId) external;\\n\\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\\n ///\\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\\n ///\\n /// Notes:\\n /// - Refer to the notes in {cancel}.\\n ///\\n /// Requirements:\\n /// - All requirements from {cancel} must be met for each stream.\\n ///\\n /// @param streamIds The IDs of the streams to cancel.\\n function cancelMultiple(uint256[] calldata streamIds) external;\\n\\n /// @notice Removes the right of the stream's sender to cancel the stream.\\n ///\\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - This is an irreversible operation.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must reference a warm stream.\\n /// - `msg.sender` must be the stream's sender.\\n /// - The stream must be cancelable.\\n ///\\n /// @param streamId The ID of the stream to renounce.\\n function renounce(uint256 streamId) external;\\n\\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\\n ///\\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the NFT descriptor is the same.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\\n function setNFTDescriptor(\\n ISablierV2NFTDescriptor newNFTDescriptor\\n ) external;\\n\\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\\n ///\\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - This function attempts to call a hook on the recipient of the stream, unless `msg.sender` is the recipient.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must not reference a null or depleted stream.\\n /// - `to` must not be the zero address.\\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\\n /// - `to` must be the recipient if `msg.sender` is not the stream's recipient or an approved third party.\\n ///\\n /// @param streamId The ID of the stream to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\\n function withdraw(uint256 streamId, address to, uint128 amount) external;\\n\\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\\n ///\\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - Refer to the notes in {withdraw}.\\n ///\\n /// Requirements:\\n /// - Refer to the requirements in {withdraw}.\\n ///\\n /// @param streamId The ID of the stream to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\\n function withdrawMax(\\n uint256 streamId,\\n address to\\n ) external returns (uint128 withdrawnAmount);\\n\\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\\n /// NFT to `newRecipient`.\\n ///\\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\\n ///\\n /// Notes:\\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\\n /// - Refer to the notes in {withdraw}.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the stream's recipient.\\n /// - Refer to the requirements in {withdraw}.\\n /// - Refer to the requirements in {IERC721.transferFrom}.\\n ///\\n /// @param streamId The ID of the stream NFT to transfer.\\n /// @param newRecipient The address of the new owner of the stream NFT.\\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\\n function withdrawMaxAndTransfer(\\n uint256 streamId,\\n address newRecipient\\n ) external returns (uint128 withdrawnAmount);\\n\\n /// @notice Withdraws assets from streams to the recipient of each stream.\\n ///\\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\\n ///\\n /// Notes:\\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - There must be an equal number of `streamIds` and `amounts`.\\n /// - Each stream ID in the array must not reference a null or depleted stream.\\n /// - Each amount in the array must be greater than zero and must not exceed the withdrawable amount.\\n ///\\n /// @param streamIds The IDs of the streams to withdraw from.\\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\\n function withdrawMultiple(\\n uint256[] calldata streamIds,\\n uint128[] calldata amounts\\n ) external;\\n}\\n\",\"keccak256\":\"0x3e5541c38a901637bd310965deb5bbde73ef07fe4ee3c752cbec330c6b9d62a3\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/ISablierV2NFTDescriptor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC721Metadata} from \\\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\\\";\\n\\n/// @title ISablierV2NFTDescriptor\\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\\n/// @dev Inspired by Uniswap V3 Positions NFTs.\\ninterface ISablierV2NFTDescriptor {\\n /// @notice Produces the URI describing a particular stream NFT.\\n /// @dev This is a data URI with the JSON contents directly inlined.\\n /// @param sablier The address of the Sablier contract the stream was created in.\\n /// @param streamId The ID of the stream for which to produce a description.\\n /// @return uri The URI of the ERC721-compliant metadata.\\n function tokenURI(\\n IERC721Metadata sablier,\\n uint256 streamId\\n ) external view returns (string memory uri);\\n}\\n\",\"keccak256\":\"0x4ed430e553d14161e93efdaaacd1a502f49b38969c9d714b45d2e682a74fa0bc\",\"license\":\"GPL-3.0-or-later\"},\"contracts/interfaces/sablier/full/types/DataTypes.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.22;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {UD2x18} from \\\"@prb/math/src/UD2x18.sol\\\";\\nimport {UD60x18} from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\n// DataTypes.sol\\n//\\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\\n//\\n// - Lockup\\n// - LockupDynamic\\n// - LockupLinear\\n// - LockupTranched\\n//\\n// You will notice that some structs contain \\\"slot\\\" annotations - they are used to indicate the\\n// storage layout of the struct. It is more gas efficient to group small data types together so\\n// that they fit in a single 32-byte slot.\\n\\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\\n/// @param account The address receiving the broker's fee.\\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\\nstruct Broker {\\n address account;\\n UD60x18 fee;\\n}\\n\\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\\nlibrary Lockup {\\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the asset's\\n /// decimals.\\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in the same slot\\n /// saves gas.\\n /// @param deposited The initial amount deposited in the stream, net of broker fee.\\n /// @param withdrawn The cumulative amount withdrawn from the stream.\\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\\n struct Amounts {\\n // slot 0\\n uint128 deposited;\\n uint128 withdrawn;\\n // slot 1\\n uint128 refunded;\\n }\\n\\n /// @notice Struct encapsulating (i) the deposit amount and (ii) the broker fee amount, both denoted in units of the\\n /// asset's decimals.\\n /// @param deposit The amount to deposit in the stream.\\n /// @param brokerFee The broker fee amount.\\n struct CreateAmounts {\\n uint128 deposit;\\n uint128 brokerFee;\\n }\\n\\n /// @notice Enum representing the different statuses of a stream.\\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\\n enum Status {\\n PENDING,\\n STREAMING,\\n SETTLED,\\n CANCELED,\\n DEPLETED\\n }\\n\\n /// @notice A common data structure to be stored in all {SablierV2Lockup} models.\\n /// @dev The fields are arranged like this to save gas via tight variable packing.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param endTime The Unix timestamp indicating the stream's end.\\n /// @param isCancelable Boolean indicating if the stream is cancelable.\\n /// @param wasCanceled Boolean indicating if the stream was canceled.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param isDepleted Boolean indicating if the stream is depleted.\\n /// @param isStream Boolean indicating if the struct entity exists.\\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\\n /// @param amounts Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the\\n /// asset's decimals.\\n struct Stream {\\n // slot 0\\n address sender;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n // slot 1\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n // slot 2 and 3\\n Lockup.Amounts amounts;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\\nlibrary LockupDynamic {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param segments Segments with durations used to compose the dynamic distribution function. Timestamps are\\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n SegmentWithDuration[] segments;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param segments Segments used to compose the dynamic distribution function.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n uint40 startTime;\\n Segment[] segments;\\n Broker broker;\\n }\\n\\n /// @notice Segment struct used in the Lockup Dynamic stream.\\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\\n /// @param timestamp The Unix timestamp indicating the segment's end.\\n struct Segment {\\n // slot 0\\n uint128 amount;\\n UD2x18 exponent;\\n uint40 timestamp;\\n }\\n\\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDurations}.\\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\\n /// @param duration The time difference in seconds between the segment and the previous one.\\n struct SegmentWithDuration {\\n uint128 amount;\\n UD2x18 exponent;\\n uint40 duration;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the segments.\\n struct StreamLD {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n Segment[] segments;\\n }\\n\\n /// @notice Struct encapsulating the LockupDynamic timestamps.\\n /// @param start The Unix timestamp indicating the stream's start.\\n /// @param end The Unix timestamp indicating the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 end;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\\nlibrary LockupLinear {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param durations Struct encapsulating (i) cliff period duration and (ii) total stream duration, both in seconds.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n Durations durations;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param timestamps Struct encapsulating (i) the stream's start time, (ii) cliff time, and (iii) end time, all as\\n /// Unix timestamps.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n Timestamps timestamps;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the cliff duration and the total duration.\\n /// @param cliff The cliff duration in seconds.\\n /// @param total The total duration in seconds.\\n struct Durations {\\n uint40 cliff;\\n uint40 total;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the cliff time.\\n struct StreamLL {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n uint40 endTime;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n uint40 cliffTime;\\n }\\n\\n /// @notice Struct encapsulating the LockupLinear timestamps.\\n /// @param start The Unix timestamp for the stream's start.\\n /// @param cliff The Unix timestamp for the cliff period's end. A value of zero means there is no cliff.\\n /// @param end The Unix timestamp for the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 cliff;\\n uint40 end;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupTranched}.\\nlibrary LockupTranched {\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithDurations} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param tranches Tranches with durations used to compose the tranched distribution function. Timestamps are\\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n TrancheWithDuration[] tranches;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithTimestamps} function.\\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\\n /// the same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\\n /// broker fee, denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset to be distributed.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param tranches Tranches used to compose the tranched distribution function.\\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithTimestamps {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n uint40 startTime;\\n Tranche[] tranches;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the full details of a stream.\\n /// @dev Extends `Lockup.Stream` by including the recipient and the tranches.\\n struct StreamLT {\\n address sender;\\n address recipient;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n Lockup.Amounts amounts;\\n Tranche[] tranches;\\n }\\n\\n /// @notice Struct encapsulating the LockupTranched timestamps.\\n /// @param start The Unix timestamp indicating the stream's start.\\n /// @param end The Unix timestamp indicating the stream's end.\\n struct Timestamps {\\n uint40 start;\\n uint40 end;\\n }\\n\\n /// @notice Tranche struct used in the Lockup Tranched stream.\\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\\n /// @param timestamp The Unix timestamp indicating the tranche's end.\\n struct Tranche {\\n // slot 0\\n uint128 amount;\\n uint40 timestamp;\\n }\\n\\n /// @notice Tranche struct used at runtime in {SablierV2LockupTranched.createWithDurations}.\\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\\n /// @param duration The time difference in seconds between the tranche and the previous one.\\n struct TrancheWithDuration {\\n uint128 amount;\\n uint40 duration;\\n }\\n}\\n\",\"keccak256\":\"0x727722c0ec71a76a947b935c9dfcac8fd846d6c3547dfbc8739c7109f3b95068\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", + "bytecode": "0x6080604052348015600f57600080fd5b506105fe8061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80636778d4b0146100465780637dc14a8e1461005b578063a3f4df7e1461006e575b600080fd5b6100596100543660046103d0565b6100c0565b005b610059610069366004610423565b610256565b6100aa6040518060400160405280601d81526020017f446563656e745361626c69657253747265616d4d616e6167656d656e7400000081525081565b6040516100b79190610495565b60405180910390f35b60405163d975dfed60e01b8152600481018390526000906001600160a01b0386169063d975dfed90602401602060405180830381865afa158015610108573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012c91906104af565b9050806001600160801b03166000036101455750610250565b336001600160a01b031663468721a7856000886000888860405160240161017f9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529181526020820180516001600160e01b031663ea5ead1960e01b179052516101bc939291906000906024016104d8565b60408051601f198184030181529181526020820180516001600160e01b0316635194544760e01b1790525160e085901b6001600160e01b031916815261020a9392919060009060040161052f565b6020604051808303816000875af1158015610229573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024d9190610585565b50505b50505050565b604051632b4d7bf560e21b8152600481018290526000906001600160a01b0384169063ad35efd490602401602060405180830381865afa15801561029e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c291906105a7565b905060008160048111156102d8576102d8610519565b141580156102f8575060018160048111156102f5576102f5610519565b14155b1561030257505050565b336001600160a01b031663468721a78460008560405160240161032791815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166340e58ee560e01b1790525160e085901b6001600160e01b03191681526103759392919060009060040161052f565b6020604051808303816000875af1158015610394573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102509190610585565b6001600160a01b03811681146103cd57600080fd5b50565b600080600080608085870312156103e657600080fd5b84356103f1816103b8565b93506020850135610401816103b8565b9250604085013591506060850135610418816103b8565b939692955090935050565b6000806040838503121561043657600080fd5b8235610441816103b8565b946020939093013593505050565b6000815180845260005b8181101561047557602081850181015186830182015201610459565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006104a8602083018461044f565b9392505050565b6000602082840312156104c157600080fd5b81516001600160801b03811681146104a857600080fd5b6001600160a01b038516815260ff841660208201526080604082018190526000906105059083018561044f565b905060ff8316606083015295945050505050565b634e487b7160e01b600052602160045260246000fd5b60018060a01b0385168152836020820152608060408201526000610556608083018561044f565b90506002831061057657634e487b7160e01b600052602160045260246000fd5b82606083015295945050505050565b60006020828403121561059757600080fd5b815180151581146104a857600080fd5b6000602082840312156105b957600080fd5b8151600581106104a857600080fdfea2646970667358221220c473750d62fe01ec9f421a499df8738e767b4a5341626c81a992fcdb3ee192de64736f6c634300081c0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80636778d4b0146100465780637dc14a8e1461005b578063a3f4df7e1461006e575b600080fd5b6100596100543660046103d0565b6100c0565b005b610059610069366004610423565b610256565b6100aa6040518060400160405280601d81526020017f446563656e745361626c69657253747265616d4d616e6167656d656e7400000081525081565b6040516100b79190610495565b60405180910390f35b60405163d975dfed60e01b8152600481018390526000906001600160a01b0386169063d975dfed90602401602060405180830381865afa158015610108573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012c91906104af565b9050806001600160801b03166000036101455750610250565b336001600160a01b031663468721a7856000886000888860405160240161017f9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529181526020820180516001600160e01b031663ea5ead1960e01b179052516101bc939291906000906024016104d8565b60408051601f198184030181529181526020820180516001600160e01b0316635194544760e01b1790525160e085901b6001600160e01b031916815261020a9392919060009060040161052f565b6020604051808303816000875af1158015610229573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024d9190610585565b50505b50505050565b604051632b4d7bf560e21b8152600481018290526000906001600160a01b0384169063ad35efd490602401602060405180830381865afa15801561029e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c291906105a7565b905060008160048111156102d8576102d8610519565b141580156102f8575060018160048111156102f5576102f5610519565b14155b1561030257505050565b336001600160a01b031663468721a78460008560405160240161032791815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166340e58ee560e01b1790525160e085901b6001600160e01b03191681526103759392919060009060040161052f565b6020604051808303816000875af1158015610394573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102509190610585565b6001600160a01b03811681146103cd57600080fd5b50565b600080600080608085870312156103e657600080fd5b84356103f1816103b8565b93506020850135610401816103b8565b9250604085013591506060850135610418816103b8565b939692955090935050565b6000806040838503121561043657600080fd5b8235610441816103b8565b946020939093013593505050565b6000815180845260005b8181101561047557602081850181015186830182015201610459565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006104a8602083018461044f565b9392505050565b6000602082840312156104c157600080fd5b81516001600160801b03811681146104a857600080fd5b6001600160a01b038516815260ff841660208201526080604082018190526000906105059083018561044f565b905060ff8316606083015295945050505050565b634e487b7160e01b600052602160045260246000fd5b60018060a01b0385168152836020820152608060408201526000610556608083018561044f565b90506002831061057657634e487b7160e01b600052602160045260246000fd5b82606083015295945050505050565b60006020828403121561059757600080fd5b815180151581146104a857600080fd5b6000602082840312156105b957600080fd5b8151600581106104a857600080fdfea2646970667358221220c473750d62fe01ec9f421a499df8738e767b4a5341626c81a992fcdb3ee192de64736f6c634300081c0033", + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/deployments/polygon/solcInputs/4511b61209438ca20d2458493e70bb24.json b/deployments/polygon/solcInputs/4511b61209438ca20d2458493e70bb24.json new file mode 100644 index 00000000..c068a9c4 --- /dev/null +++ b/deployments/polygon/solcInputs/4511b61209438ca20d2458493e70bb24.json @@ -0,0 +1,351 @@ +{ + "language": "Solidity", + "sources": { + "@gnosis.pm/safe-contracts/contracts/base/Executor.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\n\n/// @title Executor - A contract that can execute transactions\n/// @author Richard Meissner - \ncontract Executor {\n function execute(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 txGas\n ) internal returns (bool success) {\n if (operation == Enum.Operation.DelegateCall) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n success := delegatecall(txGas, to, add(data, 0x20), mload(data), 0, 0)\n }\n } else {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n success := call(txGas, to, value, add(data, 0x20), mload(data), 0, 0)\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/FallbackManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../common/SelfAuthorized.sol\";\n\n/// @title Fallback Manager - A contract that manages fallback calls made to this contract\n/// @author Richard Meissner - \ncontract FallbackManager is SelfAuthorized {\n event ChangedFallbackHandler(address handler);\n\n // keccak256(\"fallback_manager.handler.address\")\n bytes32 internal constant FALLBACK_HANDLER_STORAGE_SLOT = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5;\n\n function internalSetFallbackHandler(address handler) internal {\n bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, handler)\n }\n }\n\n /// @dev Allows to add a contract to handle fallback calls.\n /// Only fallback calls without value and with data will be forwarded.\n /// This can only be done via a Safe transaction.\n /// @param handler contract to handle fallbacks calls.\n function setFallbackHandler(address handler) public authorized {\n internalSetFallbackHandler(handler);\n emit ChangedFallbackHandler(handler);\n }\n\n // solhint-disable-next-line payable-fallback,no-complex-fallback\n fallback() external {\n bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let handler := sload(slot)\n if iszero(handler) {\n return(0, 0)\n }\n calldatacopy(0, 0, calldatasize())\n // The msg.sender address is shifted to the left by 12 bytes to remove the padding\n // Then the address without padding is stored right after the calldata\n mstore(calldatasize(), shl(96, caller()))\n // Add 20 bytes for the address appended add the end\n let success := call(gas(), handler, 0, 0, add(calldatasize(), 20), 0, 0)\n returndatacopy(0, 0, returndatasize())\n if iszero(success) {\n revert(0, returndatasize())\n }\n return(0, returndatasize())\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/GuardManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\n\ninterface Guard {\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external;\n\n function checkAfterExecution(bytes32 txHash, bool success) external;\n}\n\n/// @title Fallback Manager - A contract that manages fallback calls made to this contract\n/// @author Richard Meissner - \ncontract GuardManager is SelfAuthorized {\n event ChangedGuard(address guard);\n // keccak256(\"guard_manager.guard.address\")\n bytes32 internal constant GUARD_STORAGE_SLOT = 0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8;\n\n /// @dev Set a guard that checks transactions before execution\n /// @param guard The address of the guard to be used or the 0 address to disable the guard\n function setGuard(address guard) external authorized {\n bytes32 slot = GUARD_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, guard)\n }\n emit ChangedGuard(guard);\n }\n\n function getGuard() internal view returns (address guard) {\n bytes32 slot = GUARD_STORAGE_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n guard := sload(slot)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/ModuleManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\nimport \"./Executor.sol\";\n\n/// @title Module Manager - A contract that manages modules that can execute transactions via this contract\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract ModuleManager is SelfAuthorized, Executor {\n event EnabledModule(address module);\n event DisabledModule(address module);\n event ExecutionFromModuleSuccess(address indexed module);\n event ExecutionFromModuleFailure(address indexed module);\n\n address internal constant SENTINEL_MODULES = address(0x1);\n\n mapping(address => address) internal modules;\n\n function setupModules(address to, bytes memory data) internal {\n require(modules[SENTINEL_MODULES] == address(0), \"GS100\");\n modules[SENTINEL_MODULES] = SENTINEL_MODULES;\n if (to != address(0))\n // Setup has to complete successfully or transaction fails.\n require(execute(to, 0, data, Enum.Operation.DelegateCall, gasleft()), \"GS000\");\n }\n\n /// @dev Allows to add a module to the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Enables the module `module` for the Safe.\n /// @param module Module to be whitelisted.\n function enableModule(address module) public authorized {\n // Module address cannot be null or sentinel.\n require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n // Module cannot be added twice.\n require(modules[module] == address(0), \"GS102\");\n modules[module] = modules[SENTINEL_MODULES];\n modules[SENTINEL_MODULES] = module;\n emit EnabledModule(module);\n }\n\n /// @dev Allows to remove a module from the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Disables the module `module` for the Safe.\n /// @param prevModule Module that pointed to the module to be removed in the linked list\n /// @param module Module to be removed.\n function disableModule(address prevModule, address module) public authorized {\n // Validate module address and check that it corresponds to module index.\n require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n require(modules[prevModule] == module, \"GS103\");\n modules[prevModule] = modules[module];\n modules[module] = address(0);\n emit DisabledModule(module);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public virtual returns (bool success) {\n // Only whitelisted modules are allowed.\n require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), \"GS104\");\n // Execute transaction without further confirmations.\n success = execute(to, value, data, operation, gasleft());\n if (success) emit ExecutionFromModuleSuccess(msg.sender);\n else emit ExecutionFromModuleFailure(msg.sender);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModuleReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public returns (bool success, bytes memory returnData) {\n success = execTransactionFromModule(to, value, data, operation);\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // Load free memory location\n let ptr := mload(0x40)\n // We allocate memory for the return data by setting the free memory location to\n // current free memory location + data size + 32 bytes for data size value\n mstore(0x40, add(ptr, add(returndatasize(), 0x20)))\n // Store the size\n mstore(ptr, returndatasize())\n // Store the data\n returndatacopy(add(ptr, 0x20), 0, returndatasize())\n // Point the return data to the correct memory location\n returnData := ptr\n }\n }\n\n /// @dev Returns if an module is enabled\n /// @return True if the module is enabled\n function isModuleEnabled(address module) public view returns (bool) {\n return SENTINEL_MODULES != module && modules[module] != address(0);\n }\n\n /// @dev Returns array of modules.\n /// @param start Start of the page.\n /// @param pageSize Maximum number of modules that should be returned.\n /// @return array Array of modules.\n /// @return next Start of the next page.\n function getModulesPaginated(address start, uint256 pageSize) external view returns (address[] memory array, address next) {\n // Init array with max page size\n array = new address[](pageSize);\n\n // Populate return array\n uint256 moduleCount = 0;\n address currentModule = modules[start];\n while (currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {\n array[moduleCount] = currentModule;\n currentModule = modules[currentModule];\n moduleCount++;\n }\n next = currentModule;\n // Set correct size of returned array\n // solhint-disable-next-line no-inline-assembly\n assembly {\n mstore(array, moduleCount)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/base/OwnerManager.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/SelfAuthorized.sol\";\n\n/// @title OwnerManager - Manages a set of owners and a threshold to perform actions.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract OwnerManager is SelfAuthorized {\n event AddedOwner(address owner);\n event RemovedOwner(address owner);\n event ChangedThreshold(uint256 threshold);\n\n address internal constant SENTINEL_OWNERS = address(0x1);\n\n mapping(address => address) internal owners;\n uint256 internal ownerCount;\n uint256 internal threshold;\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n function setupOwners(address[] memory _owners, uint256 _threshold) internal {\n // Threshold can only be 0 at initialization.\n // Check ensures that setup function can only be called once.\n require(threshold == 0, \"GS200\");\n // Validate that threshold is smaller than number of added owners.\n require(_threshold <= _owners.length, \"GS201\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"GS202\");\n // Initializing Safe owners.\n address currentOwner = SENTINEL_OWNERS;\n for (uint256 i = 0; i < _owners.length; i++) {\n // Owner address cannot be null.\n address owner = _owners[i];\n require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, \"GS203\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"GS204\");\n owners[currentOwner] = owner;\n currentOwner = owner;\n }\n owners[currentOwner] = SENTINEL_OWNERS;\n ownerCount = _owners.length;\n threshold = _threshold;\n }\n\n /// @dev Allows to add a new owner to the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.\n /// @param owner New owner address.\n /// @param _threshold New threshold.\n function addOwnerWithThreshold(address owner, uint256 _threshold) public authorized {\n // Owner address cannot be null, the sentinel or the Safe itself.\n require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), \"GS203\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"GS204\");\n owners[owner] = owners[SENTINEL_OWNERS];\n owners[SENTINEL_OWNERS] = owner;\n ownerCount++;\n emit AddedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold) changeThreshold(_threshold);\n }\n\n /// @dev Allows to remove an owner from the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.\n /// @param prevOwner Owner that pointed to the owner to be removed in the linked list\n /// @param owner Owner address to be removed.\n /// @param _threshold New threshold.\n function removeOwner(\n address prevOwner,\n address owner,\n uint256 _threshold\n ) public authorized {\n // Only allow to remove an owner, if threshold can still be reached.\n require(ownerCount - 1 >= _threshold, \"GS201\");\n // Validate owner address and check that it corresponds to owner index.\n require(owner != address(0) && owner != SENTINEL_OWNERS, \"GS203\");\n require(owners[prevOwner] == owner, \"GS205\");\n owners[prevOwner] = owners[owner];\n owners[owner] = address(0);\n ownerCount--;\n emit RemovedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold) changeThreshold(_threshold);\n }\n\n /// @dev Allows to swap/replace an owner from the Safe with another address.\n /// This can only be done via a Safe transaction.\n /// @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.\n /// @param prevOwner Owner that pointed to the owner to be replaced in the linked list\n /// @param oldOwner Owner address to be replaced.\n /// @param newOwner New owner address.\n function swapOwner(\n address prevOwner,\n address oldOwner,\n address newOwner\n ) public authorized {\n // Owner address cannot be null, the sentinel or the Safe itself.\n require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), \"GS203\");\n // No duplicate owners allowed.\n require(owners[newOwner] == address(0), \"GS204\");\n // Validate oldOwner address and check that it corresponds to owner index.\n require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, \"GS203\");\n require(owners[prevOwner] == oldOwner, \"GS205\");\n owners[newOwner] = owners[oldOwner];\n owners[prevOwner] = newOwner;\n owners[oldOwner] = address(0);\n emit RemovedOwner(oldOwner);\n emit AddedOwner(newOwner);\n }\n\n /// @dev Allows to update the number of required confirmations by Safe owners.\n /// This can only be done via a Safe transaction.\n /// @notice Changes the threshold of the Safe to `_threshold`.\n /// @param _threshold New threshold.\n function changeThreshold(uint256 _threshold) public authorized {\n // Validate that threshold is smaller than number of owners.\n require(_threshold <= ownerCount, \"GS201\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"GS202\");\n threshold = _threshold;\n emit ChangedThreshold(threshold);\n }\n\n function getThreshold() public view returns (uint256) {\n return threshold;\n }\n\n function isOwner(address owner) public view returns (bool) {\n return owner != SENTINEL_OWNERS && owners[owner] != address(0);\n }\n\n /// @dev Returns array of owners.\n /// @return Array of Safe owners.\n function getOwners() public view returns (address[] memory) {\n address[] memory array = new address[](ownerCount);\n\n // populate return array\n uint256 index = 0;\n address currentOwner = owners[SENTINEL_OWNERS];\n while (currentOwner != SENTINEL_OWNERS) {\n array[index] = currentOwner;\n currentOwner = owners[currentOwner];\n index++;\n }\n return array;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/Enum.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Enum - Collection of enums\n/// @author Richard Meissner - \ncontract Enum {\n enum Operation {Call, DelegateCall}\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/EtherPaymentFallback.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title EtherPaymentFallback - A contract that has a fallback to accept ether payments\n/// @author Richard Meissner - \ncontract EtherPaymentFallback {\n event SafeReceived(address indexed sender, uint256 value);\n\n /// @dev Fallback function accepts Ether transactions.\n receive() external payable {\n emit SafeReceived(msg.sender, msg.value);\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SecuredTokenTransfer.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SecuredTokenTransfer - Secure token transfer\n/// @author Richard Meissner - \ncontract SecuredTokenTransfer {\n /// @dev Transfers a token and returns if it was a success\n /// @param token Token that should be transferred\n /// @param receiver Receiver to whom the token should be transferred\n /// @param amount The amount of tokens that should be transferred\n function transferToken(\n address token,\n address receiver,\n uint256 amount\n ) internal returns (bool transferred) {\n // 0xa9059cbb - keccack(\"transfer(address,uint256)\")\n bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // We write the return value to scratch space.\n // See https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory\n let success := call(sub(gas(), 10000), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n switch returndatasize()\n case 0 {\n transferred := success\n }\n case 0x20 {\n transferred := iszero(or(iszero(success), iszero(mload(0))))\n }\n default {\n transferred := 0\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SelfAuthorized.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SelfAuthorized - authorizes current contract to perform actions\n/// @author Richard Meissner - \ncontract SelfAuthorized {\n function requireSelfCall() private view {\n require(msg.sender == address(this), \"GS031\");\n }\n\n modifier authorized() {\n // This is a function call as it minimized the bytecode size\n requireSelfCall();\n _;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/SignatureDecoder.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title SignatureDecoder - Decodes signatures that a encoded as bytes\n/// @author Richard Meissner - \ncontract SignatureDecoder {\n /// @dev divides bytes signature into `uint8 v, bytes32 r, bytes32 s`.\n /// @notice Make sure to peform a bounds check for @param pos, to avoid out of bounds access on @param signatures\n /// @param pos which signature to read. A prior bounds check of this parameter should be performed, to avoid out of bounds access\n /// @param signatures concatenated rsv signatures\n function signatureSplit(bytes memory signatures, uint256 pos)\n internal\n pure\n returns (\n uint8 v,\n bytes32 r,\n bytes32 s\n )\n {\n // The signature format is a compact form of:\n // {bytes32 r}{bytes32 s}{uint8 v}\n // Compact means, uint8 is not padded to 32 bytes.\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let signaturePos := mul(0x41, pos)\n r := mload(add(signatures, add(signaturePos, 0x20)))\n s := mload(add(signatures, add(signaturePos, 0x40)))\n // Here we are loading the last 32 bytes, including 31 bytes\n // of 's'. There is no 'mload8' to do this.\n //\n // 'byte' is not working due to the Solidity parser, so lets\n // use the second best option, 'and'\n v := and(mload(add(signatures, add(signaturePos, 0x41))), 0xff)\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/Singleton.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Singleton - Base for singleton contracts (should always be first super contract)\n/// This contract is tightly coupled to our proxy contract (see `proxies/GnosisSafeProxy.sol`)\n/// @author Richard Meissner - \ncontract Singleton {\n // singleton always needs to be first declared variable, to ensure that it is at the same location as in the Proxy contract.\n // It should also always be ensured that the address is stored alone (uses a full word)\n address private singleton;\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/common/StorageAccessible.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title StorageAccessible - generic base contract that allows callers to access all internal storage.\n/// @notice See https://github.com/gnosis/util-contracts/blob/bb5fe5fb5df6d8400998094fb1b32a178a47c3a1/contracts/StorageAccessible.sol\ncontract StorageAccessible {\n /**\n * @dev Reads `length` bytes of storage in the currents contract\n * @param offset - the offset in the current contract's storage in words to start reading from\n * @param length - the number of words (32 bytes) of data to read\n * @return the bytes that were read.\n */\n function getStorageAt(uint256 offset, uint256 length) public view returns (bytes memory) {\n bytes memory result = new bytes(length * 32);\n for (uint256 index = 0; index < length; index++) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let word := sload(add(offset, index))\n mstore(add(add(result, 0x20), mul(index, 0x20)), word)\n }\n }\n return result;\n }\n\n /**\n * @dev Performs a delegetecall on a targetContract in the context of self.\n * Internally reverts execution to avoid side effects (making it static).\n *\n * This method reverts with data equal to `abi.encode(bool(success), bytes(response))`.\n * Specifically, the `returndata` after a call to this method will be:\n * `success:bool || response.length:uint256 || response:bytes`.\n *\n * @param targetContract Address of the contract containing the code to execute.\n * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).\n */\n function simulateAndRevert(address targetContract, bytes memory calldataPayload) external {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let success := delegatecall(gas(), targetContract, add(calldataPayload, 0x20), mload(calldataPayload), 0, 0)\n\n mstore(0x00, success)\n mstore(0x20, returndatasize())\n returndatacopy(0x40, 0, returndatasize())\n revert(0, add(returndatasize(), 0x40))\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/external/GnosisSafeMath.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title GnosisSafeMath\n * @dev Math operations with safety checks that revert on error\n * Renamed from SafeMath to GnosisSafeMath to avoid conflicts\n * TODO: remove once open zeppelin update to solc 0.5.0\n */\nlibrary GnosisSafeMath {\n /**\n * @dev Multiplies two numbers, reverts on overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b);\n\n return c;\n }\n\n /**\n * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Adds two numbers, reverts on overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a);\n\n return c;\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 a >= b ? a : b;\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/GnosisSafe.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./base/ModuleManager.sol\";\nimport \"./base/OwnerManager.sol\";\nimport \"./base/FallbackManager.sol\";\nimport \"./base/GuardManager.sol\";\nimport \"./common/EtherPaymentFallback.sol\";\nimport \"./common/Singleton.sol\";\nimport \"./common/SignatureDecoder.sol\";\nimport \"./common/SecuredTokenTransfer.sol\";\nimport \"./common/StorageAccessible.sol\";\nimport \"./interfaces/ISignatureValidator.sol\";\nimport \"./external/GnosisSafeMath.sol\";\n\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafe is\n EtherPaymentFallback,\n Singleton,\n ModuleManager,\n OwnerManager,\n SignatureDecoder,\n SecuredTokenTransfer,\n ISignatureValidatorConstants,\n FallbackManager,\n StorageAccessible,\n GuardManager\n{\n using GnosisSafeMath for uint256;\n\n string public constant VERSION = \"1.3.0\";\n\n // keccak256(\n // \"EIP712Domain(uint256 chainId,address verifyingContract)\"\n // );\n bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;\n\n // keccak256(\n // \"SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)\"\n // );\n bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;\n\n event SafeSetup(address indexed initiator, address[] owners, uint256 threshold, address initializer, address fallbackHandler);\n event ApproveHash(bytes32 indexed approvedHash, address indexed owner);\n event SignMsg(bytes32 indexed msgHash);\n event ExecutionFailure(bytes32 txHash, uint256 payment);\n event ExecutionSuccess(bytes32 txHash, uint256 payment);\n\n uint256 public nonce;\n bytes32 private _deprecatedDomainSeparator;\n // Mapping to keep track of all message hashes that have been approve by ALL REQUIRED owners\n mapping(bytes32 => uint256) public signedMessages;\n // Mapping to keep track of all hashes (message or transaction) that have been approve by ANY owners\n mapping(address => mapping(bytes32 => uint256)) public approvedHashes;\n\n // This constructor ensures that this contract can only be used as a master copy for Proxy contracts\n constructor() {\n // By setting the threshold it is not possible to call setup anymore,\n // so we create a Safe with 0 owners and threshold 1.\n // This is an unusable Safe, perfect for the singleton\n threshold = 1;\n }\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n /// @param to Contract address for optional delegate call.\n /// @param data Data payload for optional delegate call.\n /// @param fallbackHandler Handler for fallback calls to this contract\n /// @param paymentToken Token that should be used for the payment (0 is ETH)\n /// @param payment Value that should be paid\n /// @param paymentReceiver Adddress that should receive the payment (or 0 if tx.origin)\n function setup(\n address[] calldata _owners,\n uint256 _threshold,\n address to,\n bytes calldata data,\n address fallbackHandler,\n address paymentToken,\n uint256 payment,\n address payable paymentReceiver\n ) external {\n // setupOwners checks if the Threshold is already set, therefore preventing that this method is called twice\n setupOwners(_owners, _threshold);\n if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);\n // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules\n setupModules(to, data);\n\n if (payment > 0) {\n // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)\n // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment\n handlePayment(payment, 0, 1, paymentToken, paymentReceiver);\n }\n emit SafeSetup(msg.sender, _owners, _threshold, to, fallbackHandler);\n }\n\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\n /// Note: The fees are always transferred, even if the user transaction fails.\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @param safeTxGas Gas that should be used for the Safe transaction.\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Gas price that should be used for the payment calculation.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\n function execTransaction(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures\n ) public payable virtual returns (bool success) {\n bytes32 txHash;\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n bytes memory txHashData =\n encodeTransactionData(\n // Transaction info\n to,\n value,\n data,\n operation,\n safeTxGas,\n // Payment info\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n // Signature info\n nonce\n );\n // Increase nonce and execute transaction.\n nonce++;\n txHash = keccak256(txHashData);\n checkSignatures(txHash, txHashData, signatures);\n }\n address guard = getGuard();\n {\n if (guard != address(0)) {\n Guard(guard).checkTransaction(\n // Transaction info\n to,\n value,\n data,\n operation,\n safeTxGas,\n // Payment info\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n // Signature info\n signatures,\n msg.sender\n );\n }\n }\n // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)\n // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150\n require(gasleft() >= ((safeTxGas * 64) / 63).max(safeTxGas + 2500) + 500, \"GS010\");\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n uint256 gasUsed = gasleft();\n // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)\n // We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas\n success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);\n gasUsed = gasUsed.sub(gasleft());\n // If no safeTxGas and no gasPrice was set (e.g. both are 0), then the internal tx is required to be successful\n // This makes it possible to use `estimateGas` without issues, as it searches for the minimum gas where the tx doesn't revert\n require(success || safeTxGas != 0 || gasPrice != 0, \"GS013\");\n // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls\n uint256 payment = 0;\n if (gasPrice > 0) {\n payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);\n }\n if (success) emit ExecutionSuccess(txHash, payment);\n else emit ExecutionFailure(txHash, payment);\n }\n {\n if (guard != address(0)) {\n Guard(guard).checkAfterExecution(txHash, success);\n }\n }\n }\n\n function handlePayment(\n uint256 gasUsed,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver\n ) private returns (uint256 payment) {\n // solhint-disable-next-line avoid-tx-origin\n address payable receiver = refundReceiver == address(0) ? payable(tx.origin) : refundReceiver;\n if (gasToken == address(0)) {\n // For ETH we will only adjust the gas price to not be higher than the actual used gas price\n payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);\n require(receiver.send(payment), \"GS011\");\n } else {\n payment = gasUsed.add(baseGas).mul(gasPrice);\n require(transferToken(gasToken, receiver, payment), \"GS012\");\n }\n }\n\n /**\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n * @param data That should be signed (this is passed to an external validator contract)\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\n */\n function checkSignatures(\n bytes32 dataHash,\n bytes memory data,\n bytes memory signatures\n ) public view {\n // Load threshold to avoid multiple storage loads\n uint256 _threshold = threshold;\n // Check that a threshold is set\n require(_threshold > 0, \"GS001\");\n checkNSignatures(dataHash, data, signatures, _threshold);\n }\n\n /**\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n * @param data That should be signed (this is passed to an external validator contract)\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\n * @param requiredSignatures Amount of required valid signatures.\n */\n function checkNSignatures(\n bytes32 dataHash,\n bytes memory data,\n bytes memory signatures,\n uint256 requiredSignatures\n ) public view {\n // Check that the provided signature data is not too short\n require(signatures.length >= requiredSignatures.mul(65), \"GS020\");\n // There cannot be an owner with address 0.\n address lastOwner = address(0);\n address currentOwner;\n uint8 v;\n bytes32 r;\n bytes32 s;\n uint256 i;\n for (i = 0; i < requiredSignatures; i++) {\n (v, r, s) = signatureSplit(signatures, i);\n if (v == 0) {\n // If v is 0 then it is a contract signature\n // When handling contract signatures the address of the contract is encoded into r\n currentOwner = address(uint160(uint256(r)));\n\n // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes\n // This check is not completely accurate, since it is possible that more signatures than the threshold are send.\n // Here we only check that the pointer is not pointing inside the part that is being processed\n require(uint256(s) >= requiredSignatures.mul(65), \"GS021\");\n\n // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)\n require(uint256(s).add(32) <= signatures.length, \"GS022\");\n\n // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length\n uint256 contractSignatureLen;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n contractSignatureLen := mload(add(add(signatures, s), 0x20))\n }\n require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, \"GS023\");\n\n // Check signature\n bytes memory contractSignature;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s\n contractSignature := add(add(signatures, s), 0x20)\n }\n require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, \"GS024\");\n } else if (v == 1) {\n // If v is 1 then it is an approved hash\n // When handling approved hashes the address of the approver is encoded into r\n currentOwner = address(uint160(uint256(r)));\n // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction\n require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, \"GS025\");\n } else if (v > 30) {\n // If v > 30 then default va (27,28) has been adjusted for eth_sign flow\n // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover\n currentOwner = ecrecover(keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", dataHash)), v - 4, r, s);\n } else {\n // Default is the ecrecover flow with the provided data hash\n // Use ecrecover with the messageHash for EOA signatures\n currentOwner = ecrecover(dataHash, v, r, s);\n }\n require(currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS, \"GS026\");\n lastOwner = currentOwner;\n }\n }\n\n /// @dev Allows to estimate a Safe transaction.\n /// This method is only meant for estimation purpose, therefore the call will always revert and encode the result in the revert data.\n /// Since the `estimateGas` function includes refunds, call this method to get an estimated of the costs that are deducted from the safe with `execTransaction`\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @return Estimate without refunds and overhead fees (base transaction and payload data gas costs).\n /// @notice Deprecated in favor of common/StorageAccessible.sol and will be removed in next version.\n function requiredTxGas(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation\n ) external returns (uint256) {\n uint256 startGas = gasleft();\n // We don't provide an error message here, as we use it to return the estimate\n require(execute(to, value, data, operation, gasleft()));\n uint256 requiredGas = startGas - gasleft();\n // Convert response to string and return via error message\n revert(string(abi.encodePacked(requiredGas)));\n }\n\n /**\n * @dev Marks a hash as approved. This can be used to validate a hash that is used by a signature.\n * @param hashToApprove The hash that should be marked as approved for signatures that are verified by this contract.\n */\n function approveHash(bytes32 hashToApprove) external {\n require(owners[msg.sender] != address(0), \"GS030\");\n approvedHashes[msg.sender][hashToApprove] = 1;\n emit ApproveHash(hashToApprove, msg.sender);\n }\n\n /// @dev Returns the chain id used by this contract.\n function getChainId() public view returns (uint256) {\n uint256 id;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n id := chainid()\n }\n return id;\n }\n\n function domainSeparator() public view returns (bytes32) {\n return keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, getChainId(), this));\n }\n\n /// @dev Returns the bytes that are hashed to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Gas that should be used for the safe transaction.\n /// @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash bytes.\n function encodeTransactionData(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n ) public view returns (bytes memory) {\n bytes32 safeTxHash =\n keccak256(\n abi.encode(\n SAFE_TX_TYPEHASH,\n to,\n value,\n keccak256(data),\n operation,\n safeTxGas,\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n _nonce\n )\n );\n return abi.encodePacked(bytes1(0x19), bytes1(0x01), domainSeparator(), safeTxHash);\n }\n\n /// @dev Returns hash to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Fas that should be used for the safe transaction.\n /// @param baseGas Gas costs for data used to trigger the safe transaction.\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash.\n function getTransactionHash(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n ) public view returns (bytes32) {\n return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./GnosisSafe.sol\";\n\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafeL2 is GnosisSafe {\n event SafeMultiSigTransaction(\n address to,\n uint256 value,\n bytes data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes signatures,\n // We combine nonce, sender and threshold into one to avoid stack too deep\n // Dev note: additionalInfo should not contain `bytes`, as this complicates decoding\n bytes additionalInfo\n );\n\n event SafeModuleTransaction(address module, address to, uint256 value, bytes data, Enum.Operation operation);\n\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\n /// Note: The fees are always transferred, even if the user transaction fails.\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @param safeTxGas Gas that should be used for the Safe transaction.\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Gas price that should be used for the payment calculation.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\n function execTransaction(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures\n ) public payable override returns (bool) {\n bytes memory additionalInfo;\n {\n additionalInfo = abi.encode(nonce, msg.sender, threshold);\n }\n emit SafeMultiSigTransaction(\n to,\n value,\n data,\n operation,\n safeTxGas,\n baseGas,\n gasPrice,\n gasToken,\n refundReceiver,\n signatures,\n additionalInfo\n );\n return super.execTransaction(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, signatures);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) public override returns (bool success) {\n emit SafeModuleTransaction(msg.sender, to, value, data, operation);\n success = super.execTransactionFromModule(to, value, data, operation);\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/interfaces/ISignatureValidator.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\ncontract ISignatureValidatorConstants {\n // bytes4(keccak256(\"isValidSignature(bytes,bytes)\")\n bytes4 internal constant EIP1271_MAGIC_VALUE = 0x20c13b0b;\n}\n\nabstract contract ISignatureValidator is ISignatureValidatorConstants {\n /**\n * @dev Should return whether the signature provided is valid for the provided data\n * @param _data Arbitrary length data signed on the behalf of address(this)\n * @param _signature Signature byte array associated with _data\n *\n * MUST return the bytes4 magic value 0x20c13b0b when function passes.\n * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)\n * MUST allow external calls\n */\n function isValidSignature(bytes memory _data, bytes memory _signature) public view virtual returns (bytes4);\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title Multi Send Call Only - Allows to batch multiple transactions into one, but only calls\n/// @author Stefan George - \n/// @author Richard Meissner - \n/// @notice The guard logic is not required here as this contract doesn't support nested delegate calls\ncontract MultiSendCallOnly {\n /// @dev Sends multiple transactions and reverts all if one fails.\n /// @param transactions Encoded transactions. Each transaction is encoded as a packed bytes of\n /// operation has to be uint8(0) in this version (=> 1 byte),\n /// to as a address (=> 20 bytes),\n /// value as a uint256 (=> 32 bytes),\n /// data length as a uint256 (=> 32 bytes),\n /// data as bytes.\n /// see abi.encodePacked for more information on packed encoding\n /// @notice The code is for most part the same as the normal MultiSend (to keep compatibility),\n /// but reverts if a transaction tries to use a delegatecall.\n /// @notice This method is payable as delegatecalls keep the msg.value from the previous call\n /// If the calling method (e.g. execTransaction) received ETH this would revert otherwise\n function multiSend(bytes memory transactions) public payable {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let length := mload(transactions)\n let i := 0x20\n for {\n // Pre block is not used in \"while mode\"\n } lt(i, length) {\n // Post block is not used in \"while mode\"\n } {\n // First byte of the data is the operation.\n // We shift by 248 bits (256 - 8 [operation byte]) it right since mload will always load 32 bytes (a word).\n // This will also zero out unused data.\n let operation := shr(0xf8, mload(add(transactions, i)))\n // We offset the load address by 1 byte (operation byte)\n // We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data.\n let to := shr(0x60, mload(add(transactions, add(i, 0x01))))\n // We offset the load address by 21 byte (operation byte + 20 address bytes)\n let value := mload(add(transactions, add(i, 0x15)))\n // We offset the load address by 53 byte (operation byte + 20 address bytes + 32 value bytes)\n let dataLength := mload(add(transactions, add(i, 0x35)))\n // We offset the load address by 85 byte (operation byte + 20 address bytes + 32 value bytes + 32 data length bytes)\n let data := add(transactions, add(i, 0x55))\n let success := 0\n switch operation\n case 0 {\n success := call(gas(), to, value, data, dataLength, 0, 0)\n }\n // This version does not allow delegatecalls\n case 1 {\n revert(0, 0)\n }\n if eq(success, 0) {\n revert(0, 0)\n }\n // Next entry starts at 85 byte + data length\n i := add(i, add(0x55, dataLength))\n }\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxy.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain\n/// @author Richard Meissner - \ninterface IProxy {\n function masterCopy() external view returns (address);\n}\n\n/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract GnosisSafeProxy {\n // singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.\n // To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`\n address internal singleton;\n\n /// @dev Constructor function sets address of singleton contract.\n /// @param _singleton Singleton address.\n constructor(address _singleton) {\n require(_singleton != address(0), \"Invalid singleton address provided\");\n singleton = _singleton;\n }\n\n /// @dev Fallback function forwards all transactions and returns all received return data.\n fallback() external payable {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)\n // 0xa619486e == keccak(\"masterCopy()\"). The value is right padded to 32-bytes with 0s\n if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {\n mstore(0, _singleton)\n return(0, 0x20)\n }\n calldatacopy(0, 0, calldatasize())\n let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)\n returndatacopy(0, 0, returndatasize())\n if eq(success, 0) {\n revert(0, returndatasize())\n }\n return(0, returndatasize())\n }\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./GnosisSafeProxy.sol\";\nimport \"./IProxyCreationCallback.sol\";\n\n/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n/// @author Stefan George - \ncontract GnosisSafeProxyFactory {\n event ProxyCreation(GnosisSafeProxy proxy, address singleton);\n\n /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n /// @param singleton Address of singleton contract.\n /// @param data Payload for message call sent to new proxy contract.\n function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {\n proxy = new GnosisSafeProxy(singleton);\n if (data.length > 0)\n // solhint-disable-next-line no-inline-assembly\n assembly {\n if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {\n revert(0, 0)\n }\n }\n emit ProxyCreation(proxy, singleton);\n }\n\n /// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.\n function proxyRuntimeCode() public pure returns (bytes memory) {\n return type(GnosisSafeProxy).runtimeCode;\n }\n\n /// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.\n function proxyCreationCode() public pure returns (bytes memory) {\n return type(GnosisSafeProxy).creationCode;\n }\n\n /// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.\n /// This method is only meant as an utility to be called from other methods\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function deployProxyWithNonce(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce\n ) internal returns (GnosisSafeProxy proxy) {\n // If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it\n bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));\n bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));\n // solhint-disable-next-line no-inline-assembly\n assembly {\n proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)\n }\n require(address(proxy) != address(0), \"Create2 call failed\");\n }\n\n /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function createProxyWithNonce(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce\n ) public returns (GnosisSafeProxy proxy) {\n proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);\n if (initializer.length > 0)\n // solhint-disable-next-line no-inline-assembly\n assembly {\n if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {\n revert(0, 0)\n }\n }\n emit ProxyCreation(proxy, _singleton);\n }\n\n /// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n /// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.\n function createProxyWithCallback(\n address _singleton,\n bytes memory initializer,\n uint256 saltNonce,\n IProxyCreationCallback callback\n ) public returns (GnosisSafeProxy proxy) {\n uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));\n proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);\n if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);\n }\n\n /// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`\n /// This method is only meant for address calculation purpose when you use an initializer that would revert,\n /// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.\n /// @param _singleton Address of singleton contract.\n /// @param initializer Payload for message call sent to new proxy contract.\n /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.\n function calculateCreateProxyWithNonceAddress(\n address _singleton,\n bytes calldata initializer,\n uint256 saltNonce\n ) external returns (GnosisSafeProxy proxy) {\n proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);\n revert(string(abi.encodePacked(proxy)));\n }\n}\n" + }, + "@gnosis.pm/safe-contracts/contracts/proxies/IProxyCreationCallback.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"./GnosisSafeProxy.sol\";\n\ninterface IProxyCreationCallback {\n function proxyCreated(\n GnosisSafeProxy proxy,\n address _singleton,\n bytes calldata initializer,\n uint256 saltNonce\n ) external;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/core/Module.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Module Interface - A contract that can pass messages to a Module Manager contract if enabled by that contract.\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../interfaces/IAvatar.sol\";\nimport \"../factory/FactoryFriendly.sol\";\nimport \"../guard/Guardable.sol\";\n\nabstract contract Module is FactoryFriendly, Guardable {\n /// @dev Address that will ultimately execute function calls.\n address public avatar;\n /// @dev Address that this module will pass transactions to.\n address public target;\n\n /// @dev Emitted each time the avatar is set.\n event AvatarSet(address indexed previousAvatar, address indexed newAvatar);\n /// @dev Emitted each time the Target is set.\n event TargetSet(address indexed previousTarget, address indexed newTarget);\n\n /// @dev Sets the avatar to a new avatar (`newAvatar`).\n /// @notice Can only be called by the current owner.\n function setAvatar(address _avatar) public onlyOwner {\n address previousAvatar = avatar;\n avatar = _avatar;\n emit AvatarSet(previousAvatar, _avatar);\n }\n\n /// @dev Sets the target to a new target (`newTarget`).\n /// @notice Can only be called by the current owner.\n function setTarget(address _target) public onlyOwner {\n address previousTarget = target;\n target = _target;\n emit TargetSet(previousTarget, _target);\n }\n\n /// @dev Passes a transaction to be executed by the avatar.\n /// @notice Can only be called by this contract.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function exec(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) internal returns (bool success) {\n /// Check if a transactioon guard is enabled.\n if (guard != address(0)) {\n IGuard(guard).checkTransaction(\n /// Transaction info used by module transactions.\n to,\n value,\n data,\n operation,\n /// Zero out the redundant transaction information only used for Safe multisig transctions.\n 0,\n 0,\n 0,\n address(0),\n payable(0),\n bytes(\"0x\"),\n msg.sender\n );\n }\n success = IAvatar(target).execTransactionFromModule(\n to,\n value,\n data,\n operation\n );\n if (guard != address(0)) {\n IGuard(guard).checkAfterExecution(bytes32(\"0x\"), success);\n }\n return success;\n }\n\n /// @dev Passes a transaction to be executed by the target and returns data.\n /// @notice Can only be called by this contract.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execAndReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) internal returns (bool success, bytes memory returnData) {\n /// Check if a transactioon guard is enabled.\n if (guard != address(0)) {\n IGuard(guard).checkTransaction(\n /// Transaction info used by module transactions.\n to,\n value,\n data,\n operation,\n /// Zero out the redundant transaction information only used for Safe multisig transctions.\n 0,\n 0,\n 0,\n address(0),\n payable(0),\n bytes(\"0x\"),\n msg.sender\n );\n }\n (success, returnData) = IAvatar(target)\n .execTransactionFromModuleReturnData(to, value, data, operation);\n if (guard != address(0)) {\n IGuard(guard).checkAfterExecution(bytes32(\"0x\"), success);\n }\n return (success, returnData);\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/factory/FactoryFriendly.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Zodiac FactoryFriendly - A contract that allows other contracts to be initializable and pass bytes as arguments to define contract state\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nabstract contract FactoryFriendly is OwnableUpgradeable {\n function setUp(bytes memory initializeParams) public virtual;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.8.0;\n\ncontract ModuleProxyFactory {\n event ModuleProxyCreation(\n address indexed proxy,\n address indexed masterCopy\n );\n\n /// `target` can not be zero.\n error ZeroAddress(address target);\n\n /// `address_` is already taken.\n error TakenAddress(address address_);\n\n /// @notice Initialization failed.\n error FailedInitialization();\n\n function createProxy(address target, bytes32 salt)\n internal\n returns (address result)\n {\n if (address(target) == address(0)) revert ZeroAddress(target);\n bytes memory deployment = abi.encodePacked(\n hex\"602d8060093d393df3363d3d373d3d3d363d73\",\n target,\n hex\"5af43d82803e903d91602b57fd5bf3\"\n );\n // solhint-disable-next-line no-inline-assembly\n assembly {\n result := create2(0, add(deployment, 0x20), mload(deployment), salt)\n }\n if (result == address(0)) revert TakenAddress(result);\n }\n\n function deployModule(\n address masterCopy,\n bytes memory initializer,\n uint256 saltNonce\n ) public returns (address proxy) {\n proxy = createProxy(\n masterCopy,\n keccak256(abi.encodePacked(keccak256(initializer), saltNonce))\n );\n (bool success, ) = proxy.call(initializer);\n if (!success) revert FailedInitialization();\n\n emit ModuleProxyCreation(proxy, masterCopy);\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/guard/BaseGuard.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport \"../interfaces/IGuard.sol\";\n\nabstract contract BaseGuard is IERC165 {\n function supportsInterface(bytes4 interfaceId)\n external\n pure\n override\n returns (bool)\n {\n return\n interfaceId == type(IGuard).interfaceId || // 0xe6d7a83a\n interfaceId == type(IERC165).interfaceId; // 0x01ffc9a7\n }\n\n /// @dev Module transactions only use the first four parameters: to, value, data, and operation.\n /// Module.sol hardcodes the remaining parameters as 0 since they are not used for module transactions.\n /// @notice This interface is used to maintain compatibilty with Gnosis Safe transaction guards.\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external virtual;\n\n function checkAfterExecution(bytes32 txHash, bool success) external virtual;\n}\n" + }, + "@gnosis.pm/zodiac/contracts/guard/Guardable.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"./BaseGuard.sol\";\n\n/// @title Guardable - A contract that manages fallback calls made to this contract\ncontract Guardable is OwnableUpgradeable {\n address public guard;\n\n event ChangedGuard(address guard);\n\n /// `guard_` does not implement IERC165.\n error NotIERC165Compliant(address guard_);\n\n /// @dev Set a guard that checks transactions before execution.\n /// @param _guard The address of the guard to be used or the 0 address to disable the guard.\n function setGuard(address _guard) external onlyOwner {\n if (_guard != address(0)) {\n if (!BaseGuard(_guard).supportsInterface(type(IGuard).interfaceId))\n revert NotIERC165Compliant(_guard);\n }\n guard = _guard;\n emit ChangedGuard(guard);\n }\n\n function getGuard() external view returns (address _guard) {\n return guard;\n }\n}\n" + }, + "@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\n\n/// @title Zodiac Avatar - A contract that manages modules that can execute transactions via this contract.\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\n\ninterface IAvatar {\n event EnabledModule(address module);\n event DisabledModule(address module);\n event ExecutionFromModuleSuccess(address indexed module);\n event ExecutionFromModuleFailure(address indexed module);\n\n /// @dev Enables a module on the avatar.\n /// @notice Can only be called by the avatar.\n /// @notice Modules should be stored as a linked list.\n /// @notice Must emit EnabledModule(address module) if successful.\n /// @param module Module to be enabled.\n function enableModule(address module) external;\n\n /// @dev Disables a module on the avatar.\n /// @notice Can only be called by the avatar.\n /// @notice Must emit DisabledModule(address module) if successful.\n /// @param prevModule Address that pointed to the module to be removed in the linked list\n /// @param module Module to be removed.\n function disableModule(address prevModule, address module) external;\n\n /// @dev Allows a Module to execute a transaction.\n /// @notice Can only be called by an enabled module.\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execTransactionFromModule(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) external returns (bool success);\n\n /// @dev Allows a Module to execute a transaction and return data\n /// @notice Can only be called by an enabled module.\n /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.\n /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.\n function execTransactionFromModuleReturnData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation\n ) external returns (bool success, bytes memory returnData);\n\n /// @dev Returns if an module is enabled\n /// @return True if the module is enabled\n function isModuleEnabled(address module) external view returns (bool);\n\n /// @dev Returns array of modules.\n /// @param start Start of the page.\n /// @param pageSize Maximum number of modules that should be returned.\n /// @return array Array of modules.\n /// @return next Start of the next page.\n function getModulesPaginated(address start, uint256 pageSize)\n external\n view\n returns (address[] memory array, address next);\n}\n" + }, + "@gnosis.pm/zodiac/contracts/interfaces/IGuard.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\n\ninterface IGuard {\n function checkTransaction(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes memory signatures,\n address msgSender\n ) external;\n\n function checkAfterExecution(bytes32 txHash, bool success) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 * By default, the owner account will be the one that deploys the contract. This\n * can 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 OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\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 require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing 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 require(newOwner != address(0), \"Ownable: new owner is the zero address\");\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/governance/utils/IVotesUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotesUpgradeable {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\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 * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\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 Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 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. Equivalent to `reinitializer(1)`.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\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 * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\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 modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\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 require(_initializing, \"Initializable: contract is not initializing\");\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 function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20Upgradeable.sol\";\nimport \"./extensions/IERC20MetadataUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC20_init_unchained(name_, symbol_);\n }\n\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[45] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20PermitUpgradeable.sol\";\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/cryptography/draft-EIP712Upgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {\n using CountersUpgradeable for CountersUpgradeable.Counter;\n\n mapping(address => CountersUpgradeable.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n function __ERC20Permit_init(string memory name) internal onlyInitializing {\n __EIP712_init_unchained(name, \"1\");\n }\n\n function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSAUpgradeable.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n CountersUpgradeable.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20SnapshotUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC20Snapshot.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/ArraysUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances and\n * total supply at the time are recorded for later access.\n *\n * This can be used to safely create mechanisms based on token balances such as trustless dividends or weighted voting.\n * In naive implementations it's possible to perform a \"double spend\" attack by reusing the same balance from different\n * accounts. By using snapshots to calculate dividends or voting power, those attacks no longer apply. It can also be\n * used to create an efficient ERC20 forking mechanism.\n *\n * Snapshots are created by the internal {_snapshot} function, which will emit the {Snapshot} event and return a\n * snapshot id. To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with the snapshot\n * id. To get the balance of an account at the time of a snapshot, call the {balanceOfAt} function with the snapshot id\n * and the account address.\n *\n * NOTE: Snapshot policy can be customized by overriding the {_getCurrentSnapshotId} method. For example, having it\n * return `block.number` will trigger the creation of snapshot at the beginning of each new block. When overriding this\n * function, be careful about the monotonicity of its result. Non-monotonic snapshot ids will break the contract.\n *\n * Implementing snapshots for every block using this method will incur significant gas costs. For a gas-efficient\n * alternative consider {ERC20Votes}.\n *\n * ==== Gas Costs\n *\n * Snapshots are efficient. Snapshot creation is _O(1)_. Retrieval of balances or total supply from a snapshot is _O(log\n * n)_ in the number of snapshots that have been created, although _n_ for a specific account will generally be much\n * smaller since identical balances in subsequent snapshots are stored as a single entry.\n *\n * There is a constant overhead for normal ERC20 transfers due to the additional snapshot bookkeeping. This overhead is\n * only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent\n * transfers will have normal cost until the next snapshot, and so on.\n */\n\nabstract contract ERC20SnapshotUpgradeable is Initializable, ERC20Upgradeable {\n function __ERC20Snapshot_init() internal onlyInitializing {\n }\n\n function __ERC20Snapshot_init_unchained() internal onlyInitializing {\n }\n // Inspired by Jordi Baylina's MiniMeToken to record historical balances:\n // https://github.com/Giveth/minime/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol\n\n using ArraysUpgradeable for uint256[];\n using CountersUpgradeable for CountersUpgradeable.Counter;\n\n // Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a\n // Snapshot struct, but that would impede usage of functions that work on an array.\n struct Snapshots {\n uint256[] ids;\n uint256[] values;\n }\n\n mapping(address => Snapshots) private _accountBalanceSnapshots;\n Snapshots private _totalSupplySnapshots;\n\n // Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid.\n CountersUpgradeable.Counter private _currentSnapshotId;\n\n /**\n * @dev Emitted by {_snapshot} when a snapshot identified by `id` is created.\n */\n event Snapshot(uint256 id);\n\n /**\n * @dev Creates a new snapshot and returns its snapshot id.\n *\n * Emits a {Snapshot} event that contains the same id.\n *\n * {_snapshot} is `internal` and you have to decide how to expose it externally. Its usage may be restricted to a\n * set of accounts, for example using {AccessControl}, or it may be open to the public.\n *\n * [WARNING]\n * ====\n * While an open way of calling {_snapshot} is required for certain trust minimization mechanisms such as forking,\n * you must consider that it can potentially be used by attackers in two ways.\n *\n * First, it can be used to increase the cost of retrieval of values from snapshots, although it will grow\n * logarithmically thus rendering this attack ineffective in the long term. Second, it can be used to target\n * specific accounts and increase the cost of ERC20 transfers for them, in the ways specified in the Gas Costs\n * section above.\n *\n * We haven't measured the actual numbers; if this is something you're interested in please reach out to us.\n * ====\n */\n function _snapshot() internal virtual returns (uint256) {\n _currentSnapshotId.increment();\n\n uint256 currentId = _getCurrentSnapshotId();\n emit Snapshot(currentId);\n return currentId;\n }\n\n /**\n * @dev Get the current snapshotId\n */\n function _getCurrentSnapshotId() internal view virtual returns (uint256) {\n return _currentSnapshotId.current();\n }\n\n /**\n * @dev Retrieves the balance of `account` at the time `snapshotId` was created.\n */\n function balanceOfAt(address account, uint256 snapshotId) public view virtual returns (uint256) {\n (bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]);\n\n return snapshotted ? value : balanceOf(account);\n }\n\n /**\n * @dev Retrieves the total supply at the time `snapshotId` was created.\n */\n function totalSupplyAt(uint256 snapshotId) public view virtual returns (uint256) {\n (bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots);\n\n return snapshotted ? value : totalSupply();\n }\n\n // Update balance and/or total supply snapshots before the values are modified. This is implemented\n // in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations.\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n if (from == address(0)) {\n // mint\n _updateAccountSnapshot(to);\n _updateTotalSupplySnapshot();\n } else if (to == address(0)) {\n // burn\n _updateAccountSnapshot(from);\n _updateTotalSupplySnapshot();\n } else {\n // transfer\n _updateAccountSnapshot(from);\n _updateAccountSnapshot(to);\n }\n }\n\n function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) {\n require(snapshotId > 0, \"ERC20Snapshot: id is 0\");\n require(snapshotId <= _getCurrentSnapshotId(), \"ERC20Snapshot: nonexistent id\");\n\n // When a valid snapshot is queried, there are three possibilities:\n // a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was never\n // created for this id, and all stored snapshot ids are smaller than the requested one. The value that corresponds\n // to this id is the current one.\n // b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with the\n // requested id, and its value is the one to return.\n // c) More snapshots were created after the requested one, and the queried value was later modified. There will be\n // no entry for the requested id: the value that corresponds to it is that of the smallest snapshot id that is\n // larger than the requested one.\n //\n // In summary, we need to find an element in an array, returning the index of the smallest value that is larger if\n // it is not found, unless said value doesn't exist (e.g. when all values are smaller). Arrays.findUpperBound does\n // exactly this.\n\n uint256 index = snapshots.ids.findUpperBound(snapshotId);\n\n if (index == snapshots.ids.length) {\n return (false, 0);\n } else {\n return (true, snapshots.values[index]);\n }\n }\n\n function _updateAccountSnapshot(address account) private {\n _updateSnapshot(_accountBalanceSnapshots[account], balanceOf(account));\n }\n\n function _updateTotalSupplySnapshot() private {\n _updateSnapshot(_totalSupplySnapshots, totalSupply());\n }\n\n function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private {\n uint256 currentId = _getCurrentSnapshotId();\n if (_lastSnapshotId(snapshots.ids) < currentId) {\n snapshots.ids.push(currentId);\n snapshots.values.push(currentValue);\n }\n }\n\n function _lastSnapshotId(uint256[] storage ids) private view returns (uint256) {\n if (ids.length == 0) {\n return 0;\n } else {\n return ids[ids.length - 1];\n }\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[46] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Votes.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-ERC20PermitUpgradeable.sol\";\nimport \"../../../utils/math/MathUpgradeable.sol\";\nimport \"../../../governance/utils/IVotesUpgradeable.sol\";\nimport \"../../../utils/math/SafeCastUpgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's,\n * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1.\n *\n * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module.\n *\n * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either\n * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting\n * power can be queried through the public accessors {getVotes} and {getPastVotes}.\n *\n * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it\n * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.\n *\n * _Available since v4.2._\n */\nabstract contract ERC20VotesUpgradeable is Initializable, IVotesUpgradeable, ERC20PermitUpgradeable {\n function __ERC20Votes_init() internal onlyInitializing {\n }\n\n function __ERC20Votes_init_unchained() internal onlyInitializing {\n }\n struct Checkpoint {\n uint32 fromBlock;\n uint224 votes;\n }\n\n bytes32 private constant _DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n mapping(address => address) private _delegates;\n mapping(address => Checkpoint[]) private _checkpoints;\n Checkpoint[] private _totalSupplyCheckpoints;\n\n /**\n * @dev Get the `pos`-th checkpoint for `account`.\n */\n function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) {\n return _checkpoints[account][pos];\n }\n\n /**\n * @dev Get number of checkpoints for `account`.\n */\n function numCheckpoints(address account) public view virtual returns (uint32) {\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\n }\n\n /**\n * @dev Get the address `account` is currently delegating to.\n */\n function delegates(address account) public view virtual override returns (address) {\n return _delegates[account];\n }\n\n /**\n * @dev Gets the current votes balance for `account`\n */\n function getVotes(address account) public view virtual override returns (uint256) {\n uint256 pos = _checkpoints[account].length;\n return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;\n }\n\n /**\n * @dev Retrieve the number of votes for `account` at the end of `blockNumber`.\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_checkpoints[account], blockNumber);\n }\n\n /**\n * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances.\n * It is but NOT the sum of all the delegated votes!\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastTotalSupply(uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber);\n }\n\n /**\n * @dev Lookup a value in a list of (sorted) checkpoints.\n */\n function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) {\n // We run a binary search to look for the earliest checkpoint taken after `blockNumber`.\n //\n // During the loop, the index of the wanted checkpoint remains in the range [low-1, high).\n // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.\n // - If the middle checkpoint is after `blockNumber`, we look in [low, mid)\n // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high)\n // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not\n // out of bounds (in which case we're looking too far in the past and the result is 0).\n // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is\n // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out\n // the same.\n uint256 high = ckpts.length;\n uint256 low = 0;\n while (low < high) {\n uint256 mid = MathUpgradeable.average(low, high);\n if (ckpts[mid].fromBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n return high == 0 ? 0 : ckpts[high - 1].votes;\n }\n\n /**\n * @dev Delegate votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) public virtual override {\n _delegate(_msgSender(), delegatee);\n }\n\n /**\n * @dev Delegates votes from signer to `delegatee`\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= expiry, \"ERC20Votes: signature expired\");\n address signer = ECDSAUpgradeable.recover(\n _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))),\n v,\n r,\n s\n );\n require(nonce == _useNonce(signer), \"ERC20Votes: invalid nonce\");\n _delegate(signer, delegatee);\n }\n\n /**\n * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).\n */\n function _maxSupply() internal view virtual returns (uint224) {\n return type(uint224).max;\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been increased.\n */\n function _mint(address account, uint256 amount) internal virtual override {\n super._mint(account, amount);\n require(totalSupply() <= _maxSupply(), \"ERC20Votes: total supply risks overflowing votes\");\n\n _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been decreased.\n */\n function _burn(address account, uint256 amount) internal virtual override {\n super._burn(account, amount);\n\n _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);\n }\n\n /**\n * @dev Move voting power when tokens are transferred.\n *\n * Emits a {DelegateVotesChanged} event.\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._afterTokenTransfer(from, to, amount);\n\n _moveVotingPower(delegates(from), delegates(to), amount);\n }\n\n /**\n * @dev Change delegation for `delegator` to `delegatee`.\n *\n * Emits events {DelegateChanged} and {DelegateVotesChanged}.\n */\n function _delegate(address delegator, address delegatee) internal virtual {\n address currentDelegate = delegates(delegator);\n uint256 delegatorBalance = balanceOf(delegator);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _moveVotingPower(\n address src,\n address dst,\n uint256 amount\n ) private {\n if (src != dst && amount > 0) {\n if (src != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);\n emit DelegateVotesChanged(src, oldWeight, newWeight);\n }\n\n if (dst != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\n }\n }\n }\n\n function _writeCheckpoint(\n Checkpoint[] storage ckpts,\n function(uint256, uint256) view returns (uint256) op,\n uint256 delta\n ) private returns (uint256 oldWeight, uint256 newWeight) {\n uint256 pos = ckpts.length;\n oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes;\n newWeight = op(oldWeight, delta);\n\n if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {\n ckpts[pos - 1].votes = SafeCastUpgradeable.toUint224(newWeight);\n } else {\n ckpts.push(Checkpoint({fromBlock: SafeCastUpgradeable.toUint32(block.number), votes: SafeCastUpgradeable.toUint224(newWeight)}));\n }\n }\n\n function _add(uint256 a, uint256 b) private pure returns (uint256) {\n return a + b;\n }\n\n function _subtract(uint256 a, uint256 b) private pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[47] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20WrapperUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/ERC20Wrapper.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../utils/SafeERC20Upgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Extension of the ERC20 token contract to support token wrapping.\n *\n * Users can deposit and withdraw \"underlying tokens\" and receive a matching number of \"wrapped tokens\". This is useful\n * in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the\n * wrapping of an existing \"basic\" ERC20 into a governance token.\n *\n * _Available since v4.2._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20WrapperUpgradeable is Initializable, ERC20Upgradeable {\n IERC20Upgradeable public underlying;\n\n function __ERC20Wrapper_init(IERC20Upgradeable underlyingToken) internal onlyInitializing {\n __ERC20Wrapper_init_unchained(underlyingToken);\n }\n\n function __ERC20Wrapper_init_unchained(IERC20Upgradeable underlyingToken) internal onlyInitializing {\n underlying = underlyingToken;\n }\n\n /**\n * @dev See {ERC20-decimals}.\n */\n function decimals() public view virtual override returns (uint8) {\n try IERC20MetadataUpgradeable(address(underlying)).decimals() returns (uint8 value) {\n return value;\n } catch {\n return super.decimals();\n }\n }\n\n /**\n * @dev Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.\n */\n function depositFor(address account, uint256 amount) public virtual returns (bool) {\n SafeERC20Upgradeable.safeTransferFrom(underlying, _msgSender(), address(this), amount);\n _mint(account, amount);\n return true;\n }\n\n /**\n * @dev Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.\n */\n function withdrawTo(address account, uint256 amount) public virtual returns (bool) {\n _burn(_msgSender(), amount);\n SafeERC20Upgradeable.safeTransfer(underlying, account, amount);\n return true;\n }\n\n /**\n * @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal\n * function that can be exposed with access control if desired.\n */\n function _recover(address account) internal virtual returns (uint256) {\n uint256 value = underlying.balanceOf(address(this)) - totalSupply();\n _mint(account, value);\n return value;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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 function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\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 /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ArraysUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Arrays.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\n\n/**\n * @dev Collection of functions related to array types.\n */\nlibrary ArraysUpgradeable {\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 * `array` is expected to be sorted in ascending order, and to contain no\n * repeated elements.\n */\n function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {\n if (array.length == 0) {\n return 0;\n }\n\n uint256 low = 0;\n uint256 high = array.length;\n\n while (low < high) {\n uint256 mid = MathUpgradeable.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 down (it does integer division with truncation).\n if (array[mid] > 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 && array[low - 1] == element) {\n return low - 1;\n } else {\n return low;\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary CountersUpgradeable {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSAUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 52\n */\nabstract contract EIP712Upgradeable is Initializable {\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n __EIP712_init_unchained(name, version);\n }\n\n function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev The hash of the name parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712NameHash() internal virtual view returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /**\n * @dev The hash of the version parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712VersionHash() internal virtual view returns (bytes32) {\n return _HASHED_VERSION;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\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 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 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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / 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 prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\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 works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\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^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`.\n // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.\n // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.\n // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a\n // good first aproximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1;\n uint256 x = a;\n if (x >> 128 > 0) {\n x >>= 128;\n result <<= 64;\n }\n if (x >> 64 > 0) {\n x >>= 64;\n result <<= 32;\n }\n if (x >> 32 > 0) {\n x >>= 32;\n result <<= 16;\n }\n if (x >> 16 > 0) {\n x >>= 16;\n result <<= 8;\n }\n if (x >> 8 > 0) {\n x >>= 8;\n result <<= 4;\n }\n if (x >> 4 > 0) {\n x >>= 4;\n result <<= 2;\n }\n if (x >> 2 > 0) {\n result <<= 1;\n }\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n uint256 result = sqrt(a);\n if (rounding == Rounding.Up && result * result < a) {\n result += 1;\n }\n return result;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX 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 *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\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 * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\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 * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\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 * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\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 * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\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 * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\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 * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\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 * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\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 * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\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 * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\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 * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\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 * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\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 * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\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 * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\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 * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\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 * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\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 * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\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 * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\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 * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\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 * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\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 * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\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 * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\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 * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\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 * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\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 * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\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 * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\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 * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\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 * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\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 * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\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 * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\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 * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\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 * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\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 * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\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 * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248) {\n require(value >= type(int248).min && value <= type(int248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return int248(value);\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 * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240) {\n require(value >= type(int240).min && value <= type(int240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return int240(value);\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 * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232) {\n require(value >= type(int232).min && value <= type(int232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return int232(value);\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 * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224) {\n require(value >= type(int224).min && value <= type(int224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return int224(value);\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 * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216) {\n require(value >= type(int216).min && value <= type(int216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return int216(value);\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 * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208) {\n require(value >= type(int208).min && value <= type(int208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return int208(value);\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 * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200) {\n require(value >= type(int200).min && value <= type(int200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return int200(value);\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 * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192) {\n require(value >= type(int192).min && value <= type(int192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return int192(value);\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 * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184) {\n require(value >= type(int184).min && value <= type(int184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return int184(value);\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 * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176) {\n require(value >= type(int176).min && value <= type(int176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return int176(value);\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 * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168) {\n require(value >= type(int168).min && value <= type(int168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return int168(value);\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 * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160) {\n require(value >= type(int160).min && value <= type(int160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return int160(value);\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 * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152) {\n require(value >= type(int152).min && value <= type(int152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return int152(value);\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 * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144) {\n require(value >= type(int144).min && value <= type(int144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return int144(value);\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 * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136) {\n require(value >= type(int136).min && value <= type(int136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return int136(value);\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 * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128) {\n require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return int128(value);\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 * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120) {\n require(value >= type(int120).min && value <= type(int120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return int120(value);\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 * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112) {\n require(value >= type(int112).min && value <= type(int112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return int112(value);\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 * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104) {\n require(value >= type(int104).min && value <= type(int104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return int104(value);\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 * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96) {\n require(value >= type(int96).min && value <= type(int96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return int96(value);\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 * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88) {\n require(value >= type(int88).min && value <= type(int88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return int88(value);\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 * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80) {\n require(value >= type(int80).min && value <= type(int80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return int80(value);\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 * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72) {\n require(value >= type(int72).min && value <= type(int72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return int72(value);\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 * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64) {\n require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return int64(value);\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 * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56) {\n require(value >= type(int56).min && value <= type(int56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return int56(value);\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 * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48) {\n require(value >= type(int48).min && value <= type(int48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return int48(value);\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 * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40) {\n require(value >= type(int40).min && value <= type(int40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return int40(value);\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 * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32) {\n require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return int32(value);\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 * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24) {\n require(value >= type(int24).min && value <= type(int24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return int24(value);\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 * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16) {\n require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return int16(value);\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 * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8) {\n require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return int8(value);\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 * _Available since v3.0._\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 require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@openzeppelin/contracts/governance/utils/IVotes.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotes {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/ERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\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 /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\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" + }, + "@openzeppelin/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 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 *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165Storage.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Storage.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ERC165.sol\";\n\n/**\n * @dev Storage based implementation of the {IERC165} interface.\n *\n * Contracts may inherit from this and call {_registerInterface} to declare\n * their support of an interface.\n */\nabstract contract ERC165Storage is ERC165 {\n /**\n * @dev Mapping of interface ids to whether or not it's supported.\n */\n mapping(bytes4 => bool) private _supportedInterfaces;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return super.supportsInterface(interfaceId) || _supportedInterfaces[interfaceId];\n }\n\n /**\n * @dev Registers the contract as an implementer of the interface defined by\n * `interfaceId`. Support of the actual ERC165 interface is automatic and\n * registering its interface id is not required.\n *\n * See {IERC165-supportsInterface}.\n *\n * Requirements:\n *\n * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).\n */\n function _registerInterface(bytes4 interfaceId) internal virtual {\n require(interfaceId != 0xffffffff, \"ERC165: invalid interface id\");\n _supportedInterfaces[interfaceId] = true;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\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[EIP 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" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@prb/math/src/Common.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\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 works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\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^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n" + }, + "@prb/math/src/sd1x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n" + }, + "@prb/math/src/sd1x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint64 constant uUNIT = 1e18;\n" + }, + "@prb/math/src/sd1x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n" + }, + "@prb/math/src/sd1x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n" + }, + "@prb/math/src/sd59x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n" + }, + "@prb/math/src/sd59x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev Any value less than this returns 0 in {exp}.\nint256 constant uEXP_MIN_THRESHOLD = -41_446531673892822322;\nSD59x18 constant EXP_MIN_THRESHOLD = SD59x18.wrap(uEXP_MIN_THRESHOLD);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Any value less than this returns 0 in {exp2}.\nint256 constant uEXP2_MIN_THRESHOLD = -59_794705707972522261;\nSD59x18 constant EXP2_MIN_THRESHOLD = SD59x18.wrap(uEXP2_MIN_THRESHOLD);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n" + }, + "@prb/math/src/sd59x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n" + }, + "@prb/math/src/sd59x18/Helpers.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" + }, + "@prb/math/src/sd59x18/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uEXP_MIN_THRESHOLD,\n uEXP2_MIN_THRESHOLD,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // Any input less than the threshold returns zero.\n // This check also prevents an overflow for very small numbers.\n if (xInt < uEXP_MIN_THRESHOLD) {\n return ZERO;\n }\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than the threshold is truncated to zero.\n if (xInt < uEXP2_MIN_THRESHOLD) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n" + }, + "@prb/math/src/sd59x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n" + }, + "@prb/math/src/UD2x18.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗╚════██╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║ █████╔╝ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══╝ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud2x18/Casting.sol\";\nimport \"./ud2x18/Constants.sol\";\nimport \"./ud2x18/Errors.sol\";\nimport \"./ud2x18/ValueType.sol\";\n" + }, + "@prb/math/src/ud2x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n" + }, + "@prb/math/src/ud2x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\nuint64 constant uUNIT = 1e18;\n" + }, + "@prb/math/src/ud2x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n" + }, + "@prb/math/src/ud2x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n" + }, + "@prb/math/src/UD60x18.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n" + }, + "@prb/math/src/ud60x18/Casting.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n" + }, + "@prb/math/src/ud60x18/Constants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n" + }, + "@prb/math/src/ud60x18/Conversions.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n" + }, + "@prb/math/src/ud60x18/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n" + }, + "@prb/math/src/ud60x18/Helpers.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" + }, + "@prb/math/src/ud60x18/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n///\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n" + }, + "@prb/math/src/ud60x18/ValueType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n" + }, + "contracts/DecentSablierStreamManagement.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.28;\n\nimport {Enum} from \"@gnosis.pm/safe-contracts/contracts/common/Enum.sol\";\nimport {IAvatar} from \"@gnosis.pm/zodiac/contracts/interfaces/IAvatar.sol\";\nimport {ISablierV2Lockup} from \"./interfaces/sablier/full/ISablierV2Lockup.sol\";\nimport {Lockup} from \"./interfaces/sablier/full/types/DataTypes.sol\";\n\ncontract DecentSablierStreamManagement {\n string public constant NAME = \"DecentSablierStreamManagement\";\n\n function withdrawMaxFromStream(\n ISablierV2Lockup sablier,\n address recipientHatAccount,\n uint256 streamId,\n address to\n ) public {\n // Check if there are funds to withdraw\n uint128 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\n if (withdrawableAmount == 0) {\n return;\n }\n\n // Proxy the Sablier withdrawMax call through IAvatar (Safe)\n IAvatar(msg.sender).execTransactionFromModule(\n recipientHatAccount,\n 0,\n abi.encodeWithSignature(\n \"execute(address,uint256,bytes,uint8)\",\n address(sablier),\n 0,\n abi.encodeWithSignature(\n \"withdrawMax(uint256,address)\",\n streamId,\n to\n ),\n 0\n ),\n Enum.Operation.Call\n );\n }\n\n function cancelStream(ISablierV2Lockup sablier, uint256 streamId) public {\n // Check if the stream can be cancelled\n Lockup.Status streamStatus = sablier.statusOf(streamId);\n if (\n streamStatus != Lockup.Status.PENDING &&\n streamStatus != Lockup.Status.STREAMING\n ) {\n return;\n }\n\n IAvatar(msg.sender).execTransactionFromModule(\n address(sablier),\n 0,\n abi.encodeWithSignature(\"cancel(uint256)\", streamId),\n Enum.Operation.Call\n );\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol';\n" + }, + "contracts/interfaces/hats/IHats.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0\n// Copyright (C) 2023 Haberdasher Labs\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see .\n\npragma solidity >=0.8.13;\n\ninterface IHats {\n function mintTopHat(\n address _target,\n string memory _details,\n string memory _imageURI\n ) external returns (uint256 topHatId);\n\n function createHat(\n uint256 _admin,\n string calldata _details,\n uint32 _maxSupply,\n address _eligibility,\n address _toggle,\n bool _mutable,\n string calldata _imageURI\n ) external returns (uint256 newHatId);\n\n function mintHat(\n uint256 _hatId,\n address _wearer\n ) external returns (bool success);\n\n function transferHat(uint256 _hatId, address _from, address _to) external;\n}\n" + }, + "contracts/interfaces/IERC6551Registry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IERC6551Registry {\n /**\n * @dev Creates a token bound account for a non-fungible token.\n *\n * If account has already been created, returns the account address without calling create2.\n *\n * Emits ERC6551AccountCreated event.\n *\n * @return account The address of the token bound account\n */\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address account);\n}\n" + }, + "contracts/interfaces/sablier/full/IAdminable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\n/// @title IAdminable\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\n/// in the constructor.\ninterface IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin is transferred.\n /// @param oldAdmin The address of the old admin.\n /// @param newAdmin The address of the new admin.\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice The address of the admin account or contract.\n function admin() external view returns (address);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Transfers the contract admin to a new address.\n ///\n /// @dev Notes:\n /// - Does not revert if the admin is the same.\n /// - This function can potentially leave the contract without an admin, thereby removing any\n /// functionality that is only available to the admin.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newAdmin The address of the new admin.\n function transferAdmin(address newAdmin) external;\n}\n" + }, + "contracts/interfaces/sablier/full/IERC4096.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4906.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\n/// @title ERC-721 Metadata Update Extension\ninterface IERC4906 is IERC165, IERC721 {\n /// @dev This event emits when the metadata of a token is changed.\n /// So that the third-party platforms such as NFT market could\n /// timely update the images and related attributes of the NFT.\n event MetadataUpdate(uint256 _tokenId);\n\n /// @dev This event emits when the metadata of a range of tokens is changed.\n /// So that the third-party platforms such as NFT market could\n /// timely update the images and related attributes of the NFTs.\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n}\n" + }, + "contracts/interfaces/sablier/full/ISablierV2Lockup.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC4906} from \"./IERC4096.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IERC721Metadata} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\nimport {UD60x18} from \"@prb/math/src/UD60x18.sol\";\n\nimport {Lockup} from \"./types/DataTypes.sol\";\nimport {IAdminable} from \"./IAdminable.sol\";\nimport {ISablierV2NFTDescriptor} from \"./ISablierV2NFTDescriptor.sol\";\n\n/// @title ISablierV2Lockup\n/// @notice Common logic between all Sablier V2 Lockup contracts.\ninterface ISablierV2Lockup is\n IAdminable, // 0 inherited components\n IERC4906, // 2 inherited components\n IERC721Metadata // 2 inherited components\n{\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin allows a new recipient contract to hook to Sablier.\n /// @param admin The address of the current contract admin.\n /// @param recipient The address of the recipient contract put on the allowlist.\n event AllowToHook(address indexed admin, address recipient);\n\n /// @notice Emitted when a stream is canceled.\n /// @param streamId The ID of the stream.\n /// @param sender The address of the stream's sender.\n /// @param recipient The address of the stream's recipient.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\n /// decimals.\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\n /// asset's decimals.\n event CancelLockupStream(\n uint256 streamId,\n address indexed sender,\n address indexed recipient,\n IERC20 indexed asset,\n uint128 senderAmount,\n uint128 recipientAmount\n );\n\n /// @notice Emitted when a sender gives up the right to cancel a stream.\n /// @param streamId The ID of the stream.\n event RenounceLockupStream(uint256 indexed streamId);\n\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\n /// @param admin The address of the current contract admin.\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n event SetNFTDescriptor(\n address indexed admin,\n ISablierV2NFTDescriptor oldNFTDescriptor,\n ISablierV2NFTDescriptor newNFTDescriptor\n );\n\n /// @notice Emitted when assets are withdrawn from a stream.\n /// @param streamId The ID of the stream.\n /// @param to The address that has received the withdrawn assets.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\n event WithdrawFromLockupStream(\n uint256 indexed streamId,\n address indexed to,\n IERC20 indexed asset,\n uint128 amount\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the address of the ERC-20 asset to be distributed.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\n\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getDepositedAmount(\n uint256 streamId\n ) external view returns (uint128 depositedAmount);\n\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getEndTime(\n uint256 streamId\n ) external view returns (uint40 endTime);\n\n /// @notice Retrieves the stream's recipient.\n /// @dev Reverts if the NFT has been burned.\n /// @param streamId The stream ID for the query.\n function getRecipient(\n uint256 streamId\n ) external view returns (address recipient);\n\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\n /// decimals. This amount is always zero unless the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getRefundedAmount(\n uint256 streamId\n ) external view returns (uint128 refundedAmount);\n\n /// @notice Retrieves the stream's sender.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getSender(uint256 streamId) external view returns (address sender);\n\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getStartTime(\n uint256 streamId\n ) external view returns (uint40 startTime);\n\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function getWithdrawnAmount(\n uint256 streamId\n ) external view returns (uint128 withdrawnAmount);\n\n /// @notice Retrieves a flag indicating whether the provided address is a contract allowed to hook to Sablier\n /// when a stream is canceled or when assets are withdrawn.\n /// @dev See {ISablierLockupRecipient} for more information.\n function isAllowedToHook(\n address recipient\n ) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\n /// flag is always `false`.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isCancelable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isCold(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isDepleted(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream exists.\n /// @dev Does not revert if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isStream(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isTransferable(\n uint256 streamId\n ) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function isWarm(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves the maximum broker fee that can be charged by the broker, denoted as a fixed-point\n /// number where 1e18 is 100%.\n /// @dev This value is hard coded as a constant.\n function MAX_BROKER_FEE() external view returns (UD60x18);\n\n /// @notice Counter for stream IDs, used in the create functions.\n function nextStreamId() external view returns (uint256);\n\n /// @notice Contract that generates the non-fungible token URI.\n function nftDescriptor() external view returns (ISablierV2NFTDescriptor);\n\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\n /// of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function refundableAmountOf(\n uint256 streamId\n ) external view returns (uint128 refundableAmount);\n\n /// @notice Retrieves the stream's status.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function statusOf(\n uint256 streamId\n ) external view returns (Lockup.Status status);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n ///\n /// Notes:\n /// - Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\n /// to the total amount withdrawn.\n ///\n /// @param streamId The stream ID for the query.\n function streamedAmountOf(\n uint256 streamId\n ) external view returns (uint128 streamedAmount);\n\n /// @notice Retrieves a flag indicating whether the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function wasCanceled(uint256 streamId) external view returns (bool result);\n\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\n /// decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream ID for the query.\n function withdrawableAmountOf(\n uint256 streamId\n ) external view returns (uint128 withdrawableAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Allows a recipient contract to hook to Sablier when a stream is canceled or when assets are withdrawn.\n /// Useful for implementing contracts that hold streams on behalf of users, such as vaults or staking contracts.\n ///\n /// @dev Emits an {AllowToHook} event.\n ///\n /// Notes:\n /// - Does not revert if the contract is already on the allowlist.\n /// - This is an irreversible operation. The contract cannot be removed from the allowlist.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n /// - `recipient` must have a non-zero code size.\n /// - `recipient` must implement {ISablierLockupRecipient}.\n ///\n /// @param recipient The address of the contract to allow for hooks.\n function allowToHook(address recipient) external;\n\n /// @notice Burns the NFT associated with the stream.\n ///\n /// @dev Emits a {Transfer} event.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a depleted stream.\n /// - The NFT must exist.\n /// - `msg.sender` must be either the NFT owner or an approved third party.\n ///\n /// @param streamId The ID of the stream NFT to burn.\n function burn(uint256 streamId) external;\n\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\n ///\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\n /// stream is marked as depleted.\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - The stream must be warm and cancelable.\n /// - `msg.sender` must be the stream's sender.\n ///\n /// @param streamId The ID of the stream to cancel.\n function cancel(uint256 streamId) external;\n\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\n ///\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - Refer to the notes in {cancel}.\n ///\n /// Requirements:\n /// - All requirements from {cancel} must be met for each stream.\n ///\n /// @param streamIds The IDs of the streams to cancel.\n function cancelMultiple(uint256[] calldata streamIds) external;\n\n /// @notice Removes the right of the stream's sender to cancel the stream.\n ///\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This is an irreversible operation.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a warm stream.\n /// - `msg.sender` must be the stream's sender.\n /// - The stream must be cancelable.\n ///\n /// @param streamId The ID of the stream to renounce.\n function renounce(uint256 streamId) external;\n\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\n ///\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\n ///\n /// Notes:\n /// - Does not revert if the NFT descriptor is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n function setNFTDescriptor(\n ISablierV2NFTDescriptor newNFTDescriptor\n ) external;\n\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of the stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must not reference a null or depleted stream.\n /// - `to` must not be the zero address.\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\n /// - `to` must be the recipient if `msg.sender` is not the stream's recipient or an approved third party.\n ///\n /// @param streamId The ID of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\n function withdraw(uint256 streamId, address to, uint128 amount) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - Refer to the requirements in {withdraw}.\n ///\n /// @param streamId The ID of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\n function withdrawMax(\n uint256 streamId,\n address to\n ) external returns (uint128 withdrawnAmount);\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\n /// NFT to `newRecipient`.\n ///\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\n ///\n /// Notes:\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - `msg.sender` must be the stream's recipient.\n /// - Refer to the requirements in {withdraw}.\n /// - Refer to the requirements in {IERC721.transferFrom}.\n ///\n /// @param streamId The ID of the stream NFT to transfer.\n /// @param newRecipient The address of the new owner of the stream NFT.\n /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals.\n function withdrawMaxAndTransfer(\n uint256 streamId,\n address newRecipient\n ) external returns (uint128 withdrawnAmount);\n\n /// @notice Withdraws assets from streams to the recipient of each stream.\n ///\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - There must be an equal number of `streamIds` and `amounts`.\n /// - Each stream ID in the array must not reference a null or depleted stream.\n /// - Each amount in the array must be greater than zero and must not exceed the withdrawable amount.\n ///\n /// @param streamIds The IDs of the streams to withdraw from.\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\n function withdrawMultiple(\n uint256[] calldata streamIds,\n uint128[] calldata amounts\n ) external;\n}\n" + }, + "contracts/interfaces/sablier/full/ISablierV2NFTDescriptor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC721Metadata} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\n/// @title ISablierV2NFTDescriptor\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\n/// @dev Inspired by Uniswap V3 Positions NFTs.\ninterface ISablierV2NFTDescriptor {\n /// @notice Produces the URI describing a particular stream NFT.\n /// @dev This is a data URI with the JSON contents directly inlined.\n /// @param sablier The address of the Sablier contract the stream was created in.\n /// @param streamId The ID of the stream for which to produce a description.\n /// @return uri The URI of the ERC721-compliant metadata.\n function tokenURI(\n IERC721Metadata sablier,\n uint256 streamId\n ) external view returns (string memory uri);\n}\n" + }, + "contracts/interfaces/sablier/full/types/DataTypes.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.22;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {UD2x18} from \"@prb/math/src/UD2x18.sol\";\nimport {UD60x18} from \"@prb/math/src/UD60x18.sol\";\n\n// DataTypes.sol\n//\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\n//\n// - Lockup\n// - LockupDynamic\n// - LockupLinear\n// - LockupTranched\n//\n// You will notice that some structs contain \"slot\" annotations - they are used to indicate the\n// storage layout of the struct. It is more gas efficient to group small data types together so\n// that they fit in a single 32-byte slot.\n\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\n/// @param account The address receiving the broker's fee.\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\nstruct Broker {\n address account;\n UD60x18 fee;\n}\n\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\nlibrary Lockup {\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the asset's\n /// decimals.\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in the same slot\n /// saves gas.\n /// @param deposited The initial amount deposited in the stream, net of broker fee.\n /// @param withdrawn The cumulative amount withdrawn from the stream.\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\n struct Amounts {\n // slot 0\n uint128 deposited;\n uint128 withdrawn;\n // slot 1\n uint128 refunded;\n }\n\n /// @notice Struct encapsulating (i) the deposit amount and (ii) the broker fee amount, both denoted in units of the\n /// asset's decimals.\n /// @param deposit The amount to deposit in the stream.\n /// @param brokerFee The broker fee amount.\n struct CreateAmounts {\n uint128 deposit;\n uint128 brokerFee;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING,\n STREAMING,\n SETTLED,\n CANCELED,\n DEPLETED\n }\n\n /// @notice A common data structure to be stored in all {SablierV2Lockup} models.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address distributing the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\nlibrary LockupDynamic {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param segments Segments with durations used to compose the dynamic distribution function. Timestamps are\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n SegmentWithDuration[] segments;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param segments Segments used to compose the dynamic distribution function.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n uint40 startTime;\n Segment[] segments;\n Broker broker;\n }\n\n /// @notice Segment struct used in the Lockup Dynamic stream.\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\n /// @param timestamp The Unix timestamp indicating the segment's end.\n struct Segment {\n // slot 0\n uint128 amount;\n UD2x18 exponent;\n uint40 timestamp;\n }\n\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDurations}.\n /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of the segment, denoted as a fixed-point number.\n /// @param duration The time difference in seconds between the segment and the previous one.\n struct SegmentWithDuration {\n uint128 amount;\n UD2x18 exponent;\n uint40 duration;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the segments.\n struct StreamLD {\n address sender;\n address recipient;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n Segment[] segments;\n }\n\n /// @notice Struct encapsulating the LockupDynamic timestamps.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 end;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\nlibrary LockupLinear {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param durations Struct encapsulating (i) cliff period duration and (ii) total stream duration, both in seconds.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Durations durations;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param timestamps Struct encapsulating (i) the stream's start time, (ii) cliff time, and (iii) end time, all as\n /// Unix timestamps.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the cliff duration and the total duration.\n /// @param cliff The cliff duration in seconds.\n /// @param total The total duration in seconds.\n struct Durations {\n uint40 cliff;\n uint40 total;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the cliff time.\n struct StreamLL {\n address sender;\n address recipient;\n uint40 startTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n uint40 endTime;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n uint40 cliffTime;\n }\n\n /// @notice Struct encapsulating the LockupLinear timestamps.\n /// @param start The Unix timestamp for the stream's start.\n /// @param cliff The Unix timestamp for the cliff period's end. A value of zero means there is no cliff.\n /// @param end The Unix timestamp for the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupTranched}.\nlibrary LockupTranched {\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithDurations} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param tranches Tranches with durations used to compose the tranched distribution function. Timestamps are\n /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n TrancheWithDuration[] tranches;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithTimestamps} function.\n /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be\n /// the same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any\n /// broker fee, denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset to be distributed.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param tranches Tranches used to compose the tranched distribution function.\n /// @param broker Struct encapsulating (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n uint40 startTime;\n Tranche[] tranches;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the full details of a stream.\n /// @dev Extends `Lockup.Stream` by including the recipient and the tranches.\n struct StreamLT {\n address sender;\n address recipient;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n Lockup.Amounts amounts;\n Tranche[] tranches;\n }\n\n /// @notice Struct encapsulating the LockupTranched timestamps.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Timestamps {\n uint40 start;\n uint40 end;\n }\n\n /// @notice Tranche struct used in the Lockup Tranched stream.\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\n /// @param timestamp The Unix timestamp indicating the tranche's end.\n struct Tranche {\n // slot 0\n uint128 amount;\n uint40 timestamp;\n }\n\n /// @notice Tranche struct used at runtime in {SablierV2LockupTranched.createWithDurations}.\n /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals.\n /// @param duration The time difference in seconds between the tranche and the previous one.\n struct TrancheWithDuration {\n uint128 amount;\n uint40 duration;\n }\n}\n" + }, + "contracts/interfaces/sablier/ISablierV2LockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {LockupLinear} from \"./LockupLinear.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface ISablierV2LockupLinear {\n function createWithTimestamps(\n LockupLinear.CreateWithTimestamps calldata params\n ) external returns (uint256 streamId);\n}\n" + }, + "contracts/interfaces/sablier/LockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nlibrary LockupLinear {\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n struct Broker {\n address account;\n uint256 fee;\n }\n}\n" + }, + "contracts/mocks/ERC6551Registry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IERC6551Registry {\n /**\n * @dev The registry MUST emit the ERC6551AccountCreated event upon successful account creation.\n */\n event ERC6551AccountCreated(\n address account,\n address indexed implementation,\n bytes32 salt,\n uint256 chainId,\n address indexed tokenContract,\n uint256 indexed tokenId\n );\n\n /**\n * @dev The registry MUST revert with AccountCreationFailed error if the create2 operation fails.\n */\n error AccountCreationFailed();\n\n /**\n * @dev Creates a token bound account for a non-fungible token.\n *\n * If account has already been created, returns the account address without calling create2.\n *\n * Emits ERC6551AccountCreated event.\n *\n * @return account The address of the token bound account\n */\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address account);\n\n /**\n * @dev Returns the computed token bound account address for a non-fungible token.\n *\n * @return account The address of the token bound account\n */\n function account(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external view returns (address account);\n}\n\ncontract ERC6551Registry is IERC6551Registry {\n function createAccount(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external returns (address) {\n assembly {\n // Memory Layout:\n // ----\n // 0x00 0xff (1 byte)\n // 0x01 registry (address) (20 bytes)\n // 0x15 salt (bytes32) (32 bytes)\n // 0x35 Bytecode Hash (bytes32) (32 bytes)\n // ----\n // 0x55 ERC-1167 Constructor + Header (20 bytes)\n // 0x69 implementation (address) (20 bytes)\n // 0x5D ERC-1167 Footer (15 bytes)\n // 0x8C salt (uint256) (32 bytes)\n // 0xAC chainId (uint256) (32 bytes)\n // 0xCC tokenContract (address) (32 bytes)\n // 0xEC tokenId (uint256) (32 bytes)\n\n // Silence unused variable warnings\n pop(chainId)\n\n // Copy bytecode + constant data to memory\n calldatacopy(0x8c, 0x24, 0x80) // salt, chainId, tokenContract, tokenId\n mstore(0x6c, 0x5af43d82803e903d91602b57fd5bf3) // ERC-1167 footer\n mstore(0x5d, implementation) // implementation\n mstore(0x49, 0x3d60ad80600a3d3981f3363d3d373d3d3d363d73) // ERC-1167 constructor + header\n\n // Copy create2 computation data to memory\n mstore8(0x00, 0xff) // 0xFF\n mstore(0x35, keccak256(0x55, 0xb7)) // keccak256(bytecode)\n mstore(0x01, shl(96, address())) // registry address\n mstore(0x15, salt) // salt\n\n // Compute account address\n let computed := keccak256(0x00, 0x55)\n\n // If the account has not yet been deployed\n if iszero(extcodesize(computed)) {\n // Deploy account contract\n let deployed := create2(0, 0x55, 0xb7, salt)\n\n // Revert if the deployment fails\n if iszero(deployed) {\n mstore(0x00, 0x20188a59) // `AccountCreationFailed()`\n revert(0x1c, 0x04)\n }\n\n // Store account address in memory before salt and chainId\n mstore(0x6c, deployed)\n\n // Emit the ERC6551AccountCreated event\n log4(\n 0x6c,\n 0x60,\n // `ERC6551AccountCreated(address,address,bytes32,uint256,address,uint256)`\n 0x79f19b3655ee38b1ce526556b7731a20c8f218fbda4a3990b6cc4172fdf88722,\n implementation,\n tokenContract,\n tokenId\n )\n\n // Return the account address\n return(0x6c, 0x20)\n }\n\n // Otherwise, return the computed account address\n mstore(0x00, shr(96, shl(96, computed)))\n return(0x00, 0x20)\n }\n }\n\n function account(\n address implementation,\n bytes32 salt,\n uint256 chainId,\n address tokenContract,\n uint256 tokenId\n ) external view returns (address) {\n assembly {\n // Silence unused variable warnings\n pop(chainId)\n pop(tokenContract)\n pop(tokenId)\n\n // Copy bytecode + constant data to memory\n calldatacopy(0x8c, 0x24, 0x80) // salt, chainId, tokenContract, tokenId\n mstore(0x6c, 0x5af43d82803e903d91602b57fd5bf3) // ERC-1167 footer\n mstore(0x5d, implementation) // implementation\n mstore(0x49, 0x3d60ad80600a3d3981f3363d3d373d3d3d363d73) // ERC-1167 constructor + header\n\n // Copy create2 computation data to memory\n mstore8(0x00, 0xff) // 0xFF\n mstore(0x35, keccak256(0x55, 0xb7)) // keccak256(bytecode)\n mstore(0x01, shl(96, address())) // registry address\n mstore(0x15, salt) // salt\n\n // Store computed account address in memory\n mstore(0x00, shr(96, shl(96, keccak256(0x00, 0x55))))\n\n // Return computed account address\n return(0x00, 0x20)\n }\n }\n}\n" + }, + "contracts/mocks/MockContract.sol": { + "content": "//SPDX-License-Identifier: Unlicense\n\npragma solidity ^0.8.19;\n\n/**\n * Mock contract for testing\n */\ncontract MockContract {\n event DidSomething(string message);\n\n error Reverting();\n\n function doSomething() public {\n doSomethingWithParam(\"doSomething()\");\n }\n\n function doSomethingWithParam(string memory _message) public {\n emit DidSomething(_message);\n }\n\n function returnSomething(string memory _s)\n external\n pure\n returns (string memory)\n {\n return _s;\n }\n\n function revertSomething() external pure {\n revert Reverting();\n }\n}\n" + }, + "contracts/mocks/MockLockupLinear.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nlibrary MockLockupLinear {\n struct CreateWithTimestamps {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Timestamps timestamps;\n Broker broker;\n }\n\n struct Timestamps {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n struct Broker {\n address account;\n uint256 fee;\n }\n\n struct Stream {\n address sender;\n uint40 startTime;\n uint40 endTime;\n uint40 cliffTime;\n bool cancelable;\n bool wasCanceled;\n address asset;\n bool transferable;\n uint128 totalAmount;\n address recipient;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value0 PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value1 STREAMING Active stream where assets are currently being streamed.\n /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING,\n STREAMING,\n SETTLED,\n CANCELED,\n DEPLETED\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file From 8dd38150ef6041c8c37cda26a12d1da240e03add Mon Sep 17 00:00:00 2001 From: Kellar Date: Thu, 10 Oct 2024 17:50:11 +0100 Subject: [PATCH 3/3] Bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8b4f73ef..acf53bf0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@fractal-framework/fractal-contracts", - "version": "1.2.14", + "version": "1.2.15", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@fractal-framework/fractal-contracts", - "version": "1.2.14", + "version": "1.2.15", "license": "MIT", "devDependencies": { "@gnosis.pm/zodiac": "^1.1.4", diff --git a/package.json b/package.json index de81f04e..44ccd3d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fractal-framework/fractal-contracts", - "version": "1.2.14", + "version": "1.2.15", "files": [ "publish", "contracts",