{"language":"Solidity","sources":{"src/FountainMarket.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.24;\n\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {IERC2981} from \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\nimport {Ownable, Ownable2Step} from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\nimport {Pausable} from \"@openzeppelin/contracts/utils/Pausable.sol\";\nimport {ReentrancyGuard} from \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\n\n/**\n * @title FOUNTAIN Market\n * @notice Fixed-price, non-custodial marketplace for one collection (FOUNTAIN).\n *  - Sellers keep their NFT until it sells (approval-based listings).\n *  - Buy one or many listings in one transaction, or buy the N cheapest (\"floor\") in one call.\n *  - ERC-2981 royalty is paid on every sale; optional marketplace fee (starts at 0, hard cap 5%).\n *  - Stale listings (token moved or approval revoked) are skipped and can be cleaned by anyone.\n *  - A seller whose payout reverts is credited instead (withdrawProceeds), so one bad seller cannot block buyers.\n *  - pause() stops new listings and buys; cancelling and withdrawing always work.\n */\ncontract FountainMarket is Ownable2Step, Pausable, ReentrancyGuard {\n    struct Listing {\n        address seller;\n        uint96 index; // position + 1 in `_listed`; 0 = not listed\n        uint256 price; // wei\n    }\n\n    struct ListingView {\n        uint256 tokenId;\n        address seller;\n        uint256 price;\n    }\n\n    IERC721 public immutable nft;\n    uint256 public constant MAX_FEE_BPS = 500; // 5%\n    uint256 public constant MAX_BATCH = 20;\n\n    uint256 public feeBps;\n    address public feeRecipient;\n\n    mapping(uint256 => Listing) private _listings;\n    uint256[] private _listed;\n    mapping(address => uint256) public proceeds;\n\n    event Listed(uint256 indexed tokenId, address indexed seller, uint256 price);\n    event Cancelled(uint256 indexed tokenId, address indexed by);\n    event Sold(uint256 indexed tokenId, address indexed seller, address indexed buyer, uint256 price, uint256 royalty, uint256 fee);\n    event FeeUpdated(uint256 feeBps, address feeRecipient);\n    event ProceedsCredited(address indexed account, uint256 amount);\n    event ProceedsWithdrawn(address indexed account, uint256 amount);\n\n    error ZeroAddress();\n    error FeeTooHigh();\n    error LengthMismatch();\n    error BadBatch();\n    error ZeroPrice();\n    error NotTokenOwner(uint256 tokenId);\n    error NotApproved(uint256 tokenId);\n    error NotListed(uint256 tokenId);\n    error ListingInvalid(uint256 tokenId);\n    error OwnListing(uint256 tokenId);\n    error NotAuthorized(uint256 tokenId);\n    error StillValid(uint256 tokenId);\n    error PriceAboveMax(uint256 total, uint256 maxTotal);\n    error WrongPayment(uint256 sent, uint256 needed);\n    error NotEnoughListings(uint256 available, uint256 wanted);\n    error NothingToWithdraw();\n    error TransferFailed();\n\n    constructor(address nft_, address owner_, address feeRecipient_, uint256 feeBps_) Ownable(owner_) {\n        if (nft_ == address(0) || feeRecipient_ == address(0)) revert ZeroAddress();\n        if (feeBps_ > MAX_FEE_BPS) revert FeeTooHigh();\n        nft = IERC721(nft_);\n        feeRecipient = feeRecipient_;\n        feeBps = feeBps_;\n        emit FeeUpdated(feeBps_, feeRecipient_);\n    }\n\n    /* ----------------------------- Sell ----------------------------- */\n\n    /// @notice List or re-price tokens you own. Approve this market on the NFT first (setApprovalForAll).\n    function list(uint256[] calldata tokenIds, uint256[] calldata prices) external whenNotPaused {\n        uint256 n = tokenIds.length;\n        if (n == 0 || n > MAX_BATCH) revert BadBatch();\n        if (n != prices.length) revert LengthMismatch();\n        for (uint256 i; i < n; ++i) {\n            uint256 id = tokenIds[i];\n            uint256 price = prices[i];\n            if (price == 0) revert ZeroPrice();\n            if (nft.ownerOf(id) != msg.sender) revert NotTokenOwner(id);\n            if (!_approved(msg.sender, id)) revert NotApproved(id);\n            Listing storage l = _listings[id];\n            if (l.index == 0) {\n                _listed.push(id);\n                l.index = uint96(_listed.length);\n            }\n            l.seller = msg.sender;\n            l.price = price;\n            emit Listed(id, msg.sender, price);\n        }\n    }\n\n    /// @notice Cancel listings. Allowed for the seller or the token's current owner.\n    function cancel(uint256[] calldata tokenIds) external {\n        uint256 n = tokenIds.length;\n        if (n == 0 || n > MAX_BATCH) revert BadBatch();\n        for (uint256 i; i < n; ++i) {\n            uint256 id = tokenIds[i];\n            Listing storage l = _listings[id];\n            if (l.index == 0) revert NotListed(id);\n            if (msg.sender != l.seller && msg.sender != _ownerOf(id)) revert NotAuthorized(id);\n            _remove(id);\n            emit Cancelled(id, msg.sender);\n        }\n    }\n\n    /// @notice Anyone may remove listings that can no longer be filled.\n    function cleanup(uint256[] calldata tokenIds) external {\n        uint256 n = tokenIds.length;\n        if (n == 0 || n > MAX_BATCH) revert BadBatch();\n        for (uint256 i; i < n; ++i) {\n            uint256 id = tokenIds[i];\n            if (_listings[id].index == 0) revert NotListed(id);\n            if (_valid(id)) revert StillValid(id);\n            _remove(id);\n            emit Cancelled(id, msg.sender);\n        }\n    }\n\n    /* ----------------------------- Buy ------------------------------ */\n\n    /// @notice Buy specific listings. Send exactly the sum of their prices.\n    function buy(uint256[] calldata tokenIds, uint256 maxTotal) external payable nonReentrant whenNotPaused {\n        uint256 n = tokenIds.length;\n        if (n == 0 || n > MAX_BATCH) revert BadBatch();\n        uint256 total;\n        for (uint256 i; i < n; ++i) total += _listings[tokenIds[i]].price;\n        if (total > maxTotal) revert PriceAboveMax(total, maxTotal);\n        if (msg.value != total) revert WrongPayment(msg.value, total);\n        for (uint256 i; i < n; ++i) _fill(tokenIds[i]);\n    }\n\n    /// @notice Buy the `quantity` cheapest valid listings. Send at least their total (see quoteFloor);\n    ///         anything above the actual total is refunded. Reverts if the total exceeds maxTotal.\n    function buyFloor(uint256 quantity, uint256 maxTotal) external payable nonReentrant whenNotPaused {\n        if (quantity == 0 || quantity > MAX_BATCH) revert BadBatch();\n        (uint256[] memory ids, uint256 total) = _floor(quantity, msg.sender);\n        if (total > maxTotal) revert PriceAboveMax(total, maxTotal);\n        if (msg.value < total) revert WrongPayment(msg.value, total);\n        for (uint256 i; i < ids.length; ++i) _fill(ids[i]);\n        uint256 refund = msg.value - total;\n        if (refund > 0) {\n            (bool ok,) = payable(msg.sender).call{value: refund}(\"\");\n            if (!ok) revert TransferFailed();\n        }\n    }\n\n    function withdrawProceeds() external nonReentrant {\n        uint256 amt = proceeds[msg.sender];\n        if (amt == 0) revert NothingToWithdraw();\n        proceeds[msg.sender] = 0;\n        (bool ok,) = payable(msg.sender).call{value: amt}(\"\");\n        if (!ok) revert TransferFailed();\n        emit ProceedsWithdrawn(msg.sender, amt);\n    }\n\n    /* ----------------------------- Views ---------------------------- */\n\n    /// @notice The `quantity` cheapest fillable listings for `buyer` (excludes the buyer's own) and their total.\n    function quoteFloor(uint256 quantity, address buyer) external view returns (uint256[] memory tokenIds, uint256 total) {\n        if (quantity == 0 || quantity > MAX_BATCH) revert BadBatch();\n        return _floor(quantity, buyer);\n    }\n\n    function getListing(uint256 tokenId) external view returns (address seller, uint256 price, bool listed, bool valid) {\n        Listing storage l = _listings[tokenId];\n        return (l.seller, l.price, l.index != 0, l.index != 0 && _valid(tokenId));\n    }\n\n    /// @notice Fillable listings in storage order, paged over the raw list.\n    function getListings(uint256 offset, uint256 limit) external view returns (ListingView[] memory out, uint256 rawTotal) {\n        rawTotal = _listed.length;\n        if (offset >= rawTotal || limit == 0) return (new ListingView[](0), rawTotal);\n        uint256 end = offset + limit > rawTotal ? rawTotal : offset + limit;\n        ListingView[] memory tmp = new ListingView[](end - offset);\n        uint256 k;\n        for (uint256 i = offset; i < end; ++i) {\n            uint256 id = _listed[i];\n            if (_valid(id)) tmp[k++] = ListingView(id, _listings[id].seller, _listings[id].price);\n        }\n        assembly { mstore(tmp, k) }\n        return (tmp, rawTotal);\n    }\n\n    function listedCount() external view returns (uint256) {\n        return _listed.length;\n    }\n\n    /// @notice Helper for agents: token IDs in [fromId, toId] owned by `owner`, and whether each is listed.\n    ///         Read-only (call it with eth_call; costs no gas). Range capped at 1000 IDs per call.\n    function ownedTokens(address owner_, uint256 fromId, uint256 toId)\n        external\n        view\n        returns (uint256[] memory tokenIds, bool[] memory listed)\n    {\n        if (toId < fromId || toId - fromId >= 1000) revert BadBatch();\n        uint256[] memory tmp = new uint256[](toId - fromId + 1);\n        uint256 n;\n        for (uint256 id = fromId; id <= toId; ++id) {\n            try nft.ownerOf(id) returns (address a) {\n                if (a == owner_) tmp[n++] = id;\n            } catch {}\n        }\n        tokenIds = new uint256[](n);\n        listed = new bool[](n);\n        for (uint256 i; i < n; ++i) {\n            tokenIds[i] = tmp[i];\n            listed[i] = _listings[tmp[i]].seller == owner_ && _listings[tmp[i]].price != 0;\n        }\n    }\n\n    /// @notice Lowest fillable price (0 when nothing is listed) and the number of fillable listings.\n    function stats() external view returns (uint256 floorPrice, uint256 validCount) {\n        uint256 len = _listed.length;\n        for (uint256 i; i < len; ++i) {\n            uint256 id = _listed[i];\n            if (!_valid(id)) continue;\n            uint256 p = _listings[id].price;\n            if (validCount == 0 || p < floorPrice) floorPrice = p;\n            ++validCount;\n        }\n    }\n\n    /* ----------------------------- Admin ---------------------------- */\n\n    function setFee(uint256 feeBps_, address feeRecipient_) external onlyOwner {\n        if (feeRecipient_ == address(0)) revert ZeroAddress();\n        if (feeBps_ > MAX_FEE_BPS) revert FeeTooHigh();\n        feeBps = feeBps_;\n        feeRecipient = feeRecipient_;\n        emit FeeUpdated(feeBps_, feeRecipient_);\n    }\n\n    function pause() external onlyOwner {\n        _pause();\n    }\n\n    function unpause() external onlyOwner {\n        _unpause();\n    }\n\n    function renounceOwnership() public view override onlyOwner {\n        revert NotAuthorized(0);\n    }\n\n    /* ---------------------------- Internal -------------------------- */\n\n    function _fill(uint256 id) private {\n        Listing memory l = _listings[id];\n        if (l.index == 0) revert NotListed(id);\n        if (!_valid(id)) revert ListingInvalid(id);\n        if (l.seller == msg.sender) revert OwnListing(id);\n        _remove(id);\n\n        uint256 royalty;\n        address royaltyTo;\n        try IERC2981(address(nft)).royaltyInfo(id, l.price) returns (address r, uint256 a) {\n            if (r != address(0) && a <= l.price) (royaltyTo, royalty) = (r, a);\n        } catch {}\n        uint256 fee = (l.price * feeBps) / 10_000;\n        if (royalty + fee > l.price) fee = l.price - royalty;\n\n        nft.safeTransferFrom(l.seller, msg.sender, id);\n\n        _pay(royaltyTo, royalty);\n        _pay(feeRecipient, fee);\n        _pay(l.seller, l.price - royalty - fee);\n        emit Sold(id, l.seller, msg.sender, l.price, royalty, fee);\n    }\n\n    function _pay(address to, uint256 amt) private {\n        if (amt == 0) return;\n        (bool ok,) = payable(to).call{value: amt, gas: 30_000}(\"\");\n        if (!ok) {\n            proceeds[to] += amt;\n            emit ProceedsCredited(to, amt);\n        }\n    }\n\n    function _floor(uint256 quantity, address buyer) private view returns (uint256[] memory ids, uint256 total) {\n        uint256 len = _listed.length;\n        uint256[] memory cid = new uint256[](len);\n        uint256[] memory cp = new uint256[](len);\n        uint256 c;\n        for (uint256 i; i < len; ++i) {\n            uint256 id = _listed[i];\n            Listing storage l = _listings[id];\n            if (l.seller == buyer || !_valid(id)) continue;\n            cid[c] = id;\n            cp[c] = l.price;\n            ++c;\n        }\n        if (c < quantity) revert NotEnoughListings(c, quantity);\n        ids = new uint256[](quantity);\n        for (uint256 k; k < quantity; ++k) {\n            uint256 best = k;\n            for (uint256 j = k + 1; j < c; ++j) {\n                if (cp[j] < cp[best] || (cp[j] == cp[best] && cid[j] < cid[best])) best = j;\n            }\n            (cid[k], cid[best]) = (cid[best], cid[k]);\n            (cp[k], cp[best]) = (cp[best], cp[k]);\n            ids[k] = cid[k];\n            total += cp[k];\n        }\n    }\n\n    function _remove(uint256 id) private {\n        uint256 idx = _listings[id].index - 1;\n        uint256 last = _listed.length - 1;\n        if (idx != last) {\n            uint256 moved = _listed[last];\n            _listed[idx] = moved;\n            _listings[moved].index = uint96(idx + 1);\n        }\n        _listed.pop();\n        delete _listings[id];\n    }\n\n    function _valid(uint256 id) private view returns (bool) {\n        address seller = _listings[id].seller;\n        return seller != address(0) && _ownerOf(id) == seller && _approved(seller, id);\n    }\n\n    function _approved(address owner_, uint256 id) private view returns (bool) {\n        if (nft.isApprovedForAll(owner_, address(this))) return true;\n        try nft.getApproved(id) returns (address a) {\n            return a == address(this);\n        } catch {\n            return false;\n        }\n    }\n\n    function _ownerOf(uint256 id) private view returns (address o) {\n        try nft.ownerOf(id) returns (address a) {\n            o = a;\n        } catch {}\n    }\n}\n"},"lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC-721 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\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC-721 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\n     *   {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721\n     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n     * understand this adds an external call which potentially creates a reentrancy vulnerability.\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(address from, address to, uint256 tokenId) 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 address zero.\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"},"lib/openzeppelin-contracts/contracts/interfaces/IERC2981.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n */\ninterface IERC2981 is IERC165 {\n    /**\n     * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n     * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n     *\n     * NOTE: ERC-2981 allows setting the royalty to 100% of the price. In that case all the price would be sent to the\n     * royalty receiver and 0 tokens to the seller. Contracts dealing with royalty should consider empty transfers.\n     */\n    function royaltyInfo(\n        uint256 tokenId,\n        uint256 salePrice\n    ) external view returns (address receiver, uint256 royaltyAmount);\n}\n"},"lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.20;\n\nimport {Ownable} from \"./Ownable.sol\";\n\n/**\n * @dev Contract module which provides access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * This extension of the {Ownable} contract includes a two-step mechanism to transfer\n * ownership, where the new owner must call {acceptOwnership} in order to replace the\n * old one. This can help prevent common mistakes, such as transfers of ownership to\n * incorrect accounts, or to contracts that are unable to interact with the\n * permission system.\n *\n * The initial owner is specified at deployment time in the constructor for `Ownable`. This\n * can later be changed with {transferOwnership} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n    address private _pendingOwner;\n\n    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Returns the address of the pending owner.\n     */\n    function pendingOwner() public view virtual returns (address) {\n        return _pendingOwner;\n    }\n\n    /**\n     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n     * Can only be called by the current owner.\n     *\n     * Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.\n     */\n    function transferOwnership(address newOwner) public virtual override onlyOwner {\n        _pendingOwner = newOwner;\n        emit OwnershipTransferStarted(owner(), newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual override {\n        delete _pendingOwner;\n        super._transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev The new owner accepts the ownership transfer.\n     */\n    function acceptOwnership() public virtual {\n        address sender = _msgSender();\n        if (pendingOwner() != sender) {\n            revert OwnableUnauthorizedAccount(sender);\n        }\n        _transferOwnership(sender);\n    }\n}\n"},"lib/openzeppelin-contracts/contracts/utils/Pausable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n    bool private _paused;\n\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    /**\n     * @dev The operation failed because the contract is paused.\n     */\n    error EnforcedPause();\n\n    /**\n     * @dev The operation failed because the contract is not paused.\n     */\n    error ExpectedPause();\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n    constructor() {\n        _paused = false;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        _requireNotPaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        _requirePaused();\n        _;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        if (paused()) {\n            revert EnforcedPause();\n        }\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        if (!paused()) {\n            revert ExpectedPause();\n        }\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        _paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        _paused = false;\n        emit Unpaused(_msgSender());\n    }\n}\n"},"lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,\n * consider using {ReentrancyGuardTransient} instead.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant NOT_ENTERED = 1;\n    uint256 private constant ENTERED = 2;\n\n    uint256 private _status;\n\n    /**\n     * @dev Unauthorized reentrant call.\n     */\n    error ReentrancyGuardReentrantCall();\n\n    constructor() {\n        _status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        // On the first call to nonReentrant, _status will be NOT_ENTERED\n        if (_status == ENTERED) {\n            revert ReentrancyGuardReentrantCall();\n        }\n\n        // Any calls to nonReentrant after this point will fail\n        _status = ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        return _status == ENTERED;\n    }\n}\n"},"lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC-165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[ERC].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"},"lib/openzeppelin-contracts/contracts/access/Ownable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    constructor(address initialOwner) {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"},"lib/openzeppelin-contracts/contracts/utils/Context.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"}},"settings":{"remappings":["@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/","@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","forge-std/=lib/forge-std/src/","lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/","lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/","lib/openzeppelin-contracts-upgradeable/lib/forge-std/:ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/","lib/openzeppelin-contracts-upgradeable/lib/forge-std/:ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/","lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/:erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/erc4626-tests/","lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/:erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/erc4626-tests/","lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/:halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/","lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/:halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/","lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/","lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/","lib/openzeppelin-contracts-upgradeable/:erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/","lib/openzeppelin-contracts-upgradeable/:erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/","lib/openzeppelin-contracts-upgradeable/:halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/","lib/openzeppelin-contracts-upgradeable/:halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/","lib/openzeppelin-contracts-upgradeable/:openzeppelin-contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/","lib/openzeppelin-contracts-upgradeable/:openzeppelin-contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/","lib/openzeppelin-contracts/:erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/","lib/openzeppelin-contracts/:erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/","lib/openzeppelin-contracts/:halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/","lib/openzeppelin-contracts/:halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/","chainlink-brownie-contracts/=lib/chainlink-brownie-contracts/","ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/","erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/","halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/","openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/","openzeppelin-contracts/=lib/openzeppelin-contracts/"],"optimizer":{"enabled":true,"runs":200},"metadata":{"useLiteralContent":false,"bytecodeHash":"ipfs","appendCBOR":true},"outputSelection":{"*":{"*":["abi","evm.bytecode.object","evm.bytecode.sourceMap","evm.bytecode.linkReferences","evm.deployedBytecode.object","evm.deployedBytecode.sourceMap","evm.deployedBytecode.linkReferences","evm.deployedBytecode.immutableReferences","evm.methodIdentifiers","metadata"]}},"evmVersion":"paris","viaIR":false,"libraries":{}}}
