{"file_path":"src/ClaimBridge.sol","creation_status":"success","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\nimport {AccessControlUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport {Initializable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport {UUPSUpgradeable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport {ERC721Upgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\";\nimport {PausableUpgradeable} from \"@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol\";\nimport {ReentrancyGuardUpgradeable} from \"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol\";\n\nimport {IAttestationOracle} from \"./interfaces/IAttestationOracle.sol\";\nimport {ICollateralRegistry} from \"./interfaces/ICollateralRegistry.sol\";\nimport {Config} from \"./libraries/Config.sol\";\nimport {LossEventIds} from \"./libraries/LossEventIds.sol\";\nimport {Roles} from \"./libraries/Roles.sol\";\nimport {IContinuousAccrual} from \"./interfaces/IContinuousAccrual.sol\";\nimport {IAccrualExposure} from \"./interfaces/IAccrualExposure.sol\";\nimport {IAccrualBridge} from \"./interfaces/IAccrualLifecycle.sol\";\nimport {BridgeAccrualLib} from \"./libraries/BridgeAccrualLib.sol\";\nimport {BridgeMixedInterestLib} from \"./libraries/BridgeMixedInterestLib.sol\";\n\n/// @title ClaimBridge - tokenized facility positions (the CALIBER analog, ADR-0006)\n/// @notice Each ERC-721 token is the on-chain position of record for one identified,\n///         lien-perfected facility. THE SYNCHRONIZED MINT GATE (CLAUDE.md section 1.3): a\n///         facility cannot mint unless every attestation kind required for its class is\n///         currently satisfied, and the deal-identity attestations (`AssignmentExecuted`,\n///         `UCCFiled` and `CreditIssued`) commit to EXACTLY the terms being minted (AUDIT\n///         FIX H-4 / P-32 - full payload binding; `Valuation` retains its mark payload), AND all on-chain\n///         conditions hold (class active, LTV and maturity within class parameters, every\n///         concentration limit respected - checked atomically through the registry).\n///         Attestations that merely EXIST at a facility id are not sufficient: they must\n///         attest to this obligor, this class, this amount, this tenor and this lien.\n///         Escrow release is contractually\n///         conditioned off-chain on the existence of this token (legal wrapper section 3).\n///\n///         Positions are transfer-restricted: facilities are held by protocol/SPV\n///         custody addresses; transfers require governance execution, and DEFAULTED or\n///         ACCELERATED positions are frozen entirely.\ncontract ClaimBridge is\n    Initializable,\n    ERC721Upgradeable,\n    PausableUpgradeable,\n    ReentrancyGuardUpgradeable,\n    AccessControlUpgradeable,\n    UUPSUpgradeable,\n    IAccrualBridge\n{\n    enum RateType {\n        Fixed,\n        Variable\n    }\n\n    enum DayCountConvention {\n        Actual360,\n        Actual365,\n        Thirty360\n    }\n\n    enum LoanState {\n        Pending, // minted, awaiting funding\n        Active, // funded, performing\n        Amortizing, // in scheduled repayment\n        Repaid, // closed, made whole\n        Defaulted, // default declared - token frozen\n        Accelerated, // waterfall shifted to acceleration - token frozen\n        Cancelled, // AUDIT FIX (M-02): pending facility retired before funding - NFT burned\n        Resolved // AUDIT FIX (M-03): defaulted facility worked out to full principal recovery\n\n    }\n\n    struct Facility {\n        uint256 classId;\n        bytes32 borrowerId; // stable pseudonymous borrower key (off-chain KYB record)\n        bytes32 stateId; // US state key for tax-credit classes (zero elsewhere)\n        uint256 principal; // 18-dec\n        uint16 ltvBps;\n        // Contractual annual rate for THIS facility, supplied and signed per facility.\n        uint16 interestRateBps;\n        uint64 maturity; // absolute timestamp\n        address fundingRecipient; // attested destination; the servicer cannot redirect funding\n        uint64 paymentInterval; // contractual seconds between scheduled payments\n        uint64 nextPaymentDue; // absolute due date used by permissionless past-due marking\n        RateType rateType;\n        DayCountConvention dayCountConvention;\n        bool renewable;\n        bytes32 paymentScheduleHash; // full amortization schedule\n        bytes32 rateIndexRef; // required for variable-rate facilities\n        bytes32 renewalTermsHash; // required when renewable\n        bytes32 offchainRef; // UCC filing / SPV-series / escrow reference hash\n        LoanState state;\n        /// @notice Whether this facility contractually CAPITALISES unpaid interest (PIK).\n        /// @dev TAIL-APPENDED 2026-09-08. Set once at origination and never amended: `Amendment`\n        ///      deliberately does not carry it, so a cash-pay facility can never be converted into a\n        ///      capitalising one by a later signature. Converting the other way would also be a\n        ///      restructuring, and a restructuring should be a new facility rather than a flag flip.\n        ///\n        ///      IT IS IN THE TERMS HASH, so it is signed by the `CreditIssued` quorum along with the\n        ///      rate. Without it `WaterfallEngine.capitalizePik` had nothing to distinguish a PIK\n        ///      facility from an ordinary cash-pay one, and any address could force PIK accounting\n        ///      onto the cash-pay book: the interest was capitalised into `deployed` AND then paid\n        ///      again in cash through `distribute`, leaving a phantom receivable that only a real\n        ///      charge against curator first-loss could ever clear.\n        bool pik;\n    }\n\n    struct OriginationTerms {\n        uint256 classId;\n        bytes32 borrowerId;\n        bytes32 stateId;\n        uint256 principal;\n        uint16 ltvBps;\n        uint16 interestRateBps;\n        uint64 maturity;\n        address fundingRecipient;\n        uint64 paymentInterval;\n        uint64 nextPaymentDue;\n        RateType rateType;\n        DayCountConvention dayCountConvention;\n        bool renewable;\n        bytes32 paymentScheduleHash;\n        bytes32 rateIndexRef;\n        bytes32 renewalTermsHash;\n        bytes32 offchainRef;\n        /// @notice Whether this facility contractually capitalises unpaid interest. Signed.\n        bool pik;\n    }\n\n    struct Amendment {\n        uint16 interestRateBps;\n        uint64 maturity;\n        uint64 paymentInterval;\n        uint64 nextPaymentDue;\n        RateType rateType;\n        DayCountConvention dayCountConvention;\n        bool renewable;\n        bytes32 paymentScheduleHash;\n        bytes32 rateIndexRef;\n        bytes32 renewalTermsHash;\n    }\n\n    /// @custom:storage-location erc7201:forestroad.storage.ClaimBridge\n    struct BridgeStorage {\n        ICollateralRegistry registry;\n        IAttestationOracle oracle;\n        uint256 nextId;\n        mapping(uint256 tokenId => Facility) facilities;\n        // per-class required attestation kinds for minting (bitmask over\n        // IAttestationOracle.AttestationKind)\n        mapping(uint256 classId => uint256) requiredMintAttestations;\n        // Permanent continuous source, appended after all historical bridge fields.\n        address accrualReserve;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"forestroad.storage.ClaimBridge\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant BRIDGE_STORAGE_LOCATION =\n        0xc9c2da543a2a10e4b712709fb6548fb2c0c97cecbac3457453966d18f1663f00;\n\n    /// @dev AUDIT FIX (section 3.1 reconstructability): carries the full originated terms so\n    ///      the register - including WHEN principal is due (`maturity`) and WHICH\n    ///      perfected lien backs it (`offchainRef`) - is reconstructable purely from\n    ///      events, not only from the mutable `facility()` view.\n    event Originated(uint256 indexed tokenId, uint256 indexed classId, bytes32 indexed borrowerId, bytes32 termsHash);\n    event NextPaymentDueSet(uint256 indexed tokenId, uint64 previousDue, uint64 nextDue);\n    event TermsAmended(uint256 indexed tokenId, bytes32 indexed amendmentId, bytes32 termsHash);\n    event StateChanged(uint256 indexed tokenId, LoanState from, LoanState to);\n    event RequiredAttestationsSet(uint256 indexed classId, uint256 kindsMask);\n    /// @notice Governance permanently bound this bridge's authenticated accrual source.\n    event AccrualReserveSet(address indexed reserve);\n    /// @notice Governance permanently bound the borrower-payout policy used at origination.\n    event BorrowerPayoutRegistrySet(address indexed registry);\n    event MixedInterestOriginationPrepared(uint256 indexed tokenId, bytes32 indexed termsHash);\n    /// @notice Exact staged cash/PIK metadata; activated only by a later matching origination or amendment log.\n    event MixedInterestTermsStaged(\n        uint256 indexed facilityId,\n        bytes32 indexed actionId,\n        bytes32 indexed termsHash,\n        uint16 cashRateBps,\n        uint16 pikRateBps,\n        uint64 cashPaymentInterval,\n        uint64 nextCashPaymentDue,\n        uint64 pikCapitalizationInterval,\n        uint64 nextPikCapitalization\n    );\n    event MixedInterestOriginationCancelled(uint256 indexed tokenId);\n    event MixedInterestAmendmentPrepared(\n        uint256 indexed tokenId, bytes32 indexed amendmentId, bytes32 indexed termsHash\n    );\n\n    /// @dev Number of `IAttestationOracle.AttestationKind` values. The mint-gate setter and the\n    ///      `originate` gate loop BOTH derive from this, so a future kind cannot be accepted by\n    ///      governance while remaining unread by the gate (PM-R-09).\n    uint256 private constant KIND_COUNT = 9;\n    /// @dev Every valid attestation-kind bit set.\n    uint256 private constant KINDS_MASK_ALL = (1 << KIND_COUNT) - 1;\n    /// @dev AUDIT FIX (H-4): the `CreditIssued` bit. This kind is the TERMS attestation -\n    ///      the 2-of-n quorum that authorizes an amount for a counterparty - so it is\n    ///      mandatory in every class's mint gate and its payload is bound in `originate`.\n    uint256 private constant BIT_CREDIT_ISSUED = 1 << uint256(uint8(IAttestationOracle.AttestationKind.CreditIssued));\n\n    error Bridge_ZeroAddress();\n    /// @notice A mint-gate mask carried bits outside the known `AttestationKind` range, or was\n    ///         empty. Either would leave the gate weaker than it reads (PM-R-09).\n    /// @param kindsMask The rejected mask.\n    error Bridge_BadAttestationMask(uint256 kindsMask);\n    error Bridge_BadFacility();\n    /// @notice Legacy PIK coupon dates can change only after migration to the native lifecycle.\n    error Bridge_LegacyPikScheduleRequiresMigration(uint256 tokenId);\n    error Bridge_AttestationMissing(uint256 classId, IAttestationOracle.AttestationKind kind);\n    /// @notice AUDIT FIX (H-4): the currently-satisfied `CreditIssued` attestation at this\n    ///         facility id does not commit to THESE terms. Either no terms were attested, or\n    ///         the attested terms describe a different obligor/class/amount/tenor/lien.\n    /// @param facilityId The facility id the gate read.\n    /// @param expected The terms hash of the facility being originated/funded.\n    /// @param attested The terms hash actually carried by the attestation (zero if none).\n    error Bridge_TermsNotAttested(uint256 facilityId, bytes32 expected, bytes32 attested);\n    /// @notice A deal-identity attestation is present but commits to different terms.\n    /// @param classId The collateral class whose mint gate failed.\n    /// @param kind The deal-identity attestation kind.\n    /// @param expected The terms hash of the facility being originated/funded.\n    /// @param attested The terms hash carried by the attestation.\n    error Bridge_AttestationNotBoundToDeal(\n        uint256 classId, IAttestationOracle.AttestationKind kind, bytes32 expected, bytes32 attested\n    );\n    error Bridge_ValuationStale(uint256 tokenIdOrZero, uint64 asOf, uint64 maxAge);\n    error Bridge_LtvExceedsValue(uint256 principal, uint256 maxByValue);\n    error Bridge_InvalidTransition(uint256 tokenId, LoanState from, LoanState to);\n    error Bridge_PositionFrozen(uint256 tokenId);\n    error Bridge_TransferRestricted();\n    error Bridge_UnknownToken(uint256 tokenId);\n    error Bridge_FacilityMatured(uint256 tokenId);\n    error Bridge_ClassInactive(uint256 classId);\n    error Bridge_NotPending(uint256 tokenId);\n    error Bridge_TermsAmendmentNotAttested(uint256 tokenId);\n    error Bridge_FacilityEventNamespaceExhausted(uint256 nextId);\n    /// @notice The continuous accounting source cannot be replaced after binding.\n    error Bridge_AccrualAlreadyBound();\n    /// @notice Only the bound source can advance its signed PIK capitalization schedule.\n    error Bridge_AccrualReserveOnly(address caller);\n    /// @notice A live continuous facility must use the supported fixed-rate day-count scope.\n    error Bridge_AccrualUnsupportedTerms(uint256 tokenId);\n    /// @notice A continuous PIK schedule advances only through its accounting source or signed amendment.\n    error Bridge_AccrualDueManaged(uint256 tokenId);\n    /// @notice A mixed facility must retain both legs through its dedicated lifecycle entry point.\n    error Bridge_MixedLifecycleRequired(uint256 tokenId);\n    /// @notice Activation requires the enabled, fresh and version-matched continuous system.\n    error Bridge_MixedInterestUnavailable();\n\n    uint16 public constant MAX_INTEREST_RATE_BPS = 10_000;\n    bytes32 private constant _MIXED_INTEREST_VERSION = keccak256(\"forestroad.mixed-interest.v1\");\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    /// @notice Initializes the position register.\n    /// @param admin Governance timelock.\n    /// @param guardian Emergency pauser.\n    /// @param upgrader Upgrade authority (timelock).\n    /// @param registry The collateral registry (class params + concentration).\n    /// @param oracle The attestation oracle (mint gate; ADR-0007 trust note applies).\n    function initialize(address admin, address guardian, address upgrader, address registry, address oracle)\n        external\n        initializer\n    {\n        if (\n            admin == address(0) || guardian == address(0) || upgrader == address(0) || registry == address(0)\n                || oracle == address(0)\n        ) revert Bridge_ZeroAddress();\n        __ERC721_init(\"Forest Road Facility\", \"frFACILITY\");\n        __Pausable_init();\n        __ReentrancyGuard_init();\n        __AccessControl_init();\n        __UUPSUpgradeable_init();\n        _grantRole(DEFAULT_ADMIN_ROLE, admin);\n        _grantRole(Roles.GUARDIAN_ROLE, guardian);\n        _grantRole(Roles.UPGRADER_ROLE, upgrader);\n        BridgeStorage storage $ = _storage();\n        $.registry = ICollateralRegistry(registry);\n        $.oracle = IAttestationOracle(oracle);\n        $.nextId = 1;\n    }\n\n    // -- governance -------------------------------------------------------\n\n    /// @notice Permanently binds the reserve after the underlying token has bound that same source.\n    /// @param reserve The already configured reserve proxy for this bridge's native module routes.\n    function setAccrualReserve(address reserve) external onlyRole(DEFAULT_ADMIN_ROLE) {\n        BridgeStorage storage $ = _storage();\n        if ($.accrualReserve != address(0)) revert Bridge_AccrualAlreadyBound();\n        BridgeAccrualLib.validate(reserve, address($.registry), address($.oracle));\n        IAccrualExposure(reserve).requireAccrualIdle();\n        $.accrualReserve = reserve;\n        emit AccrualReserveSet(reserve);\n    }\n\n    /// @notice The permanent accounting source, or zero before continuous accrual is bound.\n    function accrualReserve() external view returns (address) {\n        return _storage().accrualReserve;\n    }\n\n    /// @notice Permanently binds the timelock-managed borrower-payout registry.\n    function setBorrowerPayoutRegistry(address registry) external onlyRole(DEFAULT_ADMIN_ROLE) {\n        // The library returns the bound address only to keep the delegatecall compact. Binding\n        // either validates, stores and emits, or reverts; the host has no second value to check.\n        BridgeMixedInterestLib.bindBorrowerPayoutRegistry(registry);\n    }\n\n    /// @notice Irreversibly enables new mixed facilities after every accounting module matches.\n    function enableMixedInterest() external onlyRole(DEFAULT_ADMIN_ROLE) {\n        BridgeStorage storage $ = _storage();\n        address reserve = $.accrualReserve;\n        if (reserve == address(0) || !IContinuousAccrual(reserve).accrualSnapshot().enabled) {\n            revert Bridge_MixedInterestUnavailable();\n        }\n        IContinuousAccrual(reserve).requireAccrualFresh();\n        IAccrualExposure(reserve).requireAccrualIdle();\n        BridgeAccrualLib.activateMixed(reserve);\n        BridgeMixedInterestLib.enable();\n    }\n\n    /// @notice Exact cross-module version used by activation and downgrade checks.\n    function mixedInterestVersion() external pure returns (bytes32) {\n        return _MIXED_INTEREST_VERSION;\n    }\n\n    function mixedInterestEnabled() external view returns (bool) {\n        return BridgeMixedInterestLib.enabled();\n    }\n\n    /// @notice Stages the current next id's encoded common and leg terms for attester review.\n    /// @dev `encoded` is `abi.encode(OriginationTerms, InterestLegTerms)`. No facility or exposure\n    ///      exists until the ordinary `originate` call presents the exact common terms.\n    function prepareMixedOrigination(bytes calldata encoded)\n        external\n        onlyRole(Roles.ORIGINATOR_ROLE)\n        whenNotPaused\n        nonReentrant\n        returns (uint256 tokenId, bytes32 termsHash)\n    {\n        _requireAccrualFresh();\n        tokenId = _storage().nextId;\n        termsHash = BridgeMixedInterestLib.stageOrigination(tokenId, encoded);\n        emit MixedInterestOriginationPrepared(tokenId, termsHash);\n    }\n\n    function cancelPreparedMixedOrigination() external onlyRole(Roles.ORIGINATOR_ROLE) nonReentrant {\n        _requireAccrualIdle();\n        uint256 tokenId = _storage().nextId;\n        BridgeMixedInterestLib.clearPreparedOrigination(tokenId);\n        emit MixedInterestOriginationCancelled(tokenId);\n    }\n\n    /// @notice Stages both prospective leg schedules for exact attester review.\n    /// @dev `encoded` is `abi.encode(Amendment, InterestLegTerms)`. Staging alone does not\n    ///      checkpoint, amend or otherwise change a live facility.\n    function prepareMixedAmendment(uint256 tokenId, bytes32 amendmentId, bytes calldata encoded)\n        external\n        onlyRole(Roles.ORIGINATOR_ROLE)\n        whenNotPaused\n        nonReentrant\n        returns (bytes32 termsHash)\n    {\n        _requireAccrualFresh();\n        Facility storage f = _facility(_storage(), tokenId);\n        if (!BridgeMixedInterestLib.configured(tokenId)) revert Bridge_MixedLifecycleRequired(tokenId);\n        if (f.state != LoanState.Active && f.state != LoanState.Amortizing) revert Bridge_BadFacility();\n        if (amendmentId == bytes32(0)) revert Bridge_BadFacility();\n        termsHash = BridgeMixedInterestLib.stageAmendment(tokenId, amendmentId, encoded);\n        emit MixedInterestAmendmentPrepared(tokenId, amendmentId, termsHash);\n    }\n\n    /// @notice Sets the attestation kinds required to mint a facility of `classId`\n    ///         (bitmask over AttestationKind). Timelocked governance only.\n    /// @dev AUDIT FIX (PM-R-09). Previously ANY `uint256` was stored, while `originate` only ever\n    ///      reads bits `0..KIND_COUNT-1`. A mask carrying a high bit therefore READ stricter than\n    ///      it behaved - the silent fail-open class this protocol has been bitten by before. Two\n    ///      rejections now, both fail-loud:\n    ///        - bits outside the known `AttestationKind` range: a governance typo can no longer\n    ///          silently widen the mint gate;\n    ///        - an EMPTY mask: a zero gate makes the section 1.3 \"NFT mint gate\" invariant vacuous for\n    ///          that class (a facility could mint with NO attested off-chain fact at all).\n    ///          `Validate.s.sol` already asserts every class's gate is non-zero; this makes the\n    ///          contract enforce what validation merely checked after the fact.\n    ///\n    ///      AUDIT FIX (H-4): a mask omitting `CreditIssued` is now rejected as well. `originate`\n    ///      binds the facility's TERMS to the `CreditIssued` payload unconditionally, so a class\n    ///      whose declared gate omitted that bit would read weaker than it behaves - and, before\n    ///      the binding existed, such a class (the digital-assets class) had NO attested amount\n    ///      or counterparty at all.\n    /// @param classId The collateral class.\n    /// @param kindsMask Bitmask over `AttestationKind`; must be within `KINDS_MASK_ALL` and\n    ///        must include the `CreditIssued` bit.\n    function setRequiredMintAttestations(uint256 classId, uint256 kindsMask) external onlyRole(DEFAULT_ADMIN_ROLE) {\n        _requireAccrualIdle();\n        if (kindsMask & ~KINDS_MASK_ALL != 0 || kindsMask & BIT_CREDIT_ISSUED == 0) {\n            revert Bridge_BadAttestationMask(kindsMask);\n        }\n        _storage().requiredMintAttestations[classId] = kindsMask;\n        emit RequiredAttestationsSet(classId, kindsMask);\n    }\n\n    // -- origination (THE synchronized mint gate) -------------------------\n\n    /// @notice Mints the position NFT for an underwritten facility - ONLY if every\n    ///         off-chain condition (required attestations, with every deal-identity quorum\n    ///         committing to EXACTLY these terms) AND on-chain condition (class params,\n    ///         LTV, maturity, concentration) holds. Escrow releases off-chain only after\n    ///         this token exists.\n    /// @dev AUDIT FIX (H-4) - FULL PAYLOAD BINDING. The gate previously proved only that\n    ///      attestations EXISTED at the facility id it was about to mint; it never proved\n    ///      they attested to the facility's TERMS. Two consequences, both measured:\n    ///        - SEQUENCE DESYNC: `nextId` only advances on a SUCCESSFUL mint, so a reverted\n    ///          or reordered origination left a fully-attested bundle sitting at the id the\n    ///          next call would read. A completely unattested borrower could then originate\n    ///          against another obligor's attestations (and, for a marked-to-market class,\n    ///          against another obligor's appraisal).\n    ///        - UNBOUNDED PRINCIPAL: for the four Receivable classes nothing on-chain bound\n    ///          the amount at all - `ltvBps <= maxLtvBps` is a ratio with no denominator -\n    ///          so a bundle diligenced for a $500k receivable could mint any principal.\n    ///      Both close by requiring the deal-identity payloads to equal\n    ///      `creditTermsHash(...)` over the exact terms being minted. `Valuation` is excluded\n    ///      because its payload is the mark. This reuses the\n    ///      `latestPayload` primitive already used by the attestation consumers. Note the attested principal IS the on-chain principal bound:\n    ///      the amount is now a signed term, not an originator-chosen input, so the LTV\n    ///      ratio's denominator (`principal * BPS / ltvBps`) is attested too.\n    /// @param holder Custody address for the position (SPV series custodian).\n    /// @param terms Complete contractual and operational facility terms.\n    /// @return tokenId The minted facility id.\n    function originate(address holder, OriginationTerms calldata terms)\n        external\n        onlyRole(Roles.ORIGINATOR_ROLE)\n        whenNotPaused\n        nonReentrant\n        returns (uint256 tokenId)\n    {\n        _requireAccrualFresh();\n        Facility memory f = _facilityFrom(terms);\n        BridgeStorage storage $ = _storage();\n        bytes32 termsHash = BridgeMixedInterestLib.commitment($.nextId);\n        if (termsHash == bytes32(0)) termsHash = _creditTermsHash(f);\n        else termsHash = BridgeMixedInterestLib.preparedOrigination($.nextId, abi.encode(terms));\n        return _originate(holder, f, termsHash);\n    }\n\n    /// @dev The external ABI deliberately exposes each signed term separately. Packing them\n    ///      into the already-storage-compatible `Facility` shape here keeps the gate below\n    ///      Solidity's stack limit without weakening or duplicating any validation.\n    function _originate(address holder, Facility memory f, bytes32 termsHash) private returns (uint256 tokenId) {\n        BridgeStorage storage $ = _storage();\n        bool mixed = BridgeMixedInterestLib.configured($.nextId);\n        if (holder == address(0)) revert Bridge_ZeroAddress();\n        // Facility defaults and protocol custody incidents share SGrove's uint256 event key.\n        // Confining sequential facility ids to the lower half makes the upper incident namespace\n        // structurally disjoint without changing any existing id or increment semantics.\n        if (!LossEventIds.isFacilityEvent($.nextId)) {\n            revert Bridge_FacilityEventNamespaceExhausted($.nextId);\n        }\n        if (\n            // State concentration is meaningful for tax-credit facilities only. A tax-credit\n            // origination must carry a state key; every other class must carry none, or the\n            // registry's state dimension is either bypassed or polluted by an unrelated class.\n            // THE SCHEDULE MUST CONTAIN AT LEAST ONE WHOLE INTERVAL BEFORE ITS FIRST PAYMENT.\n            // `WaterfallEngine.fund` anchors the PIK cursor at `nextPaymentDue - paymentInterval`\n            // so the capitalisation clock and the payment schedule agree by construction; with\n            // an interval longer than the first due date that subtraction underflows and `fund`\n            // reverts with a bare `Panic(0x11)`, stranding a fully attested facility in `Pending`\n            // with no diagnostic. The cursor write is unconditional, so a CASH-PAY facility was\n            // bricked by it too. Rejecting the terms here fails closed at the earliest point\n            // instead, and every legitimate schedule already satisfies it: `nextPaymentDue` is an\n            // absolute timestamp and `paymentInterval` a duration.\n            f.principal == 0 || f.borrowerId == bytes32(0) || f.fundingRecipient == address(0) || f.interestRateBps == 0\n                || f.interestRateBps > MAX_INTEREST_RATE_BPS || f.paymentInterval == 0\n                || (!mixed && f.paymentInterval > f.nextPaymentDue) || f.paymentScheduleHash == bytes32(0)\n                || f.offchainRef == bytes32(0)\n                || ((f.classId == Config.CLASS_FILM_TAX_CREDITS) == (f.stateId == bytes32(0)))\n        ) revert Bridge_BadFacility();\n\n        // The returned `true` keeps the linked delegatecall free of solc's codeless-target guard.\n        // Admission depends on the call completing; every refusal reverts with the recipient.\n        BridgeMixedInterestLib.requireFundingRecipientAllowed(f.fundingRecipient);\n\n        // -- on-chain conditions -------------------------------------------\n        ICollateralRegistry.ClassParams memory p = $.registry.classParams(f.classId);\n        if (f.ltvBps == 0 || f.ltvBps > p.maxLtvBps) revert Bridge_BadFacility();\n        if (f.maturity <= block.timestamp || f.maturity > block.timestamp + p.maxMaturity) {\n            revert Bridge_BadFacility();\n        }\n        if (f.nextPaymentDue <= block.timestamp || f.nextPaymentDue > f.maturity) revert Bridge_BadFacility();\n        if (f.rateType == RateType.Variable && f.rateIndexRef == bytes32(0)) revert Bridge_BadFacility();\n        if (f.rateType == RateType.Fixed && f.rateIndexRef != bytes32(0)) revert Bridge_BadFacility();\n        if (f.renewable != (f.renewalTermsHash != bytes32(0))) revert Bridge_BadFacility();\n        // PIK ONLY SERVICES FIXED / ACTUAL-360, SO REFUSE THE COMBINATION AT THE DOOR.\n        // `WaterfallEngine._planPik` reverts `Waterfall_PikRateTypeUnsupported` and\n        // `Waterfall_PikDayCountUnsupported` for anything else, and `capitalizePik` is the ONLY\n        // writer of `nextPaymentDue` for a PIK facility. Without this check a PIK facility could be\n        // created, or amended into, a shape whose crank can never run: the schedule would stop\n        // advancing immediately and the borrower would become permissionlessly markable past due,\n        // for a term combination the PROTOCOL has not implemented rather than anything they did.\n        //\n        // `pik` is set once at origination and `Amendment` deliberately does not carry it, so the\n        // two sides of this check can never be amended apart. Added 2026-09-10 after an adversarial\n        // round found the resulting freeze as the SEVENTH member of the PIK liveness family; the\n        // sheltering half of the fix is in `WaterfallEngine.pikCrankBlockedByProtocol`, and this is\n        // the half that stops the state arising at all.\n        if (f.pik && (f.rateType != RateType.Fixed || f.dayCountConvention != DayCountConvention.Actual360)) {\n            revert Bridge_BadFacility();\n        }\n        // AND THE THIRD SCOPE CONDITION, WHICH THE FIRST VERSION OF THIS GATE MISSED. `_planPik`\n        // enforces THREE things, not two: Fixed, Actual-360, and a RECEIVABLE class. Gating only\n        // the first two let a PIK facility be originated and FUNDED into a marked-to-market class,\n        // where it could then take interest in neither form: every `capitalizePik` reverts\n        // `Waterfall_PikClassNotReceivable`, and `distribute` refuses any PIK facility carrying an\n        // interest leg. A funded loan that can never earn or receive a wei, with nothing anywhere\n        // saying so. `CLASS_DIGITAL_ASSETS` is MarkedToMarket and active on this instance too, so\n        // this was reachable rather than theoretical, and it CANNOT be repaired afterwards: `pik`\n        // is written once at origination and the class is not amendable. Found by an adversarial\n        // round 2026-09-10, measured on a 500,000e18 digital-asset facility.\n        if (f.pik && p.model != ICollateralRegistry.CollateralModel.Receivable) revert Bridge_BadFacility();\n\n        // -- off-chain conditions: required attestations, all satisfied NOW -\n        // AUDIT FIX (P-32): every deal-identity attestation is bound to the same terms hash.\n        // Valuation is deliberately excluded: its payload is the mark, not a deal identity.\n        _requireMintAttestations($, f.classId, $.nextId, termsHash);\n\n        // -- marked-to-market extension (ADR-0015): fresh mark, value-bounded draw -\n        if (p.model == ICollateralRegistry.CollateralModel.MarkedToMarket) {\n            (uint256 value, uint64 asOf) = $.oracle.latestValuation($.nextId);\n            if (asOf == 0 || block.timestamp - asOf > p.maxMarkAge) {\n                revert Bridge_ValuationStale(0, asOf, p.maxMarkAge);\n            }\n            uint256 maxByValue = value * f.ltvBps / Config.BPS;\n            if (f.principal > maxByValue) revert Bridge_LtvExceedsValue(f.principal, maxByValue);\n        }\n\n        // -- concentration: enforced atomically in the registry ------------\n        $.registry.recordExposureIncrease(f.classId, f.borrowerId, f.stateId, f.principal);\n\n        tokenId = $.nextId++;\n        $.facilities[tokenId] = f;\n        _safeMint(holder, tokenId);\n        emit Originated(tokenId, f.classId, f.borrowerId, termsHash);\n    }\n\n    /// @notice Re-validates that a PENDING facility still satisfies its origination gate\n    ///         immediately before funding (AUDIT FIX M-01). Origination checks are\n    ///         point-in-time; a facility can sit pending while state decays. This re-runs\n    ///         the time-sensitive gates - class still active, maturity and the first payment\n    ///         due date not passed, every required attestation STILL satisfied (a revoked one\n    ///         now blocks funding), and\n    ///         for a marked-to-market class the mark still fresh and the draw still within\n    ///         the value bound - so capital never deploys against stale/expired state.\n    ///         Reverts on the first failure; `WaterfallEngine.fund` calls it before deploying.\n    /// @dev AUDIT FIX (H-4): re-runs the TERMS BINDING too, against the terms actually stored on\n    ///      the token. Fixing only `originate` would leave the funding path open - this function\n    ///      repeated the same existence-only read, so a facility whose `CreditIssued` quorum was\n    ///      revoked and re-attested to different terms could still draw capital.\n    /// @param tokenId The pending facility about to be funded.\n    function checkFundable(uint256 tokenId) external view {\n        _requireAccrualFresh();\n        BridgeStorage storage $ = _storage();\n        Facility storage f = _facility($, tokenId);\n        if (f.state != LoanState.Pending) revert Bridge_NotPending(tokenId);\n        ICollateralRegistry.ClassParams memory p = $.registry.classParams(f.classId);\n        if (!p.active) revert Bridge_ClassInactive(f.classId);\n        if (f.maturity <= block.timestamp) revert Bridge_FacilityMatured(tokenId);\n        if (f.nextPaymentDue <= block.timestamp) revert Bridge_BadFacility();\n        if (_accrualEnabled($)) _requireAccrualTerms(tokenId, f.pik, f.rateType, f.dayCountConvention);\n\n        // AUDIT FIX (P-32): re-check every deal-identity attestation against the stored terms;\n        // Valuation retains its mark payload and is checked below by its own freshness/value limb.\n        bytes32 expected = BridgeMixedInterestLib.commitment(tokenId);\n        if (expected == bytes32(0)) expected = _creditTermsHash(f);\n        _requireMintAttestations($, f.classId, tokenId, expected);\n\n        if (p.model == ICollateralRegistry.CollateralModel.MarkedToMarket) {\n            (uint256 value, uint64 asOf) = $.oracle.latestValuation(tokenId);\n            if (asOf == 0 || block.timestamp - asOf > p.maxMarkAge) {\n                revert Bridge_ValuationStale(tokenId, asOf, p.maxMarkAge);\n            }\n            uint256 maxByValue = value * f.ltvBps / Config.BPS;\n            if (f.principal > maxByValue) revert Bridge_LtvExceedsValue(f.principal, maxByValue);\n        }\n    }\n\n    /// @notice Retires a PENDING facility that will never be funded (AUDIT FIX M-02):\n    ///         atomically reverses its recorded book exposure and burns the position NFT,\n    ///         so an abandoned or erroneous origination cannot permanently consume\n    ///         class/borrower/state/total concentration headroom. Pending only - a funded\n    ///         facility must run its lifecycle. Originator-gated (symmetric with mint).\n    function cancelPending(uint256 tokenId) external onlyRole(Roles.ORIGINATOR_ROLE) nonReentrant {\n        _requireAccrualIdle();\n        BridgeStorage storage $ = _storage();\n        Facility storage f = _facility($, tokenId);\n        if (f.state != LoanState.Pending) revert Bridge_NotPending(tokenId);\n        // release exposure BEFORE burning: same-tx reversal keeps the concentration book\n        // and the NFT set describing the same reality (registry decrease is CREDIT_ROLE,\n        // which the bridge already holds for origination's increase).\n        $.registry.recordExposureDecrease(f.classId, f.borrowerId, f.stateId, f.principal);\n        f.state = LoanState.Cancelled;\n        emit StateChanged(tokenId, LoanState.Pending, LoanState.Cancelled);\n        _burn(tokenId);\n    }\n\n    // -- lifecycle state machine ------------------------------------------\n\n    /// @notice Advances a facility's lifecycle. Only the credit layer (CREDIT_ROLE -\n    ///         WaterfallEngine/DefaultManager in Phase E). Transitions are a strict\n    ///         guarded machine; anything else reverts.\n    function transitionState(uint256 tokenId, LoanState to) external onlyRole(Roles.CREDIT_ROLE) nonReentrant {\n        _requireAccrualIdle();\n        BridgeStorage storage $ = _storage();\n        Facility storage f = _facility($, tokenId);\n        LoanState from = f.state;\n        bool ok = (from == LoanState.Pending && to == LoanState.Active)\n            || (from == LoanState.Active && to == LoanState.Amortizing)\n            || ((from == LoanState.Active || from == LoanState.Amortizing) && to == LoanState.Repaid)\n            || ((from == LoanState.Active || from == LoanState.Amortizing) && to == LoanState.Defaulted)\n            || (from == LoanState.Defaulted && to == LoanState.Accelerated)\n        // AUDIT FIX (M-03): a defaulted/accelerated facility that recovers its full\n        // outstanding principal closes out to Resolved and unfreezes the position.\n        || ((from == LoanState.Defaulted || from == LoanState.Accelerated) && to == LoanState.Resolved);\n        if (!ok) revert Bridge_InvalidTransition(tokenId, from, to);\n        f.state = to;\n        emit StateChanged(tokenId, from, to);\n    }\n\n    /// @notice Whether a credit operation can presently update the bridge's guarded schedule.\n    /// @dev A temporary operation lock is not evidence that a borrower missed a payment.\n    function creditOperationIdle() external view returns (bool) {\n        return !_reentrancyGuardEntered();\n    }\n\n    /// @notice Advances the due date after an exact, attested payment.\n    function setNextPaymentDue(uint256 tokenId, uint64 nextDue) external onlyRole(Roles.CREDIT_ROLE) nonReentrant {\n        _requireAccrualIdle();\n        BridgeMixedInterestLib.setCashDue(tokenId, nextDue);\n    }\n\n    /// @inheritdoc IAccrualBridge\n    /// @dev This reserve-only continuation runs during bounded keeper accounting. It deliberately\n    ///      has no source-idle or freshness gate; it cannot amend terms, invent a maturity extension,\n    ///      alter cash due dates or accept the coordinator's terminal zero sentinel.\n    function setAccruedPaymentDue(uint256 tokenId, uint64 nextDue) external {\n        BridgeMixedInterestLib.setPikDue(tokenId, nextDue);\n    }\n\n    /// @notice Applies a quorum-attested servicing amendment or renewal.\n    function amendTerms(uint256 tokenId, bytes32 amendmentId, Amendment calldata a)\n        external\n        onlyRole(Roles.ORIGINATOR_ROLE)\n        whenNotPaused\n        nonReentrant\n    {\n        _requireAccrualFresh();\n        BridgeMixedInterestLib.amendTerms(tokenId, amendmentId, abi.encode(a));\n    }\n\n    // -- views ------------------------------------------------------------\n\n    /// @notice Full facility record (reverts for unknown tokens).\n    function facility(uint256 tokenId) external view returns (Facility memory) {\n        return _facility(_storage(), tokenId);\n    }\n\n    /// @notice The `CreditIssued` payload an attester quorum must sign to authorize a facility\n    ///         on EXACTLY these terms (AUDIT FIX H-4). Attester tooling and the mint gate derive\n    ///         the commitment from this one function, so they cannot drift apart.\n    /// @dev The facility id is NOT in the preimage because it is the oracle record's key and is\n    ///      already covered by the EIP-712 digest (`AttestationOracle.attest` hashes\n    ///      `a.facilityId`). The per-facility interest rate IS in the preimage: pricing is a\n    ///      signed loan term, not a collateral-class parameter.\n    /// @param terms Complete contractual and operational facility terms.\n    /// @return The terms commitment.\n    function creditTermsHash(OriginationTerms calldata terms) external pure returns (bytes32) {\n        return keccak256(abi.encode(terms));\n    }\n\n    function mixedInterestTerms(uint256 tokenId)\n        external\n        view\n        returns (BridgeMixedInterestLib.InterestLegTerms memory)\n    {\n        _facility(_storage(), tokenId);\n        return BridgeMixedInterestLib.terms(tokenId);\n    }\n\n    function isMixedInterest(uint256 tokenId) external view returns (bool) {\n        _facility(_storage(), tokenId);\n        return BridgeMixedInterestLib.configured(tokenId);\n    }\n\n    function _creditTermsHash(Facility memory f) private pure returns (bytes32) {\n        OriginationTerms memory t = OriginationTerms({\n            classId: f.classId,\n            borrowerId: f.borrowerId,\n            stateId: f.stateId,\n            principal: f.principal,\n            ltvBps: f.ltvBps,\n            interestRateBps: f.interestRateBps,\n            maturity: f.maturity,\n            fundingRecipient: f.fundingRecipient,\n            paymentInterval: f.paymentInterval,\n            nextPaymentDue: f.nextPaymentDue,\n            rateType: f.rateType,\n            dayCountConvention: f.dayCountConvention,\n            renewable: f.renewable,\n            paymentScheduleHash: f.paymentScheduleHash,\n            rateIndexRef: f.rateIndexRef,\n            renewalTermsHash: f.renewalTermsHash,\n            offchainRef: f.offchainRef,\n            pik: f.pik\n        });\n        return keccak256(abi.encode(t));\n    }\n\n    function _facilityFrom(OriginationTerms calldata terms) private pure returns (Facility memory f) {\n        f.classId = terms.classId;\n        f.borrowerId = terms.borrowerId;\n        f.stateId = terms.stateId;\n        f.principal = terms.principal;\n        f.ltvBps = terms.ltvBps;\n        f.interestRateBps = terms.interestRateBps;\n        f.maturity = terms.maturity;\n        f.fundingRecipient = terms.fundingRecipient;\n        f.paymentInterval = terms.paymentInterval;\n        f.nextPaymentDue = terms.nextPaymentDue;\n        f.rateType = terms.rateType;\n        f.dayCountConvention = terms.dayCountConvention;\n        f.renewable = terms.renewable;\n        f.paymentScheduleHash = terms.paymentScheduleHash;\n        f.rateIndexRef = terms.rateIndexRef;\n        f.renewalTermsHash = terms.renewalTermsHash;\n        f.offchainRef = terms.offchainRef;\n        f.pik = terms.pik;\n        f.state = LoanState.Pending;\n    }\n\n    /// @notice Required mint-attestation mask for a class.\n    function requiredMintAttestations(uint256 classId) external view returns (uint256) {\n        return _storage().requiredMintAttestations[classId];\n    }\n\n    /// @notice Wired module addresses (post-deploy validation aid).\n    function modules() external view returns (address registry, address oracle) {\n        BridgeStorage storage $ = _storage();\n        return (address($.registry), address($.oracle));\n    }\n\n    /// @notice Total facilities ever originated.\n    function totalOriginated() external view returns (uint256) {\n        return _storage().nextId - 1;\n    }\n\n    // -- guardian ---------------------------------------------------------\n\n    /// @notice Pauses origination. Emergency use only.\n    function pause() external onlyRole(Roles.GUARDIAN_ROLE) {\n        _requireAccrualIdle();\n        _pause();\n    }\n\n    /// @notice Unpauses origination.\n    function unpause() external onlyRole(Roles.GUARDIAN_ROLE) {\n        _requireAccrualIdle();\n        _unpause();\n    }\n\n    // -- internals --------------------------------------------------------\n\n    /// @dev Transfer restriction: positions move only under governance execution\n    ///      (custody changes are legal events), and NEVER while frozen\n    ///      (Defaulted/Accelerated) - the on-chain half of the dual-record freeze.\n    function _update(address to, uint256 tokenId, address auth) internal override returns (address from) {\n        _requireAccrualIdle();\n        BridgeStorage storage $ = _storage();\n        address owner = _ownerOf(tokenId);\n        if (owner != address(0)) {\n            LoanState st = $.facilities[tokenId].state;\n            if (st == LoanState.Defaulted || st == LoanState.Accelerated) revert Bridge_PositionFrozen(tokenId);\n            if (to != address(0) && !hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) revert Bridge_TransferRestricted();\n        }\n        return super._update(to, tokenId, auth);\n    }\n\n    /// @dev AUDIT FIX (P-32). Requires every selected mint-gate attestation to be currently\n    ///      satisfied. AssignmentExecuted, UCCFiled and CreditIssued are deal identity facts and\n    ///      must carry the exact `creditTermsHash`; Valuation is intentionally left on its own mark\n    ///      payload and checked by the marked-to-market branch.\n    function _requireMintAttestations(BridgeStorage storage $, uint256 classId, uint256 facilityId, bytes32 termsHash)\n        private\n        view\n    {\n        uint256 mask = $.requiredMintAttestations[classId];\n        // An unset class must satisfy the same mandatory gate as a configured class.\n        if (mask & BIT_CREDIT_ISSUED == 0) revert Bridge_BadAttestationMask(mask);\n        // Preserve the original missing-attestation precedence: a present bit is checked before\n        // any payload comparison, so a genuinely absent documentary fact remains\n        // `Bridge_AttestationMissing` rather than looking like a malformed commitment.\n        for (uint256 k = 0; k < KIND_COUNT; ++k) {\n            if (mask & (1 << k) == 0) continue;\n            IAttestationOracle.AttestationKind kind = IAttestationOracle.AttestationKind(uint8(k));\n            (,, bool ok) = $.oracle.latestPayload(facilityId, kind);\n            if (!ok) revert Bridge_AttestationMissing(classId, kind);\n        }\n\n        // ORDER IS LOAD-BEARING BELOW THIS LINE. DO NOT REORDER, AND DO NOT NARROW THE LOOP ABOVE.\n        //\n        // Both remaining `latestPayload` reads in this function DISCARD the `ok` flag, and that is\n        // safe ONLY because of what the loop above has already done: it reverts\n        // `Bridge_AttestationMissing` for EVERY bit set in `mask`, over the same\n        // `0..KIND_COUNT-1` range these two reads are gated on, and this function is `view` so the\n        // oracle cannot change underneath them. Under those three conditions a dropped `ok` cannot\n        // hide an absent attestation, because an absent one has already reverted.\n        //\n        // Reorder these blocks above the loop, narrow the loop's range or its mask, or make this\n        // function non-view, and BOTH reads below become real defects: a missing attestation would\n        // read as `payload == bytes32(0)` and be compared against `termsHash` rather than refused.\n        // Recorded 2026-09-10 during the first Slither triage on this tree, which dispositioned\n        // these two `unused-return` findings as safe on exactly this reasoning. A property that\n        // holds by ordering has to be stated where someone would break it.\n        //\n        // Check the existing terms-quorum limb first to preserve H-4's established error surface.\n        // Documentary payloads are then checked below; P-32 adds those checks without changing the\n        // diagnostics callers already receive for a mismatched CreditIssued bundle.\n        if (mask & BIT_CREDIT_ISSUED != 0) {\n            (bytes32 payload,,) = $.oracle.latestPayload(facilityId, IAttestationOracle.AttestationKind.CreditIssued);\n            if (payload != termsHash) {\n                revert Bridge_TermsNotAttested(facilityId, termsHash, payload);\n            }\n        }\n\n        for (uint256 k = 0; k < KIND_COUNT; ++k) {\n            if (mask & (1 << k) == 0) continue;\n            IAttestationOracle.AttestationKind kind = IAttestationOracle.AttestationKind(uint8(k));\n            if (_isDealIdentityKind(kind) && kind != IAttestationOracle.AttestationKind.CreditIssued) {\n                (bytes32 payload,,) = $.oracle.latestPayload(facilityId, kind);\n                if (payload != termsHash) {\n                    revert Bridge_AttestationNotBoundToDeal(classId, kind, termsHash, payload);\n                }\n            }\n        }\n    }\n\n    function _isDealIdentityKind(IAttestationOracle.AttestationKind kind) private pure returns (bool) {\n        return kind == IAttestationOracle.AttestationKind.AssignmentExecuted\n            || kind == IAttestationOracle.AttestationKind.UCCFiled\n            || kind == IAttestationOracle.AttestationKind.CreditIssued;\n    }\n\n    function _facility(BridgeStorage storage $, uint256 tokenId) private view returns (Facility storage f) {\n        if (tokenId == 0 || tokenId >= $.nextId) revert Bridge_UnknownToken(tokenId);\n        f = $.facilities[tokenId];\n    }\n\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        override(ERC721Upgradeable, AccessControlUpgradeable)\n        returns (bool)\n    {\n        return super.supportsInterface(interfaceId);\n    }\n\n    /// @dev Token approvals cannot change during a source accounting or delivery callback.\n    function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal override {\n        _requireAccrualIdle();\n        super._approve(to, tokenId, auth, emitEvent);\n    }\n\n    /// @dev Operator approvals share the same callback boundary as ownership changes.\n    function _setApprovalForAll(address owner, address operator, bool approved) internal override {\n        _requireAccrualIdle();\n        super._setApprovalForAll(owner, operator, approved);\n    }\n\n    /// @dev Includes initial grants before binding and governed grants afterwards.\n    function _grantRole(bytes32 role, address account) internal override returns (bool) {\n        _requireAccrualIdle();\n        return super._grantRole(role, account);\n    }\n\n    /// @dev Includes revocation and a holder's own role renunciation.\n    function _revokeRole(bytes32 role, address account) internal override returns (bool) {\n        _requireAccrualIdle();\n        return super._revokeRole(role, account);\n    }\n\n    /// @dev An upgrade cannot replace lifecycle accounting during a protected source operation.\n    function _authorizeUpgrade(address implementation) internal view override onlyRole(Roles.UPGRADER_ROLE) {\n        _requireAccrualIdle();\n        if (BridgeMixedInterestLib.enabled()) BridgeAccrualLib.validateMixedImplementation(implementation);\n    }\n\n    /// @dev Admissions and prospective economic amendments require the authoritative current book.\n    function _requireAccrualFresh() private view {\n        address reserve = _storage().accrualReserve;\n        if (reserve != address(0)) IContinuousAccrual(reserve).requireAccrualFresh();\n    }\n\n    /// @dev Recovery, governance and custody changes need an idle source, independent of keeper lag.\n    function _requireAccrualIdle() private view {\n        address reserve = _storage().accrualReserve;\n        if (reserve != address(0)) IAccrualExposure(reserve).requireAccrualIdle();\n    }\n\n    /// @dev Binding prepares modules before activation and does not rewrite legacy funded terms.\n    function _accrualEnabled(BridgeStorage storage $) private view returns (bool) {\n        return $.accrualReserve != address(0) && IContinuousAccrual($.accrualReserve).accrualSnapshot().enabled;\n    }\n\n    /// @dev Continuous cash supports fixed Actual/360 and Actual/365; PIK retains fixed Actual/360.\n    function _requireAccrualTerms(uint256 tokenId, bool pik, RateType rateType, DayCountConvention dayCount)\n        private\n        pure\n    {\n        if (\n            rateType != RateType.Fixed || dayCount == DayCountConvention.Thirty360\n                || (pik && dayCount != DayCountConvention.Actual360)\n        ) revert Bridge_AccrualUnsupportedTerms(tokenId);\n    }\n\n    function _storage() private pure returns (BridgeStorage storage $) {\n        assembly {\n            $.slot := BRIDGE_STORAGE_LOCATION\n        }\n    }\n}\n","deployed_bytecode":"0x6080604052600436106102b7575f3560e01c8063709ae4411161016b578063b6d4cd7d116100c9578063d547741f11610083578063d547741f146108a0578063e6307e0e146108bf578063e985e9c5146108de578063f20b2759146108fd578063f26318bf14610911578063f604c6df1461093d578063f7e80e9814610951575f5ffd5b8063b6d4cd7d146107e6578063b88d4fde14610805578063be745ef014610824578063c5afe6cf14610843578063c7915bc114610862578063c87b56dd14610881575f5ffd5b806388c62f6d1161012557806388c62f6d1461068757806390135bdb146106bb57806391d148541461075157806395d89b4114610770578063a217fddf14610784578063a22cb46514610797578063ad3cb1cc146107b6575f5ffd5b8063709ae441146105e557806370a082311461060d578063716d5bf81461062c57806373af03891461064b578063813e89b91461065f5780638456cb5914610673575f5ffd5b80633db19d60116102185780634f1ef286116101d25780634f1ef2861461052e57806352d1902d146105415780635588fdf1146105555780635c975abb146105745780636352211e14610588578063664d81c1146105a757806367e38793146105c6575f5ffd5b80633db19d60146104825780633f29aa55146104a15780633f4ba83a146104d357806342842e0e146104e75780634a0459ce146105065780634df6607a1461051a575f5ffd5b806314ba89e71161027457806314ba89e71461039b57806323b872dd146103ba578063248a9ca3146103d95780632f2ff15d146104065780633083b4e51461042557806333ed51c91461044457806336568abe14610463575f5ffd5b806301ffc9a7146102bb57806306fdde03146102ef578063081812fc14610310578063095ea7b31461033c5780630fdfa6781461035d5780631459457a1461037c575b5f5ffd5b3480156102c6575f5ffd5b506102da6102d5366004614c8d565b610985565b60405190151581526020015b60405180910390f35b3480156102fa575f5ffd5b50610303610995565b6040516102e69190614cd6565b34801561031b575f5ffd5b5061032f61032a366004614ce8565b610a32565b6040516102e69190614cff565b348015610347575f5ffd5b5061035b610356366004614d37565b610a46565b005b348015610368575f5ffd5b5061035b610377366004614ce8565b610a55565b348015610387575f5ffd5b5061035b610396366004614d61565b610f8d565b3480156103a6575f5ffd5b506102da6103b5366004614ce8565b6111f7565b3480156103c5575f5ffd5b5061035b6103d4366004614dce565b61127c565b3480156103e4575f5ffd5b506103f86103f3366004614ce8565b611305565b6040519081526020016102e6565b348015610411575f5ffd5b5061035b610420366004614e0c565b611323565b348015610430575f5ffd5b5061035b61043f366004614e3a565b61133f565b34801561044f575f5ffd5b5061035b61045e366004614e55565b6113c4565b34801561046e575f5ffd5b5061035b61047d366004614e0c565b611473565b34801561048d575f5ffd5b506103f861049c366004614ce8565b6114a6565b3480156104ac575f5ffd5b507f17085a5db666070eb4aa0aac3c233b268ac6d0b0c76e1646dbb52fd255f00c056103f8565b3480156104de575f5ffd5b5061035b6114c2565b3480156104f2575f5ffd5b5061035b610501366004614dce565b6114ec565b348015610511575f5ffd5b506103f8611506565b348015610525575f5ffd5b5061032f611524565b61035b61053c366004614f5a565b61153f565b34801561054c575f5ffd5b506103f861155a565b348015610560575f5ffd5b5061035b61056f366004614ce8565b611575565b34801561057f575f5ffd5b506102da6116ca565b348015610593575f5ffd5b5061032f6105a2366004614ce8565b6116de565b3480156105b2575f5ffd5b506103f86105c1366004614fbd565b6116e8565b3480156105d1575f5ffd5b5061035b6105e0366004614fd8565b611717565b3480156105f0575f5ffd5b506105fa61271081565b60405161ffff90911681526020016102e6565b348015610618575f5ffd5b506103f8610627366004614e3a565b6117d4565b348015610637575f5ffd5b5061035b610646366004615036565b611829565b348015610656575f5ffd5b506102da6118d9565b34801561066a575f5ffd5b5061035b6118e8565b34801561067e575f5ffd5b5061035b6119b1565b348015610692575f5ffd5b506106a66106a136600461509d565b6119d8565b604080519283526020830191909152016102e6565b3480156106c6575f5ffd5b506106da6106d5366004614ce8565b611ad2565b6040516102e691905f60c08201905061ffff835116825261ffff60208401511660208301526001600160401b0360408401511660408301526001600160401b0360608401511660608301526001600160401b0360808401511660808301526001600160401b0360a08401511660a083015292915050565b34801561075c575f5ffd5b506102da61076b366004614e0c565b611b81565b34801561077b575f5ffd5b50610303611bb5565b34801561078f575f5ffd5b506103f85f81565b3480156107a2575f5ffd5b5061035b6107b13660046150f3565b611bd1565b3480156107c1575f5ffd5b50610303604051806040016040528060058152602001640352e302e360dc1b81525081565b3480156107f1575f5ffd5b5061035b61080036600461511f565b611bdc565b348015610810575f5ffd5b5061035b61081f366004615145565b611e67565b34801561082f575f5ffd5b5061035b61083e366004614e3a565b611e7f565b34801561084e575f5ffd5b506103f861085d3660046151ac565b611fd9565b34801561086d575f5ffd5b5061035b61087c366004615036565b6121ed565b34801561088c575f5ffd5b5061030361089b366004614ce8565b612260565b3480156108ab575f5ffd5b5061035b6108ba366004614e0c565b6122d1565b3480156108ca575f5ffd5b506103f86108d93660046151fa565b6122ed565b3480156108e9575f5ffd5b506102da6108f836600461522f565b612485565b348015610908575f5ffd5b506102da6124c2565b34801561091c575f5ffd5b5061093061092b366004614ce8565b61252e565b6040516102e691906152a3565b348015610948575f5ffd5b5061035b6126d6565b34801561095c575f5ffd5b506109656128e1565b604080516001600160a01b039384168152929091166020830152016102e6565b5f61098f82612909565b92915050565b60605f6109a061292d565b9050805f0180546109b090615403565b80601f01602080910402602001604051908101604052809291908181526020018280546109dc90615403565b8015610a275780601f106109fe57610100808354040283529160200191610a27565b820191905f5260205f20905b815481529060010190602001808311610a0a57829003601f168201915b505050505091505090565b5f610a3c82612951565b5061098f82612988565b610a518282336129af565b5050565b610a5d6129bc565b5f610a66612a23565b90505f610a738284612a47565b90505f600a82015460ff166007811115610a8f57610a8f61525b565b14610ab557604051637894505760e01b8152600481018490526024015b60405180910390fd5b8154815460405163e54a4ae560e01b815260048101919091525f916001600160a01b03169063e54a4ae5906024015f60405180830381865afa158015610afd573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610b2491908101906154c9565b90508060400151610b4e57815460405163b881744d60e01b81526004810191909152602401610aac565b600482015442600160201b9091046001600160401b031611610b865760405163818a88f960e01b815260048101859052602401610aac565b600582015442600160401b9091046001600160401b031611610bbb57604051636d3a5bb560e11b815260040160405180910390fd5b610bc483612a8e565b15610bfb57600a8201546005830154610bfb91869160ff610100909204821691600160801b8204811691600160881b900416612b28565b604051635be6357960e11b8152600481018590525f9073416983b6d1203a8d7e00904c80f0f64e8b403a929063b7cc6af290602401602060405180830381865af4158015610c4b573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c6f91906155be565b905080610e1157604080516102608101825284548152600180860154602083015260028601549282019290925260038501546060820152600485015461ffff80821660808401526201000082041660a0830152600160201b81046001600160401b0390811660c0840152600160601b9091046001600160a01b031660e08301526005860154808216610100840152600160401b8104909116610120830152610e0e928691610140840191600160801b90910460ff1690811115610d3457610d3461525b565b6001811115610d4557610d4561525b565b81526020016005820160119054906101000a900460ff166002811115610d6d57610d6d61525b565b6002811115610d7e57610d7e61525b565b8152600582015460ff600160901b90910481161515602083015260068301546040830152600780840154606084015260088401546080840152600984015460a0840152600a84015460c09093019290911690811115610ddf57610ddf61525b565b6007811115610df057610df061525b565b8152600a9190910154610100900460ff161515602090910152612b9e565b90505b610e2084845f01548784612cea565b600182602001516001811115610e3857610e3861525b565b03610f86576001840154604051631ca338f160e01b8152600481018790525f9182916001600160a01b0390911690631ca338f1906024016040805180830381865afa158015610e89573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ead91906155d5565b91509150806001600160401b03165f1480610ee957508361010001516001600160401b0316816001600160401b031642610ee7919061560d565b115b15610f285761010084015160405163874f2cd760e01b8152600481018990526001600160401b0380841660248301529091166044820152606401610aac565b60048501545f9061271090610f419061ffff1685615620565b610f4b9190615637565b90508086600301541115610f825760038601546040516329af243360e11b8152600481019190915260248101829052604401610aac565b5050505b5050505050565b5f610f96612fb0565b805490915060ff600160401b82041615906001600160401b03165f81158015610fbc5750825b90505f826001600160401b03166001148015610fd75750303b155b905081158015610fe5575080155b156110035760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561102d57845460ff60401b1916600160401b1785555b6001600160a01b038a16158061104a57506001600160a01b038916155b8061105c57506001600160a01b038816155b8061106e57506001600160a01b038716155b8061108057506001600160a01b038616155b1561109e5760405163d1e59e0960e01b815260040160405180910390fd5b6110f660405180604001604052806014815260200173466f7265737420526f616420466163696c69747960601b8152506040518060400160405280600a8152602001696672464143494c49545960b01b815250612fd8565b6110fe612fea565b611106612ff4565b61110e612fea565b611116612fea565b6111205f8b613004565b506111385f516020615f3a5f395f51905f528a613004565b506111637f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e389613004565b505f61116d612a23565b80546001600160a01b03808b166001600160a01b031992831617835560018084018054928c1692909316919091179091556002909101555083156111eb57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050505050565b5f611209611203612a23565b83612a47565b50604051635d02dea960e01b81526004810183905273416983b6d1203a8d7e00904c80f0f64e8b403a9290635d02dea990602401602060405180830381865af4158015611258573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061098f9190615656565b6001600160a01b0382166112a5575f604051633250574960e11b8152600401610aac9190614cff565b5f6112b1838333613017565b9050836001600160a01b0316816001600160a01b0316146112ff576040516364283d7b60e01b81526001600160a01b0380861660048301526024820184905282166044820152606401610aac565b50505050565b5f5f61130f613102565b5f9384526020525050604090206001015490565b61132c82611305565b61133581613126565b6112ff8383613004565b5f61134981613126565b6040516331ea288b60e11b815273416983b6d1203a8d7e00904c80f0f64e8b403a92906363d4511690611380908590600401614cff565b602060405180830381865af415801561139b573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113bf919061567c565b505050565b5f6113ce81613126565b6113d6613130565b6113e3600161020061560d565b1982161515806113f4575060048216155b156114155760405163893a4ded60e01b815260048101839052602401610aac565b8161141e612a23565b6004015f8581526020019081526020015f2081905550827f499963270303106dfdaa935e34c3e993f5a1987da365a77b4e55ec98ec138e888360405161146691815260200190565b60405180910390a2505050565b6001600160a01b038116331461149c5760405163334bd91960e11b815260040160405180910390fd5b6113bf8282613185565b5f6114af612a23565b5f92835260040160205250604090205490565b5f516020615f3a5f395f51905f526114d981613126565b6114e1613130565b6114e9613198565b50565b6113bf83838360405180602001604052805f815250611e67565b5f6001611511612a23565b6002015461151f919061560d565b905090565b5f61152d612a23565b600501546001600160a01b0316919050565b6115476131ee565b61155082613292565b610a51828261336b565b5f61156361341e565b505f516020615efa5f395f51905f5290565b5f516020615f1a5f395f51905f5261158c81613126565b611594613467565b61159c613130565b5f6115a5612a23565b90505f6115b28285612a47565b90505f600a82015460ff1660078111156115ce576115ce61525b565b146115ef57604051637894505760e01b815260048101859052602401610aac565b815481546001830154600284015460038501546040516368b4823360e01b815260048101949094526024840192909252604483015260648201526001600160a01b03909116906368b48233906084015f604051808303815f87803b158015611655575f5ffd5b505af1158015611667573d5f5f3e3d5ffd5b50505050600a8101805460ff1916600690811790915560405185917f18e785d11512625ba8e5486b7d963f337dfc0a628752fe18e284b0375eefe46c916116af915f91615697565b60405180910390a26116c08461349c565b5050610a516134d4565b5f5f6116d46134e4565b5460ff1692915050565b5f61098f82612951565b5f816040516020016116fa91906156d6565b604051602081830303815290604052805190602001209050919050565b5f516020615f1a5f395f51905f5261172e81613126565b611736613508565b61173e613467565b6117466129bc565b73416983b6d1203a8d7e00904c80f0f64e8b403a9263fb383d338585856040516020016117739190615827565b6040516020818303038152906040526040518463ffffffff1660e01b81526004016117a0939291906158fd565b5f6040518083038186803b1580156117b6575f5ffd5b505af41580156117c8573d5f5f3e3d5ffd5b505050506112ff6134d4565b5f5f6117de61292d565b90506001600160a01b038316611809575f6040516322718ad960e21b8152600401610aac9190614cff565b6001600160a01b039092165f908152600390920160205250604090205490565b7f8f949a3ba351e10a4e8a55f43474eba190dceef5961d8b678c89e6dd8f5681ef61185381613126565b61185b613467565b611863613130565b604051632a787e1360e01b8152600481018490526001600160401b038316602482015273416983b6d1203a8d7e00904c80f0f64e8b403a9290632a787e13906044015f6040518083038186803b1580156118bb575f5ffd5b505af41580156118cd573d5f5f3e3d5ffd5b505050506113bf6134d4565b5f6118e261352e565b15905090565b5f516020615f1a5f395f51905f526118ff81613126565b611907613467565b61190f613130565b5f611918612a23565b6002015460405163acb6a37160e01b81526004810182905290915073416983b6d1203a8d7e00904c80f0f64e8b403a929063acb6a371906024015f6040518083038186803b158015611968575f5ffd5b505af415801561197a573d5f5f3e3d5ffd5b50506040518392507fcaffe0b0da3b9894e8e225d7d2d8ab9dba3e90ddef5a256a4c647cef97bdb78291505f90a2506114e96134d4565b5f516020615f3a5f395f51905f526119c881613126565b6119d0613130565b6114e9613542565b5f5f5f516020615f1a5f395f51905f526119f181613126565b6119f9613508565b611a01613467565b611a096129bc565b611a11612a23565b60020154604051636cf1639760e11b815290935073416983b6d1203a8d7e00904c80f0f64e8b403a929063d9e2c72e90611a5390869089908990600401615943565b602060405180830381865af4158015611a6e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a9291906155be565b915081837f092302041ffb0cadd4953d97a0e9fb044d726e861e15672b9d2d53adfe7ebd6f60405160405180910390a3611aca6134d4565b509250929050565b6040805160c0810182525f80825260208201819052918101829052606081018290526080810182905260a0810191909152611b0e611203612a23565b50604051636055074560e11b81526004810183905273416983b6d1203a8d7e00904c80f0f64e8b403a929063c0aa0e8a9060240160c060405180830381865af4158015611b5d573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061098f919061595c565b5f5f611b8b613102565b5f948552602090815260408086206001600160a01b03959095168652939052505090205460ff1690565b60605f611bc061292d565b90508060010180546109b090615403565b610a51338383613588565b7f8f949a3ba351e10a4e8a55f43474eba190dceef5961d8b678c89e6dd8f5681ef611c0681613126565b611c0e613467565b611c16613130565b5f611c1f612a23565b90505f611c2c8286612a47565b600a81015490915060ff165f80826007811115611c4b57611c4b61525b565b148015611c6957506001866007811115611c6757611c6761525b565b145b80611ca157506001826007811115611c8357611c8361525b565b148015611ca157506002866007811115611c9f57611c9f61525b565b145b80611cf557506001826007811115611cbb57611cbb61525b565b1480611cd857506002826007811115611cd657611cd661525b565b145b8015611cf557506003866007811115611cf357611cf361525b565b145b80611d4957506001826007811115611d0f57611d0f61525b565b1480611d2c57506002826007811115611d2a57611d2a61525b565b145b8015611d4957506004866007811115611d4757611d4761525b565b145b80611d8157506004826007811115611d6357611d6361525b565b148015611d8157506005866007811115611d7f57611d7f61525b565b145b80611dd557506004826007811115611d9b57611d9b61525b565b1480611db857506005826007811115611db657611db661525b565b145b8015611dd557506007866007811115611dd357611dd361525b565b145b905080611dfb57868287604051633f0c448f60e21b8152600401610aac93929190615a06565b600a8301805487919060ff19166001836007811115611e1c57611e1c61525b565b0217905550867f18e785d11512625ba8e5486b7d963f337dfc0a628752fe18e284b0375eefe46c8388604051611e53929190615697565b60405180910390a2505050506113bf6134d4565b611e7284848461127c565b6112ff338585858561359b565b5f611e8981613126565b5f611e92612a23565b60058101549091506001600160a01b031615611ec15760405163ccd3828960e01b815260040160405180910390fd5b805460018201546040516338eb153360e11b81526001600160a01b0380871660048301529283166024820152911660448201527349fff8d1efbdc4e6d265a18ce2705d3ddc2ee953906371d62a66906064015f6040518083038186803b158015611f29575f5ffd5b505af4158015611f3b573d5f5f3e3d5ffd5b50505050826001600160a01b031663ea6137806040518163ffffffff1660e01b81526004015f6040518083038186803b158015611f76575f5ffd5b505afa158015611f88573d5f5f3e3d5ffd5b505050506005810180546001600160a01b0319166001600160a01b0385169081179091556040517fc7e46f285672009e8cc7c065c584cde30b609cb4401feeb9cd1a82fad9e989e0905f90a2505050565b5f5f516020615f1a5f395f51905f52611ff181613126565b611ff9613508565b612001613467565b6120096129bc565b5f61201b612015612a23565b88612a47565b604051635d02dea960e01b81526004810189905290915073416983b6d1203a8d7e00904c80f0f64e8b403a9290635d02dea990602401602060405180830381865af415801561206c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120909190615656565b6120b057604051635ba98c7760e01b815260048101889052602401610aac565b6001600a82015460ff1660078111156120cb576120cb61525b565b141580156120f257506002600a82015460ff1660078111156120ef576120ef61525b565b14155b1561211057604051636d3a5bb560e11b815260040160405180910390fd5b8561212e57604051636d3a5bb560e11b815260040160405180910390fd5b604051633146b52360e01b815273416983b6d1203a8d7e00904c80f0f64e8b403a9290633146b5239061216b908a908a908a908a90600401615a27565b602060405180830381865af4158015612186573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121aa91906155be565b92508286887f3404d736e6d38df4e98f15431ec08b4eaf51e2082106d94f9508e831bfe51bf360405160405180910390a4506121e46134d4565b50949350505050565b604051630cefee4d60e21b8152600481018390526001600160401b038216602482015273416983b6d1203a8d7e00904c80f0f64e8b403a92906333bfb934906044015b5f6040518083038186803b158015612246575f5ffd5b505af4158015612258573d5f5f3e3d5ffd5b505050505050565b606061226b82612951565b505f61228160408051602081019091525f815290565b90505f81511161229f5760405180602001604052805f8152506122ca565b806122a9846136a8565b6040516020016122ba929190615a5d565b6040516020818303038152906040525b9392505050565b6122da82611305565b6122e381613126565b6112ff8383613185565b5f5f516020615f1a5f395f51905f5261230581613126565b61230d613508565b612315613467565b61231d6129bc565b5f61232784613737565b90505f612332612a23565b90505f73416983b6d1203a8d7e00904c80f0f64e8b403a9263b7cc6af283600201546040518263ffffffff1660e01b815260040161237291815260200190565b602060405180830381865af415801561238d573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123b191906155be565b9050806123c8576123c183612b9e565b9050612466565b73416983b6d1203a8d7e00904c80f0f64e8b403a9263f8d796788360020154886040516020016123f891906156d6565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401612424929190615a71565b602060405180830381865af415801561243f573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061246391906155be565b90505b6124718784836138fc565b945050505061247e6134d4565b5092915050565b5f5f61248f61292d565b6001600160a01b039485165f90815260059190910160209081526040808320959096168252939093525050205460ff1690565b5f73416983b6d1203a8d7e00904c80f0f64e8b403a9263238dafe06040518163ffffffff1660e01b8152600401602060405180830381865af415801561250a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061151f9190615656565b612536614bd9565b612541611203612a23565b604080516102608101825282548152600180840154602083015260028401549282019290925260038301546060820152600483015461ffff80821660808401526201000082041660a0830152600160201b81046001600160401b0390811660c0840152600160601b9091046001600160a01b031660e08301526005840154808216610100840152600160401b8104909116610120830152909291610140840191600160801b900460ff16908111156125fb576125fb61525b565b600181111561260c5761260c61525b565b81526020016005820160119054906101000a900460ff1660028111156126345761263461525b565b60028111156126455761264561525b565b8152600582015460ff600160901b90910481161515602083015260068301546040830152600780840154606084015260088401546080840152600984015460a0840152600a84015460c090930192909116908111156126a6576126a661525b565b60078111156126b7576126b761525b565b8152600a9190910154610100900460ff16151560209091015292915050565b5f6126e081613126565b5f6126e9612a23565b60058101549091506001600160a01b03168015806127695750806001600160a01b03166379a502786040518163ffffffff1660e01b815260040161012060405180830381865afa15801561273f573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127639190615a89565b60e00151155b1561278757604051638a4a0d4560e01b815260040160405180910390fd5b806001600160a01b031663412838366040518163ffffffff1660e01b81526004015f6040518083038186803b1580156127be575f5ffd5b505afa1580156127d0573d5f5f3e3d5ffd5b50505050806001600160a01b031663ea6137806040518163ffffffff1660e01b81526004015f6040518083038186803b15801561280b575f5ffd5b505afa15801561281d573d5f5f3e3d5ffd5b5050604051632be97db760e01b81527349fff8d1efbdc4e6d265a18ce2705d3ddc2ee9539250632be97db79150612858908490600401614cff565b5f6040518083038186803b15801561286e575f5ffd5b505af4158015612880573d5f5f3e3d5ffd5b5050505073416983b6d1203a8d7e00904c80f0f64e8b403a9263a3907d716040518163ffffffff1660e01b81526004015f6040518083038186803b1580156128c6575f5ffd5b505af41580156128d8573d5f5f3e3d5ffd5b50505050505050565b5f5f5f6128ec612a23565b80546001909101546001600160a01b039182169591169350915050565b5f6001600160e01b03198216637965db0b60e01b148061098f575061098f8261425f565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930090565b5f5f61295c836142ae565b90506001600160a01b03811661098f57604051637e27328960e01b815260048101849052602401610aac565b5f5f61299261292d565b5f938452600401602052505060409020546001600160a01b031690565b6113bf83838360016142d5565b5f6129c5612a23565b600501546001600160a01b0316905080156114e957806001600160a01b031663412838366040518163ffffffff1660e01b81526004015f6040518083038186803b158015612a11575f5ffd5b505afa158015610f86573d5f5f3e3d5ffd5b7fc9c2da543a2a10e4b712709fb6548fb2c0c97cecbac3457453966d18f1663f0090565b5f811580612a59575082600201548210155b15612a7a5760405163132be2a560e21b815260048101839052602401610aac565b505f90815260039091016020526040902090565b60058101545f906001600160a01b03161580159061098f5750816005015f9054906101000a90046001600160a01b03166001600160a01b03166379a502786040518163ffffffff1660e01b815260040161012060405180830381865afa158015612afa573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612b1e9190615a89565b60e0015192915050565b5f826001811115612b3b57612b3b61525b565b141580612b5957506002816002811115612b5757612b5761525b565b145b80612b7d5750828015612b7d57505f816002811115612b7a57612b7a61525b565b14155b156112ff576040516352b3253f60e11b815260048101859052602401610aac565b5f5f604051806102400160405280845f01518152602001846020015181526020018460400151815260200184606001518152602001846080015161ffff1681526020018460a0015161ffff1681526020018460c001516001600160401b031681526020018460e001516001600160a01b031681526020018461010001516001600160401b031681526020018461012001516001600160401b031681526020018461014001516001811115612c5457612c5461525b565b81526020018461016001516002811115612c7057612c7061525b565b815260200184610180015115158152602001846101a001518152602001846101c001518152602001846101e00151815260200184610200015181526020018461024001511515815250905080604051602001612ccc9190615b1d565b60405160208183030381529060405280519060200120915050919050565b5f83815260048581016020526040822054919082169003612d215760405163893a4ded60e01b815260048101829052602401610aac565b5f5b6009811015612df6576001811b821615612dee575f8160ff166009811115612d4d57612d4d61525b565b60018801546040516302a180eb60e11b81529192505f916001600160a01b039091169063054301d690612d869089908690600401615c78565b606060405180830381865afa158015612da1573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612dc59190615c8c565b9250505080612deb5786826040516376cd1a7760e01b8152600401610aac929190615c78565b50505b600101612d23565b506004811615612eab5760018501546040516302a180eb60e11b81525f916001600160a01b03169063054301d690612e35908790600290600401615c78565b606060405180830381865afa158015612e50573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612e749190615c8c565b50509050828114612ea9576040516320c2917960e21b8152600481018590526024810184905260448101829052606401610aac565b505b5f5b6009811015612258576001811b821615612fa8575f8160ff166009811115612ed757612ed761525b565b9050612ee2816142e9565b8015612f0057506002816009811115612efd57612efd61525b565b14155b15612fa65760018701546040516302a180eb60e11b81525f916001600160a01b03169063054301d690612f399089908690600401615c78565b606060405180830381865afa158015612f54573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f789190615c8c565b50509050848114612fa45786828683604051632f0f25c360e21b8152600401610aac9493929190615ccd565b505b505b600101612ead565b5f807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0061098f565b612fe061433b565b610a518282614360565b612ff261433b565b565b612ffc61433b565b612ff261438d565b5f61300d613130565b6122ca8383614395565b5f613020613130565b5f613029612a23565b90505f613035856142ae565b90506001600160a01b038116156130ed575f8581526003830160205260409020600a015460ff1660048160078111156130705761307061525b565b148061308d5750600581600781111561308b5761308b61525b565b145b156130ae57604051635110e24d60e01b815260048101879052602401610aac565b6001600160a01b038716158015906130cd57506130cb5f33611b81565b155b156130eb57604051631e5b52a360e31b815260040160405180910390fd5b505b6130f8868686614433565b9695505050505050565b7f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680090565b6114e98133614532565b5f613139612a23565b600501546001600160a01b0316905080156114e957806001600160a01b031663ea6137806040518163ffffffff1660e01b81526004015f6040518083038186803b158015612a11575f5ffd5b5f61318e613130565b6122ca838361456b565b6131a06145e1565b5f6131a96134e4565b805460ff1916815590507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516131e39190614cff565b60405180910390a150565b306001600160a01b037f000000000000000000000000c63b7bf5472378abfea171793c06bd0e960b2bb716148061327457507f000000000000000000000000c63b7bf5472378abfea171793c06bd0e960b2bb76001600160a01b03166132685f516020615efa5f395f51905f52546001600160a01b031690565b6001600160a01b031614155b15612ff25760405163703e46dd60e11b815260040160405180910390fd5b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e36132bc81613126565b6132c4613130565b73416983b6d1203a8d7e00904c80f0f64e8b403a9263238dafe06040518163ffffffff1660e01b8152600401602060405180830381865af415801561330b573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061332f9190615656565b15610a515760405163dc8e88ad60e01b81527349fff8d1efbdc4e6d265a18ce2705d3ddc2ee9539063dc8e88ad90612230908590600401614cff565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156133c5575060408051601f3d908101601f191682019092526133c2918101906155be565b60015b6133e45781604051634c9c8ce360e01b8152600401610aac9190614cff565b5f516020615efa5f395f51905f52811461341457604051632a87526960e21b815260048101829052602401610aac565b6113bf8383614606565b306001600160a01b037f000000000000000000000000c63b7bf5472378abfea171793c06bd0e960b2bb71614612ff25760405163703e46dd60e11b815260040160405180910390fd5b5f61347061465b565b80549091506001190161349657604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b5f6134a85f835f613017565b90506001600160a01b038116610a5157604051637e27328960e01b815260048101839052602401610aac565b5f6134dd61465b565b6001905550565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330090565b6135106116ca565b15612ff25760405163d93c066560e01b815260040160405180910390fd5b5f5f61353861465b565b5460021492915050565b61354a613508565b5f6135536134e4565b805460ff1916600117815590507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586131d63390565b613590613130565b6113bf83838361467f565b6001600160a01b0383163b15610f8657604051630a85bd0160e11b81526001600160a01b0384169063150b7a02906135dd908890889087908790600401615cf3565b6020604051808303815f875af1925050508015613617575060408051601f3d908101601f1916820190925261361491810190615d25565b60015b613675573d808015613644576040519150601f19603f3d011682016040523d82523d5f602084013e613649565b606091505b5080515f0361366d5783604051633250574960e11b8152600401610aac9190614cff565b805160208201fd5b6001600160e01b03198116630a85bd0160e11b146122585783604051633250574960e11b8152600401610aac9190614cff565b60605f6136b483614722565b60010190505f816001600160401b038111156136d2576136d2614e75565b6040519080825280601f01601f1916602001820160405280156136fc576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461370657509392505050565b61373f614bd9565b8135815260208083013590820152604080830135908201526060808301359082015261377160a0830160808401615d40565b61ffff16608082015261378a60c0830160a08401615d40565b61ffff1660a08201526137a360e0830160c08401615d5b565b6001600160401b031660c08201526137c2610100830160e08401614e3a565b6001600160a01b031660e08201526137e261012083016101008401615d5b565b6001600160401b031661010082015261380361014083016101208401615d5b565b6001600160401b031661012082015261382461016083016101408401615d76565b816101400190600181111561383b5761383b61525b565b9081600181111561384e5761384e61525b565b90525061386361018083016101608401615d91565b816101600190600281111561387a5761387a61525b565b9081600281111561388d5761388d61525b565b9052506138a26101a083016101808401615daa565b15156101808201526101a080830135908201526101c080830135908201526101e0808301359082015261020080830135908201526138e861024083016102208401615daa565b15156102408201525f610220820152919050565b5f5f613906612a23565b90505f73416983b6d1203a8d7e00904c80f0f64e8b403a92635d02dea983600201546040518263ffffffff1660e01b815260040161394691815260200190565b602060405180830381865af4158015613961573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906139859190615656565b90506001600160a01b0386166139ae5760405163d1e59e0960e01b815260040160405180910390fd5b6002820154600160ff1b116139de578160020154604051630d0e773760e21b8152600401610aac91815260200190565b606085015115806139f157506020850151155b80613a07575060e08501516001600160a01b0316155b80613a18575060a085015161ffff16155b80613a30575061271061ffff168560a0015161ffff16115b80613a4757506101008501516001600160401b0316155b80613a76575080158015613a7657508461012001516001600160401b03168561010001516001600160401b0316115b80613a8457506101a0850151155b80613a925750610200850151155b80613aa65750604085015185516001149015145b15613ac457604051636d3a5bb560e11b815260040160405180910390fd5b60e085015160405163263e753160e11b815273416983b6d1203a8d7e00904c80f0f64e8b403a9291634c7cea6291613aff9190600401614cff565b602060405180830381865af4158015613b1a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613b3e9190615656565b508154855160405163e54a4ae560e01b815260048101919091525f916001600160a01b03169063e54a4ae5906024015f60405180830381865afa158015613b87573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052613bae91908101906154c9565b9050856080015161ffff165f1480613bd55750806060015161ffff16866080015161ffff16115b15613bf357604051636d3a5bb560e11b815260040160405180910390fd5b428660c001516001600160401b0316111580613c3257506080810151613c22906001600160401b031642615dc5565b8660c001516001600160401b0316115b15613c5057604051636d3a5bb560e11b815260040160405180910390fd5b428661012001516001600160401b0316111580613c8757508560c001516001600160401b03168661012001516001600160401b0316115b15613ca557604051636d3a5bb560e11b815260040160405180910390fd5b60018661014001516001811115613cbe57613cbe61525b565b148015613cce57506101c0860151155b15613cec57604051636d3a5bb560e11b815260040160405180910390fd5b5f8661014001516001811115613d0457613d0461525b565b148015613d1557506101c086015115155b15613d3357604051636d3a5bb560e11b815260040160405180910390fd5b6101e0860151610180870151151590151514613d6257604051636d3a5bb560e11b815260040160405180910390fd5b8561024001518015613daa57505f8661014001516001811115613d8757613d8761525b565b141580613daa57505f8661016001516002811115613da757613da761525b565b14155b15613dc857604051636d3a5bb560e11b815260040160405180910390fd5b8561024001518015613def57505f81602001516001811115613dec57613dec61525b565b14155b15613e0d57604051636d3a5bb560e11b815260040160405180910390fd5b613e2083875f0151856002015488612cea565b600181602001516001811115613e3857613e3861525b565b03613f8f5760018301546002840154604051631ca338f160e01b81525f9283926001600160a01b0390911691631ca338f191613e7a9160040190815260200190565b6040805180830381865afa158015613e94573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613eb891906155d5565b91509150806001600160401b03165f1480613ef457508261010001516001600160401b0316816001600160401b031642613ef2919061560d565b115b15613f325761010083015160405163874f2cd760e01b81525f60048201526001600160401b0380841660248301529091166044820152606401610aac565b5f612710896080015161ffff1684613f4a9190615620565b613f549190615637565b90508089606001511115613f8b5760608901516040516329af243360e11b8152600481019190915260248101829052604401610aac565b5050505b8254865160208801516040808a015160608b0151915163c7dbcab360e01b815260048101949094526024840192909252604483019190915260648201526001600160a01b039091169063c7dbcab3906084015f604051808303815f87803b158015613ff8575f5ffd5b505af115801561400a573d5f5f3e3d5ffd5b50505060028401805491505f61401f83615dd8565b909155505f818152600380860160209081526040928390208a518155908a0151600180830191909155928a0151600282015560608a015191810191909155608089015160048201805460a08c015160c08d015160e08e01516001600160a01b0316600160601b026bffffffffffffffffffffffff6001600160401b03928316600160201b021663ffffffff61ffff948516620100000263ffffffff1990961694909716939093179390931794909416171790556101008a01516005830180546101208d01518416600160401b026001600160801b03199091169290931691909117919091178082556101408b01519498508a94929360ff60801b1990911690600160801b9084908111156141355761413561525b565b021790555061016082015160058201805460ff60881b1916600160881b8360028111156141645761416461525b565b02179055506101808201518160050160126101000a81548160ff0219169083151502179055506101a082015181600601556101c082015181600701556101e08201518160080155610200820151816009015561022082015181600a015f6101000a81548160ff021916908360078111156141e0576141e061525b565b02179055506102409190910151600a90910180549115156101000261ff001990921691909117905561421287856147f9565b8560200151865f0151857f720de6cc98e76653c86e7e0a5dc3db7a92754e03c3d3acce5f780c3b0d66d4428860405161424d91815260200190565b60405180910390a45050509392505050565b5f6001600160e01b031982166380ac58cd60e01b148061428f57506001600160e01b03198216635b5e139f60e01b145b8061098f57506301ffc9a760e01b6001600160e01b031983161461098f565b5f5f6142b861292d565b5f938452600201602052505060409020546001600160a01b031690565b6142dd613130565b6112ff84848484614812565b5f808260098111156142fd576142fd61525b565b148061431a575060018260098111156143185761431861525b565b145b8061098f575060028260098111156143345761433461525b565b1492915050565b614343614919565b612ff257604051631afcd79f60e31b815260040160405180910390fd5b61436861433b565b5f61437161292d565b90508061437e8482615e34565b50600181016112ff8382615e34565b6134d461433b565b5f5f61439f613102565b90506143ab8484611b81565b61442a575f848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556143e03390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4600191505061098f565b5f91505061098f565b5f5f61443d61292d565b90505f614449856142ae565b90506001600160a01b0384161561446557614465818587614932565b6001600160a01b038116156144a1576144805f865f5f6142d5565b6001600160a01b0381165f908152600383016020526040902080545f190190555b6001600160a01b038616156144d1576001600160a01b0386165f9081526003830160205260409020805460010190555b5f85815260028301602052604080822080546001600160a01b0319166001600160a01b038a811691821790925591518893918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a495945050505050565b61453c8282611b81565b610a515760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610aac565b5f5f614575613102565b90506145818484611b81565b1561442a575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4600191505061098f565b6145e96116ca565b612ff257604051638dfc202b60e01b815260040160405180910390fd5b61460f82614996565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a2805115614653576113bf82826149f0565b610a51614a62565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0090565b5f61468861292d565b90506001600160a01b0383166146b35782604051630b61174360e31b8152600401610aac9190614cff565b6001600160a01b038481165f818152600584016020908152604080832094881680845294825291829020805460ff191687151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a350505050565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106147605772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef8100000000831061478c576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106147aa57662386f26fc10000830492506010015b6305f5e10083106147c2576305f5e100830492506008015b61271083106147d657612710830492506004015b606483106147e8576064830492506002015b600a831061098f5760010192915050565b610a51828260405180602001604052805f815250614a81565b5f61481b61292d565b9050818061483157506001600160a01b03831615155b156148e9575f61484085612951565b90506001600160a01b0384161580159061486c5750836001600160a01b0316816001600160a01b031614155b801561487f575061487d8185612485565b155b1561489f578360405163a9fbf51f60e01b8152600401610aac9190614cff565b82156148e75784866001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5f93845260040160205250506040902080546001600160a01b0319166001600160a01b0392909216919091179055565b5f614922612fb0565b54600160401b900460ff16919050565b61493d838383614a98565b6113bf576001600160a01b03831661496b57604051637e27328960e01b815260048101829052602401610aac565b60405163177e802f60e01b81526001600160a01b038316600482015260248101829052604401610aac565b806001600160a01b03163b5f036149c25780604051634c9c8ce360e01b8152600401610aac9190614cff565b5f516020615efa5f395f51905f5280546001600160a01b0319166001600160a01b0392909216919091179055565b60605f5f846001600160a01b031684604051614a0c9190615eee565b5f60405180830381855af49150503d805f8114614a44576040519150601f19603f3d011682016040523d82523d5f602084013e614a49565b606091505b5091509150614a59858383614afd565b95945050505050565b3415612ff25760405163b398979f60e01b815260040160405180910390fd5b614a8b8383614b50565b6113bf335f85858561359b565b5f6001600160a01b03831615801590614af55750826001600160a01b0316846001600160a01b03161480614ad15750614ad18484612485565b80614af55750826001600160a01b0316614aea83612988565b6001600160a01b0316145b949350505050565b606082614b1257614b0d82614bb1565b6122ca565b8151158015614b2957506001600160a01b0384163b155b15614b495783604051639996b31560e01b8152600401610aac9190614cff565b50806122ca565b6001600160a01b038216614b79575f604051633250574960e11b8152600401610aac9190614cff565b5f614b8583835f613017565b90506001600160a01b038116156113bf575f6040516339e3563760e11b8152600401610aac9190614cff565b805115614bc057805160208201fd5b60405163d6bda27560e01b815260040160405180910390fd5b60408051610260810182525f80825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290529061014082019081526020015f81526020015f151581526020015f81526020015f81526020015f81526020015f81526020015f6007811115614c6c57614c6c61525b565b81525f60209091015290565b6001600160e01b0319811681146114e9575f5ffd5b5f60208284031215614c9d575f5ffd5b81356122ca81614c78565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6122ca6020830184614ca8565b5f60208284031215614cf8575f5ffd5b5035919050565b6001600160a01b0391909116815260200190565b6001600160a01b03811681146114e9575f5ffd5b8035614d3281614d13565b919050565b5f5f60408385031215614d48575f5ffd5b8235614d5381614d13565b946020939093013593505050565b5f5f5f5f5f60a08688031215614d75575f5ffd5b8535614d8081614d13565b94506020860135614d9081614d13565b93506040860135614da081614d13565b92506060860135614db081614d13565b91506080860135614dc081614d13565b809150509295509295909350565b5f5f5f60608486031215614de0575f5ffd5b8335614deb81614d13565b92506020840135614dfb81614d13565b929592945050506040919091013590565b5f5f60408385031215614e1d575f5ffd5b823591506020830135614e2f81614d13565b809150509250929050565b5f60208284031215614e4a575f5ffd5b81356122ca81614d13565b5f5f60408385031215614e66575f5ffd5b50508035926020909101359150565b634e487b7160e01b5f52604160045260245ffd5b60405161012081016001600160401b0381118282101715614eac57614eac614e75565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614eda57614eda614e75565b604052919050565b5f6001600160401b03821115614efa57614efa614e75565b50601f01601f191660200190565b5f82601f830112614f17575f5ffd5b8135614f2a614f2582614ee2565b614eb2565b818152846020838601011115614f3e575f5ffd5b816020850160208301375f918101602001919091529392505050565b5f5f60408385031215614f6b575f5ffd5b8235614f7681614d13565b915060208301356001600160401b03811115614f90575f5ffd5b614f9c85828601614f08565b9150509250929050565b5f6102408284031215614fb7575f5ffd5b50919050565b5f6102408284031215614fce575f5ffd5b6122ca8383614fa6565b5f5f5f838503610180811215614fec575f5ffd5b8435935060208501359250610140603f1982011215615009575f5ffd5b506040840190509250925092565b6001600160401b03811681146114e9575f5ffd5b8035614d3281615017565b5f5f60408385031215615047575f5ffd5b823591506020830135614e2f81615017565b5f5f83601f840112615069575f5ffd5b5081356001600160401b0381111561507f575f5ffd5b602083019150836020828501011115615096575f5ffd5b9250929050565b5f5f602083850312156150ae575f5ffd5b82356001600160401b038111156150c3575f5ffd5b6150cf85828601615059565b90969095509350505050565b80151581146114e9575f5ffd5b8035614d32816150db565b5f5f60408385031215615104575f5ffd5b823561510f81614d13565b91506020830135614e2f816150db565b5f5f60408385031215615130575f5ffd5b82359150602083013560088110614e2f575f5ffd5b5f5f5f5f60808587031215615158575f5ffd5b843561516381614d13565b9350602085013561517381614d13565b92506040850135915060608501356001600160401b03811115615194575f5ffd5b6151a087828801614f08565b91505092959194509250565b5f5f5f5f606085870312156151bf575f5ffd5b843593506020850135925060408501356001600160401b038111156151e2575f5ffd5b6151ee87828801615059565b95989497509550505050565b5f5f610260838503121561520c575f5ffd5b823561521781614d13565b91506152268460208501614fa6565b90509250929050565b5f5f60408385031215615240575f5ffd5b823561524b81614d13565b91506020830135614e2f81614d13565b634e487b7160e01b5f52602160045260245ffd5b6002811061527f5761527f61525b565b9052565b6003811061527f5761527f61525b565b6008811061527f5761527f61525b565b5f610260820190508251825260208301516020830152604083015160408301526060830151606083015260808301516152e2608084018261ffff169052565b5060a08301516152f860a084018261ffff169052565b5060c083015161531360c08401826001600160401b03169052565b5060e083015161532e60e08401826001600160a01b03169052565b5061010083015161534b6101008401826001600160401b03169052565b506101208301516153686101208401826001600160401b03169052565b5061014083015161537d61014084018261526f565b50610160830151615392610160840182615283565b506101808301516153a861018084018215159052565b506101a08301516101a08301526101c08301516101c08301526101e08301516101e08301526102008301516102008301526102208301516153ed610220840182615293565b5061024083015161247e61024084018215159052565b600181811c9082168061541757607f821691505b602082108103614fb757634e487b7160e01b5f52602260045260245ffd5b5f82601f830112615444575f5ffd5b8151615452614f2582614ee2565b818152846020838601011115615466575f5ffd5b8160208501602083015e5f918101602001919091529392505050565b600281106114e9575f5ffd5b8051614d3281615482565b8051614d32816150db565b61ffff811681146114e9575f5ffd5b8051614d32816154a4565b8051614d3281615017565b5f602082840312156154d9575f5ffd5b81516001600160401b038111156154ee575f5ffd5b82016101208185031215615500575f5ffd5b615508614e89565b81516001600160401b0381111561551d575f5ffd5b61552986828501615435565b8252506155386020830161548e565b602082015261554960408301615499565b604082015261555a606083016154b3565b606082015261556b608083016154be565b608082015261557c60a083016154b3565b60a082015261558d60c083016154b3565b60c082015261559e60e083016154b3565b60e08201526155b061010083016154be565b610100820152949350505050565b5f602082840312156155ce575f5ffd5b5051919050565b5f5f604083850312156155e6575f5ffd5b82516020840151909250614e2f81615017565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561098f5761098f6155f9565b808202811582820484141761098f5761098f6155f9565b5f8261565157634e487b7160e01b5f52601260045260245ffd5b500490565b5f60208284031215615666575f5ffd5b81516122ca816150db565b8051614d3281614d13565b5f6020828403121561568c575f5ffd5b81516122ca81614d13565b604081016156a58285615293565b6122ca6020830184615293565b8035614d32816154a4565b8035614d3281615482565b803560038110614d32575f5ffd5b813581526020808301359082015260408083013590820152606080830135908201526102408101615709608084016156b2565b61ffff16608083015261571e60a084016156b2565b61ffff1660a083015261573360c0840161502b565b6001600160401b031660c083015261574d60e08401614d27565b6001600160a01b031660e0830152615768610100840161502b565b6001600160401b0316610100830152615784610120840161502b565b6001600160401b03166101208301526157a061014084016156bd565b6157ae61014084018261526f565b506157bc61016084016156c8565b6157ca610160840182615283565b506157d861018084016150e8565b15156101808301526101a083810135908301526101c080840135908301526101e08084013590830152610200808401359083015261581961022084016150e8565b80151561022084015261247e565b610140810161584182615839856156b2565b61ffff169052565b61584d6020840161502b565b6001600160401b031660208301526158676040840161502b565b6001600160401b031660408301526158816060840161502b565b6001600160401b0316606083015261589b608084016156bd565b6158a8608084018261526f565b506158b560a084016156c8565b6158c260a0840182615283565b506158cf60c084016150e8565b151560c083015260e08381013590830152610100808401359083015261012092830135929091019190915290565b838152826020820152606060408201525f614a596060830184614ca8565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b838152604060208201525f614a5960408301848661591b565b5f60c082840312801561596d575f5ffd5b5060405160c081016001600160401b038111828210171561599057615990614e75565b604052825161599e816154a4565b815260208301516159ae816154a4565b602082015260408301516159c181615017565b604082015260608301516159d481615017565b606082015260808301516159e781615017565b608082015260a08301516159fa81615017565b60a08201529392505050565b83815260608101615a1a6020830185615293565b614af56040830184615293565b848152836020820152606060408201525f6130f860608301848661591b565b5f81518060208401855e5f93019283525090919050565b5f614af5615a6b8386615a46565b84615a46565b828152604060208201525f614af56040830184614ca8565b5f610120828403128015615a9b575f5ffd5b50615aa4614e89565b8251815260208084015190820152604080840151908201526060808401519082015260808084015190820152615adc60a08401615671565b60a0820152615aed60c084016154be565b60c0820152615afe60e08401615499565b60e0820152615b106101008401615499565b6101008201529392505050565b5f61024082019050825182526020830151602083015260408301516040830152606083015160608301526080830151615b5c608084018261ffff169052565b5060a0830151615b7260a084018261ffff169052565b5060c0830151615b8d60c08401826001600160401b03169052565b5060e0830151615ba860e08401826001600160a01b03169052565b50610100830151615bc56101008401826001600160401b03169052565b50610120830151615be26101208401826001600160401b03169052565b50610140830151615bf761014084018261526f565b50610160830151615c0c610160840182615283565b50610180830151615c2261018084018215159052565b506101a08301516101a08301526101c08301516101c08301526101e08301516101e083015261020083015161020083015261022083015161247e61022084018215159052565b600a811061527f5761527f61525b565b828152604081016122ca6020830184615c68565b5f5f5f60608486031215615c9e575f5ffd5b83516020850151909350615cb181615017565b6040850151909250615cc2816150db565b809150509250925092565b84815260808101615ce16020830186615c68565b60408201939093526060015292915050565b6001600160a01b03858116825284166020820152604081018390526080606082018190525f906130f890830184614ca8565b5f60208284031215615d35575f5ffd5b81516122ca81614c78565b5f60208284031215615d50575f5ffd5b81356122ca816154a4565b5f60208284031215615d6b575f5ffd5b81356122ca81615017565b5f60208284031215615d86575f5ffd5b81356122ca81615482565b5f60208284031215615da1575f5ffd5b6122ca826156c8565b5f60208284031215615dba575f5ffd5b81356122ca816150db565b8082018082111561098f5761098f6155f9565b5f60018201615de957615de96155f9565b5060010190565b601f8211156113bf57805f5260205f20601f840160051c81016020851015615e155750805b601f840160051c820191505b81811015610f86575f8155600101615e21565b81516001600160401b03811115615e4d57615e4d614e75565b615e6181615e5b8454615403565b84615df0565b6020601f821160018114615e93575f8315615e7c5750848201515b5f19600385901b1c1916600184901b178455610f86565b5f84815260208120601f198516915b82811015615ec25787850151825560209485019460019092019101615ea2565b5084821015615edf57868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b5f6122ca8284615a4656fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc59abfac6520ec36a6556b2a4dd949cc40007459bcd5cd2507f1e5cc77b6bc97e55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041a2646970667358221220c3531ecb31a12d07ac2a5b80686148d5b1422882613bddc46935f784acdcd92564736f6c634300081e0033","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":{"evmVersion":"cancun","libraries":{"src/ClaimBridge.sol:BridgeAccrualLib":"0x49fff8d1efbdc4e6d265a18ce2705d3ddc2ee953","src/ClaimBridge.sol:BridgeMixedInterestLib":"0x416983b6d1203a8d7e00904c80f0f64e8b403a92"},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":true,"runs":100},"remappings":[":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",":erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",":forge-std/=lib/forge-std/src/",":halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",":openzeppelin-contracts/=lib/openzeppelin-contracts/",":solady/=lib/solady/src/"]},"optimization_runs":100,"sourcify_repo_url":"https://repo.sourcify.dev/contracts/partial_match/1/0xc63B7bF5472378AbFeA171793C06bD0e960B2BB7/","decoded_constructor_args":null,"compiler_version":"0.8.30+commit.73712a01","is_verified_via_verifier_alliance":false,"verified_at":"2026-09-24T00:31:24.904678Z","implementations":[],"proxy_type":null,"external_libraries":[{"name":"src/ClaimBridge.sol:BridgeAccrualLib","address_hash":"0x49FFF8D1EFbdc4E6D265a18Ce2705d3DdC2EE953"},{"name":"src/ClaimBridge.sol:BridgeMixedInterestLib","address_hash":"0x416983B6d1203a8D7E00904C80f0f64E8B403A92"}],"creation_bytecode":"0x60a060405230608052348015610013575f5ffd5b5061001c610021565b6100d3565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100715760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100d05780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b608051615f8f6100f95f395f81816131f90152818161322201526134290152615f8f5ff3fe6080604052600436106102b7575f3560e01c8063709ae4411161016b578063b6d4cd7d116100c9578063d547741f11610083578063d547741f146108a0578063e6307e0e146108bf578063e985e9c5146108de578063f20b2759146108fd578063f26318bf14610911578063f604c6df1461093d578063f7e80e9814610951575f5ffd5b8063b6d4cd7d146107e6578063b88d4fde14610805578063be745ef014610824578063c5afe6cf14610843578063c7915bc114610862578063c87b56dd14610881575f5ffd5b806388c62f6d1161012557806388c62f6d1461068757806390135bdb146106bb57806391d148541461075157806395d89b4114610770578063a217fddf14610784578063a22cb46514610797578063ad3cb1cc146107b6575f5ffd5b8063709ae441146105e557806370a082311461060d578063716d5bf81461062c57806373af03891461064b578063813e89b91461065f5780638456cb5914610673575f5ffd5b80633db19d60116102185780634f1ef286116101d25780634f1ef2861461052e57806352d1902d146105415780635588fdf1146105555780635c975abb146105745780636352211e14610588578063664d81c1146105a757806367e38793146105c6575f5ffd5b80633db19d60146104825780633f29aa55146104a15780633f4ba83a146104d357806342842e0e146104e75780634a0459ce146105065780634df6607a1461051a575f5ffd5b806314ba89e71161027457806314ba89e71461039b57806323b872dd146103ba578063248a9ca3146103d95780632f2ff15d146104065780633083b4e51461042557806333ed51c91461044457806336568abe14610463575f5ffd5b806301ffc9a7146102bb57806306fdde03146102ef578063081812fc14610310578063095ea7b31461033c5780630fdfa6781461035d5780631459457a1461037c575b5f5ffd5b3480156102c6575f5ffd5b506102da6102d5366004614c8d565b610985565b60405190151581526020015b60405180910390f35b3480156102fa575f5ffd5b50610303610995565b6040516102e69190614cd6565b34801561031b575f5ffd5b5061032f61032a366004614ce8565b610a32565b6040516102e69190614cff565b348015610347575f5ffd5b5061035b610356366004614d37565b610a46565b005b348015610368575f5ffd5b5061035b610377366004614ce8565b610a55565b348015610387575f5ffd5b5061035b610396366004614d61565b610f8d565b3480156103a6575f5ffd5b506102da6103b5366004614ce8565b6111f7565b3480156103c5575f5ffd5b5061035b6103d4366004614dce565b61127c565b3480156103e4575f5ffd5b506103f86103f3366004614ce8565b611305565b6040519081526020016102e6565b348015610411575f5ffd5b5061035b610420366004614e0c565b611323565b348015610430575f5ffd5b5061035b61043f366004614e3a565b61133f565b34801561044f575f5ffd5b5061035b61045e366004614e55565b6113c4565b34801561046e575f5ffd5b5061035b61047d366004614e0c565b611473565b34801561048d575f5ffd5b506103f861049c366004614ce8565b6114a6565b3480156104ac575f5ffd5b507f17085a5db666070eb4aa0aac3c233b268ac6d0b0c76e1646dbb52fd255f00c056103f8565b3480156104de575f5ffd5b5061035b6114c2565b3480156104f2575f5ffd5b5061035b610501366004614dce565b6114ec565b348015610511575f5ffd5b506103f8611506565b348015610525575f5ffd5b5061032f611524565b61035b61053c366004614f5a565b61153f565b34801561054c575f5ffd5b506103f861155a565b348015610560575f5ffd5b5061035b61056f366004614ce8565b611575565b34801561057f575f5ffd5b506102da6116ca565b348015610593575f5ffd5b5061032f6105a2366004614ce8565b6116de565b3480156105b2575f5ffd5b506103f86105c1366004614fbd565b6116e8565b3480156105d1575f5ffd5b5061035b6105e0366004614fd8565b611717565b3480156105f0575f5ffd5b506105fa61271081565b60405161ffff90911681526020016102e6565b348015610618575f5ffd5b506103f8610627366004614e3a565b6117d4565b348015610637575f5ffd5b5061035b610646366004615036565b611829565b348015610656575f5ffd5b506102da6118d9565b34801561066a575f5ffd5b5061035b6118e8565b34801561067e575f5ffd5b5061035b6119b1565b348015610692575f5ffd5b506106a66106a136600461509d565b6119d8565b604080519283526020830191909152016102e6565b3480156106c6575f5ffd5b506106da6106d5366004614ce8565b611ad2565b6040516102e691905f60c08201905061ffff835116825261ffff60208401511660208301526001600160401b0360408401511660408301526001600160401b0360608401511660608301526001600160401b0360808401511660808301526001600160401b0360a08401511660a083015292915050565b34801561075c575f5ffd5b506102da61076b366004614e0c565b611b81565b34801561077b575f5ffd5b50610303611bb5565b34801561078f575f5ffd5b506103f85f81565b3480156107a2575f5ffd5b5061035b6107b13660046150f3565b611bd1565b3480156107c1575f5ffd5b50610303604051806040016040528060058152602001640352e302e360dc1b81525081565b3480156107f1575f5ffd5b5061035b61080036600461511f565b611bdc565b348015610810575f5ffd5b5061035b61081f366004615145565b611e67565b34801561082f575f5ffd5b5061035b61083e366004614e3a565b611e7f565b34801561084e575f5ffd5b506103f861085d3660046151ac565b611fd9565b34801561086d575f5ffd5b5061035b61087c366004615036565b6121ed565b34801561088c575f5ffd5b5061030361089b366004614ce8565b612260565b3480156108ab575f5ffd5b5061035b6108ba366004614e0c565b6122d1565b3480156108ca575f5ffd5b506103f86108d93660046151fa565b6122ed565b3480156108e9575f5ffd5b506102da6108f836600461522f565b612485565b348015610908575f5ffd5b506102da6124c2565b34801561091c575f5ffd5b5061093061092b366004614ce8565b61252e565b6040516102e691906152a3565b348015610948575f5ffd5b5061035b6126d6565b34801561095c575f5ffd5b506109656128e1565b604080516001600160a01b039384168152929091166020830152016102e6565b5f61098f82612909565b92915050565b60605f6109a061292d565b9050805f0180546109b090615403565b80601f01602080910402602001604051908101604052809291908181526020018280546109dc90615403565b8015610a275780601f106109fe57610100808354040283529160200191610a27565b820191905f5260205f20905b815481529060010190602001808311610a0a57829003601f168201915b505050505091505090565b5f610a3c82612951565b5061098f82612988565b610a518282336129af565b5050565b610a5d6129bc565b5f610a66612a23565b90505f610a738284612a47565b90505f600a82015460ff166007811115610a8f57610a8f61525b565b14610ab557604051637894505760e01b8152600481018490526024015b60405180910390fd5b8154815460405163e54a4ae560e01b815260048101919091525f916001600160a01b03169063e54a4ae5906024015f60405180830381865afa158015610afd573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610b2491908101906154c9565b90508060400151610b4e57815460405163b881744d60e01b81526004810191909152602401610aac565b600482015442600160201b9091046001600160401b031611610b865760405163818a88f960e01b815260048101859052602401610aac565b600582015442600160401b9091046001600160401b031611610bbb57604051636d3a5bb560e11b815260040160405180910390fd5b610bc483612a8e565b15610bfb57600a8201546005830154610bfb91869160ff610100909204821691600160801b8204811691600160881b900416612b28565b604051635be6357960e11b8152600481018590525f9073416983b6d1203a8d7e00904c80f0f64e8b403a929063b7cc6af290602401602060405180830381865af4158015610c4b573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c6f91906155be565b905080610e1157604080516102608101825284548152600180860154602083015260028601549282019290925260038501546060820152600485015461ffff80821660808401526201000082041660a0830152600160201b81046001600160401b0390811660c0840152600160601b9091046001600160a01b031660e08301526005860154808216610100840152600160401b8104909116610120830152610e0e928691610140840191600160801b90910460ff1690811115610d3457610d3461525b565b6001811115610d4557610d4561525b565b81526020016005820160119054906101000a900460ff166002811115610d6d57610d6d61525b565b6002811115610d7e57610d7e61525b565b8152600582015460ff600160901b90910481161515602083015260068301546040830152600780840154606084015260088401546080840152600984015460a0840152600a84015460c09093019290911690811115610ddf57610ddf61525b565b6007811115610df057610df061525b565b8152600a9190910154610100900460ff161515602090910152612b9e565b90505b610e2084845f01548784612cea565b600182602001516001811115610e3857610e3861525b565b03610f86576001840154604051631ca338f160e01b8152600481018790525f9182916001600160a01b0390911690631ca338f1906024016040805180830381865afa158015610e89573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ead91906155d5565b91509150806001600160401b03165f1480610ee957508361010001516001600160401b0316816001600160401b031642610ee7919061560d565b115b15610f285761010084015160405163874f2cd760e01b8152600481018990526001600160401b0380841660248301529091166044820152606401610aac565b60048501545f9061271090610f419061ffff1685615620565b610f4b9190615637565b90508086600301541115610f825760038601546040516329af243360e11b8152600481019190915260248101829052604401610aac565b5050505b5050505050565b5f610f96612fb0565b805490915060ff600160401b82041615906001600160401b03165f81158015610fbc5750825b90505f826001600160401b03166001148015610fd75750303b155b905081158015610fe5575080155b156110035760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561102d57845460ff60401b1916600160401b1785555b6001600160a01b038a16158061104a57506001600160a01b038916155b8061105c57506001600160a01b038816155b8061106e57506001600160a01b038716155b8061108057506001600160a01b038616155b1561109e5760405163d1e59e0960e01b815260040160405180910390fd5b6110f660405180604001604052806014815260200173466f7265737420526f616420466163696c69747960601b8152506040518060400160405280600a8152602001696672464143494c49545960b01b815250612fd8565b6110fe612fea565b611106612ff4565b61110e612fea565b611116612fea565b6111205f8b613004565b506111385f516020615f3a5f395f51905f528a613004565b506111637f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e389613004565b505f61116d612a23565b80546001600160a01b03808b166001600160a01b031992831617835560018084018054928c1692909316919091179091556002909101555083156111eb57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050505050565b5f611209611203612a23565b83612a47565b50604051635d02dea960e01b81526004810183905273416983b6d1203a8d7e00904c80f0f64e8b403a9290635d02dea990602401602060405180830381865af4158015611258573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061098f9190615656565b6001600160a01b0382166112a5575f604051633250574960e11b8152600401610aac9190614cff565b5f6112b1838333613017565b9050836001600160a01b0316816001600160a01b0316146112ff576040516364283d7b60e01b81526001600160a01b0380861660048301526024820184905282166044820152606401610aac565b50505050565b5f5f61130f613102565b5f9384526020525050604090206001015490565b61132c82611305565b61133581613126565b6112ff8383613004565b5f61134981613126565b6040516331ea288b60e11b815273416983b6d1203a8d7e00904c80f0f64e8b403a92906363d4511690611380908590600401614cff565b602060405180830381865af415801561139b573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113bf919061567c565b505050565b5f6113ce81613126565b6113d6613130565b6113e3600161020061560d565b1982161515806113f4575060048216155b156114155760405163893a4ded60e01b815260048101839052602401610aac565b8161141e612a23565b6004015f8581526020019081526020015f2081905550827f499963270303106dfdaa935e34c3e993f5a1987da365a77b4e55ec98ec138e888360405161146691815260200190565b60405180910390a2505050565b6001600160a01b038116331461149c5760405163334bd91960e11b815260040160405180910390fd5b6113bf8282613185565b5f6114af612a23565b5f92835260040160205250604090205490565b5f516020615f3a5f395f51905f526114d981613126565b6114e1613130565b6114e9613198565b50565b6113bf83838360405180602001604052805f815250611e67565b5f6001611511612a23565b6002015461151f919061560d565b905090565b5f61152d612a23565b600501546001600160a01b0316919050565b6115476131ee565b61155082613292565b610a51828261336b565b5f61156361341e565b505f516020615efa5f395f51905f5290565b5f516020615f1a5f395f51905f5261158c81613126565b611594613467565b61159c613130565b5f6115a5612a23565b90505f6115b28285612a47565b90505f600a82015460ff1660078111156115ce576115ce61525b565b146115ef57604051637894505760e01b815260048101859052602401610aac565b815481546001830154600284015460038501546040516368b4823360e01b815260048101949094526024840192909252604483015260648201526001600160a01b03909116906368b48233906084015f604051808303815f87803b158015611655575f5ffd5b505af1158015611667573d5f5f3e3d5ffd5b50505050600a8101805460ff1916600690811790915560405185917f18e785d11512625ba8e5486b7d963f337dfc0a628752fe18e284b0375eefe46c916116af915f91615697565b60405180910390a26116c08461349c565b5050610a516134d4565b5f5f6116d46134e4565b5460ff1692915050565b5f61098f82612951565b5f816040516020016116fa91906156d6565b604051602081830303815290604052805190602001209050919050565b5f516020615f1a5f395f51905f5261172e81613126565b611736613508565b61173e613467565b6117466129bc565b73416983b6d1203a8d7e00904c80f0f64e8b403a9263fb383d338585856040516020016117739190615827565b6040516020818303038152906040526040518463ffffffff1660e01b81526004016117a0939291906158fd565b5f6040518083038186803b1580156117b6575f5ffd5b505af41580156117c8573d5f5f3e3d5ffd5b505050506112ff6134d4565b5f5f6117de61292d565b90506001600160a01b038316611809575f6040516322718ad960e21b8152600401610aac9190614cff565b6001600160a01b039092165f908152600390920160205250604090205490565b7f8f949a3ba351e10a4e8a55f43474eba190dceef5961d8b678c89e6dd8f5681ef61185381613126565b61185b613467565b611863613130565b604051632a787e1360e01b8152600481018490526001600160401b038316602482015273416983b6d1203a8d7e00904c80f0f64e8b403a9290632a787e13906044015f6040518083038186803b1580156118bb575f5ffd5b505af41580156118cd573d5f5f3e3d5ffd5b505050506113bf6134d4565b5f6118e261352e565b15905090565b5f516020615f1a5f395f51905f526118ff81613126565b611907613467565b61190f613130565b5f611918612a23565b6002015460405163acb6a37160e01b81526004810182905290915073416983b6d1203a8d7e00904c80f0f64e8b403a929063acb6a371906024015f6040518083038186803b158015611968575f5ffd5b505af415801561197a573d5f5f3e3d5ffd5b50506040518392507fcaffe0b0da3b9894e8e225d7d2d8ab9dba3e90ddef5a256a4c647cef97bdb78291505f90a2506114e96134d4565b5f516020615f3a5f395f51905f526119c881613126565b6119d0613130565b6114e9613542565b5f5f5f516020615f1a5f395f51905f526119f181613126565b6119f9613508565b611a01613467565b611a096129bc565b611a11612a23565b60020154604051636cf1639760e11b815290935073416983b6d1203a8d7e00904c80f0f64e8b403a929063d9e2c72e90611a5390869089908990600401615943565b602060405180830381865af4158015611a6e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a9291906155be565b915081837f092302041ffb0cadd4953d97a0e9fb044d726e861e15672b9d2d53adfe7ebd6f60405160405180910390a3611aca6134d4565b509250929050565b6040805160c0810182525f80825260208201819052918101829052606081018290526080810182905260a0810191909152611b0e611203612a23565b50604051636055074560e11b81526004810183905273416983b6d1203a8d7e00904c80f0f64e8b403a929063c0aa0e8a9060240160c060405180830381865af4158015611b5d573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061098f919061595c565b5f5f611b8b613102565b5f948552602090815260408086206001600160a01b03959095168652939052505090205460ff1690565b60605f611bc061292d565b90508060010180546109b090615403565b610a51338383613588565b7f8f949a3ba351e10a4e8a55f43474eba190dceef5961d8b678c89e6dd8f5681ef611c0681613126565b611c0e613467565b611c16613130565b5f611c1f612a23565b90505f611c2c8286612a47565b600a81015490915060ff165f80826007811115611c4b57611c4b61525b565b148015611c6957506001866007811115611c6757611c6761525b565b145b80611ca157506001826007811115611c8357611c8361525b565b148015611ca157506002866007811115611c9f57611c9f61525b565b145b80611cf557506001826007811115611cbb57611cbb61525b565b1480611cd857506002826007811115611cd657611cd661525b565b145b8015611cf557506003866007811115611cf357611cf361525b565b145b80611d4957506001826007811115611d0f57611d0f61525b565b1480611d2c57506002826007811115611d2a57611d2a61525b565b145b8015611d4957506004866007811115611d4757611d4761525b565b145b80611d8157506004826007811115611d6357611d6361525b565b148015611d8157506005866007811115611d7f57611d7f61525b565b145b80611dd557506004826007811115611d9b57611d9b61525b565b1480611db857506005826007811115611db657611db661525b565b145b8015611dd557506007866007811115611dd357611dd361525b565b145b905080611dfb57868287604051633f0c448f60e21b8152600401610aac93929190615a06565b600a8301805487919060ff19166001836007811115611e1c57611e1c61525b565b0217905550867f18e785d11512625ba8e5486b7d963f337dfc0a628752fe18e284b0375eefe46c8388604051611e53929190615697565b60405180910390a2505050506113bf6134d4565b611e7284848461127c565b6112ff338585858561359b565b5f611e8981613126565b5f611e92612a23565b60058101549091506001600160a01b031615611ec15760405163ccd3828960e01b815260040160405180910390fd5b805460018201546040516338eb153360e11b81526001600160a01b0380871660048301529283166024820152911660448201527349fff8d1efbdc4e6d265a18ce2705d3ddc2ee953906371d62a66906064015f6040518083038186803b158015611f29575f5ffd5b505af4158015611f3b573d5f5f3e3d5ffd5b50505050826001600160a01b031663ea6137806040518163ffffffff1660e01b81526004015f6040518083038186803b158015611f76575f5ffd5b505afa158015611f88573d5f5f3e3d5ffd5b505050506005810180546001600160a01b0319166001600160a01b0385169081179091556040517fc7e46f285672009e8cc7c065c584cde30b609cb4401feeb9cd1a82fad9e989e0905f90a2505050565b5f5f516020615f1a5f395f51905f52611ff181613126565b611ff9613508565b612001613467565b6120096129bc565b5f61201b612015612a23565b88612a47565b604051635d02dea960e01b81526004810189905290915073416983b6d1203a8d7e00904c80f0f64e8b403a9290635d02dea990602401602060405180830381865af415801561206c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120909190615656565b6120b057604051635ba98c7760e01b815260048101889052602401610aac565b6001600a82015460ff1660078111156120cb576120cb61525b565b141580156120f257506002600a82015460ff1660078111156120ef576120ef61525b565b14155b1561211057604051636d3a5bb560e11b815260040160405180910390fd5b8561212e57604051636d3a5bb560e11b815260040160405180910390fd5b604051633146b52360e01b815273416983b6d1203a8d7e00904c80f0f64e8b403a9290633146b5239061216b908a908a908a908a90600401615a27565b602060405180830381865af4158015612186573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121aa91906155be565b92508286887f3404d736e6d38df4e98f15431ec08b4eaf51e2082106d94f9508e831bfe51bf360405160405180910390a4506121e46134d4565b50949350505050565b604051630cefee4d60e21b8152600481018390526001600160401b038216602482015273416983b6d1203a8d7e00904c80f0f64e8b403a92906333bfb934906044015b5f6040518083038186803b158015612246575f5ffd5b505af4158015612258573d5f5f3e3d5ffd5b505050505050565b606061226b82612951565b505f61228160408051602081019091525f815290565b90505f81511161229f5760405180602001604052805f8152506122ca565b806122a9846136a8565b6040516020016122ba929190615a5d565b6040516020818303038152906040525b9392505050565b6122da82611305565b6122e381613126565b6112ff8383613185565b5f5f516020615f1a5f395f51905f5261230581613126565b61230d613508565b612315613467565b61231d6129bc565b5f61232784613737565b90505f612332612a23565b90505f73416983b6d1203a8d7e00904c80f0f64e8b403a9263b7cc6af283600201546040518263ffffffff1660e01b815260040161237291815260200190565b602060405180830381865af415801561238d573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123b191906155be565b9050806123c8576123c183612b9e565b9050612466565b73416983b6d1203a8d7e00904c80f0f64e8b403a9263f8d796788360020154886040516020016123f891906156d6565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401612424929190615a71565b602060405180830381865af415801561243f573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061246391906155be565b90505b6124718784836138fc565b945050505061247e6134d4565b5092915050565b5f5f61248f61292d565b6001600160a01b039485165f90815260059190910160209081526040808320959096168252939093525050205460ff1690565b5f73416983b6d1203a8d7e00904c80f0f64e8b403a9263238dafe06040518163ffffffff1660e01b8152600401602060405180830381865af415801561250a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061151f9190615656565b612536614bd9565b612541611203612a23565b604080516102608101825282548152600180840154602083015260028401549282019290925260038301546060820152600483015461ffff80821660808401526201000082041660a0830152600160201b81046001600160401b0390811660c0840152600160601b9091046001600160a01b031660e08301526005840154808216610100840152600160401b8104909116610120830152909291610140840191600160801b900460ff16908111156125fb576125fb61525b565b600181111561260c5761260c61525b565b81526020016005820160119054906101000a900460ff1660028111156126345761263461525b565b60028111156126455761264561525b565b8152600582015460ff600160901b90910481161515602083015260068301546040830152600780840154606084015260088401546080840152600984015460a0840152600a84015460c090930192909116908111156126a6576126a661525b565b60078111156126b7576126b761525b565b8152600a9190910154610100900460ff16151560209091015292915050565b5f6126e081613126565b5f6126e9612a23565b60058101549091506001600160a01b03168015806127695750806001600160a01b03166379a502786040518163ffffffff1660e01b815260040161012060405180830381865afa15801561273f573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127639190615a89565b60e00151155b1561278757604051638a4a0d4560e01b815260040160405180910390fd5b806001600160a01b031663412838366040518163ffffffff1660e01b81526004015f6040518083038186803b1580156127be575f5ffd5b505afa1580156127d0573d5f5f3e3d5ffd5b50505050806001600160a01b031663ea6137806040518163ffffffff1660e01b81526004015f6040518083038186803b15801561280b575f5ffd5b505afa15801561281d573d5f5f3e3d5ffd5b5050604051632be97db760e01b81527349fff8d1efbdc4e6d265a18ce2705d3ddc2ee9539250632be97db79150612858908490600401614cff565b5f6040518083038186803b15801561286e575f5ffd5b505af4158015612880573d5f5f3e3d5ffd5b5050505073416983b6d1203a8d7e00904c80f0f64e8b403a9263a3907d716040518163ffffffff1660e01b81526004015f6040518083038186803b1580156128c6575f5ffd5b505af41580156128d8573d5f5f3e3d5ffd5b50505050505050565b5f5f5f6128ec612a23565b80546001909101546001600160a01b039182169591169350915050565b5f6001600160e01b03198216637965db0b60e01b148061098f575061098f8261425f565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930090565b5f5f61295c836142ae565b90506001600160a01b03811661098f57604051637e27328960e01b815260048101849052602401610aac565b5f5f61299261292d565b5f938452600401602052505060409020546001600160a01b031690565b6113bf83838360016142d5565b5f6129c5612a23565b600501546001600160a01b0316905080156114e957806001600160a01b031663412838366040518163ffffffff1660e01b81526004015f6040518083038186803b158015612a11575f5ffd5b505afa158015610f86573d5f5f3e3d5ffd5b7fc9c2da543a2a10e4b712709fb6548fb2c0c97cecbac3457453966d18f1663f0090565b5f811580612a59575082600201548210155b15612a7a5760405163132be2a560e21b815260048101839052602401610aac565b505f90815260039091016020526040902090565b60058101545f906001600160a01b03161580159061098f5750816005015f9054906101000a90046001600160a01b03166001600160a01b03166379a502786040518163ffffffff1660e01b815260040161012060405180830381865afa158015612afa573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612b1e9190615a89565b60e0015192915050565b5f826001811115612b3b57612b3b61525b565b141580612b5957506002816002811115612b5757612b5761525b565b145b80612b7d5750828015612b7d57505f816002811115612b7a57612b7a61525b565b14155b156112ff576040516352b3253f60e11b815260048101859052602401610aac565b5f5f604051806102400160405280845f01518152602001846020015181526020018460400151815260200184606001518152602001846080015161ffff1681526020018460a0015161ffff1681526020018460c001516001600160401b031681526020018460e001516001600160a01b031681526020018461010001516001600160401b031681526020018461012001516001600160401b031681526020018461014001516001811115612c5457612c5461525b565b81526020018461016001516002811115612c7057612c7061525b565b815260200184610180015115158152602001846101a001518152602001846101c001518152602001846101e00151815260200184610200015181526020018461024001511515815250905080604051602001612ccc9190615b1d565b60405160208183030381529060405280519060200120915050919050565b5f83815260048581016020526040822054919082169003612d215760405163893a4ded60e01b815260048101829052602401610aac565b5f5b6009811015612df6576001811b821615612dee575f8160ff166009811115612d4d57612d4d61525b565b60018801546040516302a180eb60e11b81529192505f916001600160a01b039091169063054301d690612d869089908690600401615c78565b606060405180830381865afa158015612da1573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612dc59190615c8c565b9250505080612deb5786826040516376cd1a7760e01b8152600401610aac929190615c78565b50505b600101612d23565b506004811615612eab5760018501546040516302a180eb60e11b81525f916001600160a01b03169063054301d690612e35908790600290600401615c78565b606060405180830381865afa158015612e50573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612e749190615c8c565b50509050828114612ea9576040516320c2917960e21b8152600481018590526024810184905260448101829052606401610aac565b505b5f5b6009811015612258576001811b821615612fa8575f8160ff166009811115612ed757612ed761525b565b9050612ee2816142e9565b8015612f0057506002816009811115612efd57612efd61525b565b14155b15612fa65760018701546040516302a180eb60e11b81525f916001600160a01b03169063054301d690612f399089908690600401615c78565b606060405180830381865afa158015612f54573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f789190615c8c565b50509050848114612fa45786828683604051632f0f25c360e21b8152600401610aac9493929190615ccd565b505b505b600101612ead565b5f807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0061098f565b612fe061433b565b610a518282614360565b612ff261433b565b565b612ffc61433b565b612ff261438d565b5f61300d613130565b6122ca8383614395565b5f613020613130565b5f613029612a23565b90505f613035856142ae565b90506001600160a01b038116156130ed575f8581526003830160205260409020600a015460ff1660048160078111156130705761307061525b565b148061308d5750600581600781111561308b5761308b61525b565b145b156130ae57604051635110e24d60e01b815260048101879052602401610aac565b6001600160a01b038716158015906130cd57506130cb5f33611b81565b155b156130eb57604051631e5b52a360e31b815260040160405180910390fd5b505b6130f8868686614433565b9695505050505050565b7f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680090565b6114e98133614532565b5f613139612a23565b600501546001600160a01b0316905080156114e957806001600160a01b031663ea6137806040518163ffffffff1660e01b81526004015f6040518083038186803b158015612a11575f5ffd5b5f61318e613130565b6122ca838361456b565b6131a06145e1565b5f6131a96134e4565b805460ff1916815590507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516131e39190614cff565b60405180910390a150565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148061327457507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166132685f516020615efa5f395f51905f52546001600160a01b031690565b6001600160a01b031614155b15612ff25760405163703e46dd60e11b815260040160405180910390fd5b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e36132bc81613126565b6132c4613130565b73416983b6d1203a8d7e00904c80f0f64e8b403a9263238dafe06040518163ffffffff1660e01b8152600401602060405180830381865af415801561330b573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061332f9190615656565b15610a515760405163dc8e88ad60e01b81527349fff8d1efbdc4e6d265a18ce2705d3ddc2ee9539063dc8e88ad90612230908590600401614cff565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156133c5575060408051601f3d908101601f191682019092526133c2918101906155be565b60015b6133e45781604051634c9c8ce360e01b8152600401610aac9190614cff565b5f516020615efa5f395f51905f52811461341457604051632a87526960e21b815260048101829052602401610aac565b6113bf8383614606565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614612ff25760405163703e46dd60e11b815260040160405180910390fd5b5f61347061465b565b80549091506001190161349657604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b5f6134a85f835f613017565b90506001600160a01b038116610a5157604051637e27328960e01b815260048101839052602401610aac565b5f6134dd61465b565b6001905550565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330090565b6135106116ca565b15612ff25760405163d93c066560e01b815260040160405180910390fd5b5f5f61353861465b565b5460021492915050565b61354a613508565b5f6135536134e4565b805460ff1916600117815590507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586131d63390565b613590613130565b6113bf83838361467f565b6001600160a01b0383163b15610f8657604051630a85bd0160e11b81526001600160a01b0384169063150b7a02906135dd908890889087908790600401615cf3565b6020604051808303815f875af1925050508015613617575060408051601f3d908101601f1916820190925261361491810190615d25565b60015b613675573d808015613644576040519150601f19603f3d011682016040523d82523d5f602084013e613649565b606091505b5080515f0361366d5783604051633250574960e11b8152600401610aac9190614cff565b805160208201fd5b6001600160e01b03198116630a85bd0160e11b146122585783604051633250574960e11b8152600401610aac9190614cff565b60605f6136b483614722565b60010190505f816001600160401b038111156136d2576136d2614e75565b6040519080825280601f01601f1916602001820160405280156136fc576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461370657509392505050565b61373f614bd9565b8135815260208083013590820152604080830135908201526060808301359082015261377160a0830160808401615d40565b61ffff16608082015261378a60c0830160a08401615d40565b61ffff1660a08201526137a360e0830160c08401615d5b565b6001600160401b031660c08201526137c2610100830160e08401614e3a565b6001600160a01b031660e08201526137e261012083016101008401615d5b565b6001600160401b031661010082015261380361014083016101208401615d5b565b6001600160401b031661012082015261382461016083016101408401615d76565b816101400190600181111561383b5761383b61525b565b9081600181111561384e5761384e61525b565b90525061386361018083016101608401615d91565b816101600190600281111561387a5761387a61525b565b9081600281111561388d5761388d61525b565b9052506138a26101a083016101808401615daa565b15156101808201526101a080830135908201526101c080830135908201526101e0808301359082015261020080830135908201526138e861024083016102208401615daa565b15156102408201525f610220820152919050565b5f5f613906612a23565b90505f73416983b6d1203a8d7e00904c80f0f64e8b403a92635d02dea983600201546040518263ffffffff1660e01b815260040161394691815260200190565b602060405180830381865af4158015613961573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906139859190615656565b90506001600160a01b0386166139ae5760405163d1e59e0960e01b815260040160405180910390fd5b6002820154600160ff1b116139de578160020154604051630d0e773760e21b8152600401610aac91815260200190565b606085015115806139f157506020850151155b80613a07575060e08501516001600160a01b0316155b80613a18575060a085015161ffff16155b80613a30575061271061ffff168560a0015161ffff16115b80613a4757506101008501516001600160401b0316155b80613a76575080158015613a7657508461012001516001600160401b03168561010001516001600160401b0316115b80613a8457506101a0850151155b80613a925750610200850151155b80613aa65750604085015185516001149015145b15613ac457604051636d3a5bb560e11b815260040160405180910390fd5b60e085015160405163263e753160e11b815273416983b6d1203a8d7e00904c80f0f64e8b403a9291634c7cea6291613aff9190600401614cff565b602060405180830381865af4158015613b1a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613b3e9190615656565b508154855160405163e54a4ae560e01b815260048101919091525f916001600160a01b03169063e54a4ae5906024015f60405180830381865afa158015613b87573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052613bae91908101906154c9565b9050856080015161ffff165f1480613bd55750806060015161ffff16866080015161ffff16115b15613bf357604051636d3a5bb560e11b815260040160405180910390fd5b428660c001516001600160401b0316111580613c3257506080810151613c22906001600160401b031642615dc5565b8660c001516001600160401b0316115b15613c5057604051636d3a5bb560e11b815260040160405180910390fd5b428661012001516001600160401b0316111580613c8757508560c001516001600160401b03168661012001516001600160401b0316115b15613ca557604051636d3a5bb560e11b815260040160405180910390fd5b60018661014001516001811115613cbe57613cbe61525b565b148015613cce57506101c0860151155b15613cec57604051636d3a5bb560e11b815260040160405180910390fd5b5f8661014001516001811115613d0457613d0461525b565b148015613d1557506101c086015115155b15613d3357604051636d3a5bb560e11b815260040160405180910390fd5b6101e0860151610180870151151590151514613d6257604051636d3a5bb560e11b815260040160405180910390fd5b8561024001518015613daa57505f8661014001516001811115613d8757613d8761525b565b141580613daa57505f8661016001516002811115613da757613da761525b565b14155b15613dc857604051636d3a5bb560e11b815260040160405180910390fd5b8561024001518015613def57505f81602001516001811115613dec57613dec61525b565b14155b15613e0d57604051636d3a5bb560e11b815260040160405180910390fd5b613e2083875f0151856002015488612cea565b600181602001516001811115613e3857613e3861525b565b03613f8f5760018301546002840154604051631ca338f160e01b81525f9283926001600160a01b0390911691631ca338f191613e7a9160040190815260200190565b6040805180830381865afa158015613e94573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613eb891906155d5565b91509150806001600160401b03165f1480613ef457508261010001516001600160401b0316816001600160401b031642613ef2919061560d565b115b15613f325761010083015160405163874f2cd760e01b81525f60048201526001600160401b0380841660248301529091166044820152606401610aac565b5f612710896080015161ffff1684613f4a9190615620565b613f549190615637565b90508089606001511115613f8b5760608901516040516329af243360e11b8152600481019190915260248101829052604401610aac565b5050505b8254865160208801516040808a015160608b0151915163c7dbcab360e01b815260048101949094526024840192909252604483019190915260648201526001600160a01b039091169063c7dbcab3906084015f604051808303815f87803b158015613ff8575f5ffd5b505af115801561400a573d5f5f3e3d5ffd5b50505060028401805491505f61401f83615dd8565b909155505f818152600380860160209081526040928390208a518155908a0151600180830191909155928a0151600282015560608a015191810191909155608089015160048201805460a08c015160c08d015160e08e01516001600160a01b0316600160601b026bffffffffffffffffffffffff6001600160401b03928316600160201b021663ffffffff61ffff948516620100000263ffffffff1990961694909716939093179390931794909416171790556101008a01516005830180546101208d01518416600160401b026001600160801b03199091169290931691909117919091178082556101408b01519498508a94929360ff60801b1990911690600160801b9084908111156141355761413561525b565b021790555061016082015160058201805460ff60881b1916600160881b8360028111156141645761416461525b565b02179055506101808201518160050160126101000a81548160ff0219169083151502179055506101a082015181600601556101c082015181600701556101e08201518160080155610200820151816009015561022082015181600a015f6101000a81548160ff021916908360078111156141e0576141e061525b565b02179055506102409190910151600a90910180549115156101000261ff001990921691909117905561421287856147f9565b8560200151865f0151857f720de6cc98e76653c86e7e0a5dc3db7a92754e03c3d3acce5f780c3b0d66d4428860405161424d91815260200190565b60405180910390a45050509392505050565b5f6001600160e01b031982166380ac58cd60e01b148061428f57506001600160e01b03198216635b5e139f60e01b145b8061098f57506301ffc9a760e01b6001600160e01b031983161461098f565b5f5f6142b861292d565b5f938452600201602052505060409020546001600160a01b031690565b6142dd613130565b6112ff84848484614812565b5f808260098111156142fd576142fd61525b565b148061431a575060018260098111156143185761431861525b565b145b8061098f575060028260098111156143345761433461525b565b1492915050565b614343614919565b612ff257604051631afcd79f60e31b815260040160405180910390fd5b61436861433b565b5f61437161292d565b90508061437e8482615e34565b50600181016112ff8382615e34565b6134d461433b565b5f5f61439f613102565b90506143ab8484611b81565b61442a575f848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556143e03390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4600191505061098f565b5f91505061098f565b5f5f61443d61292d565b90505f614449856142ae565b90506001600160a01b0384161561446557614465818587614932565b6001600160a01b038116156144a1576144805f865f5f6142d5565b6001600160a01b0381165f908152600383016020526040902080545f190190555b6001600160a01b038616156144d1576001600160a01b0386165f9081526003830160205260409020805460010190555b5f85815260028301602052604080822080546001600160a01b0319166001600160a01b038a811691821790925591518893918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a495945050505050565b61453c8282611b81565b610a515760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610aac565b5f5f614575613102565b90506145818484611b81565b1561442a575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4600191505061098f565b6145e96116ca565b612ff257604051638dfc202b60e01b815260040160405180910390fd5b61460f82614996565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a2805115614653576113bf82826149f0565b610a51614a62565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0090565b5f61468861292d565b90506001600160a01b0383166146b35782604051630b61174360e31b8152600401610aac9190614cff565b6001600160a01b038481165f818152600584016020908152604080832094881680845294825291829020805460ff191687151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a350505050565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106147605772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef8100000000831061478c576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106147aa57662386f26fc10000830492506010015b6305f5e10083106147c2576305f5e100830492506008015b61271083106147d657612710830492506004015b606483106147e8576064830492506002015b600a831061098f5760010192915050565b610a51828260405180602001604052805f815250614a81565b5f61481b61292d565b9050818061483157506001600160a01b03831615155b156148e9575f61484085612951565b90506001600160a01b0384161580159061486c5750836001600160a01b0316816001600160a01b031614155b801561487f575061487d8185612485565b155b1561489f578360405163a9fbf51f60e01b8152600401610aac9190614cff565b82156148e75784866001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5f93845260040160205250506040902080546001600160a01b0319166001600160a01b0392909216919091179055565b5f614922612fb0565b54600160401b900460ff16919050565b61493d838383614a98565b6113bf576001600160a01b03831661496b57604051637e27328960e01b815260048101829052602401610aac565b60405163177e802f60e01b81526001600160a01b038316600482015260248101829052604401610aac565b806001600160a01b03163b5f036149c25780604051634c9c8ce360e01b8152600401610aac9190614cff565b5f516020615efa5f395f51905f5280546001600160a01b0319166001600160a01b0392909216919091179055565b60605f5f846001600160a01b031684604051614a0c9190615eee565b5f60405180830381855af49150503d805f8114614a44576040519150601f19603f3d011682016040523d82523d5f602084013e614a49565b606091505b5091509150614a59858383614afd565b95945050505050565b3415612ff25760405163b398979f60e01b815260040160405180910390fd5b614a8b8383614b50565b6113bf335f85858561359b565b5f6001600160a01b03831615801590614af55750826001600160a01b0316846001600160a01b03161480614ad15750614ad18484612485565b80614af55750826001600160a01b0316614aea83612988565b6001600160a01b0316145b949350505050565b606082614b1257614b0d82614bb1565b6122ca565b8151158015614b2957506001600160a01b0384163b155b15614b495783604051639996b31560e01b8152600401610aac9190614cff565b50806122ca565b6001600160a01b038216614b79575f604051633250574960e11b8152600401610aac9190614cff565b5f614b8583835f613017565b90506001600160a01b038116156113bf575f6040516339e3563760e11b8152600401610aac9190614cff565b805115614bc057805160208201fd5b60405163d6bda27560e01b815260040160405180910390fd5b60408051610260810182525f80825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290529061014082019081526020015f81526020015f151581526020015f81526020015f81526020015f81526020015f81526020015f6007811115614c6c57614c6c61525b565b81525f60209091015290565b6001600160e01b0319811681146114e9575f5ffd5b5f60208284031215614c9d575f5ffd5b81356122ca81614c78565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6122ca6020830184614ca8565b5f60208284031215614cf8575f5ffd5b5035919050565b6001600160a01b0391909116815260200190565b6001600160a01b03811681146114e9575f5ffd5b8035614d3281614d13565b919050565b5f5f60408385031215614d48575f5ffd5b8235614d5381614d13565b946020939093013593505050565b5f5f5f5f5f60a08688031215614d75575f5ffd5b8535614d8081614d13565b94506020860135614d9081614d13565b93506040860135614da081614d13565b92506060860135614db081614d13565b91506080860135614dc081614d13565b809150509295509295909350565b5f5f5f60608486031215614de0575f5ffd5b8335614deb81614d13565b92506020840135614dfb81614d13565b929592945050506040919091013590565b5f5f60408385031215614e1d575f5ffd5b823591506020830135614e2f81614d13565b809150509250929050565b5f60208284031215614e4a575f5ffd5b81356122ca81614d13565b5f5f60408385031215614e66575f5ffd5b50508035926020909101359150565b634e487b7160e01b5f52604160045260245ffd5b60405161012081016001600160401b0381118282101715614eac57614eac614e75565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614eda57614eda614e75565b604052919050565b5f6001600160401b03821115614efa57614efa614e75565b50601f01601f191660200190565b5f82601f830112614f17575f5ffd5b8135614f2a614f2582614ee2565b614eb2565b818152846020838601011115614f3e575f5ffd5b816020850160208301375f918101602001919091529392505050565b5f5f60408385031215614f6b575f5ffd5b8235614f7681614d13565b915060208301356001600160401b03811115614f90575f5ffd5b614f9c85828601614f08565b9150509250929050565b5f6102408284031215614fb7575f5ffd5b50919050565b5f6102408284031215614fce575f5ffd5b6122ca8383614fa6565b5f5f5f838503610180811215614fec575f5ffd5b8435935060208501359250610140603f1982011215615009575f5ffd5b506040840190509250925092565b6001600160401b03811681146114e9575f5ffd5b8035614d3281615017565b5f5f60408385031215615047575f5ffd5b823591506020830135614e2f81615017565b5f5f83601f840112615069575f5ffd5b5081356001600160401b0381111561507f575f5ffd5b602083019150836020828501011115615096575f5ffd5b9250929050565b5f5f602083850312156150ae575f5ffd5b82356001600160401b038111156150c3575f5ffd5b6150cf85828601615059565b90969095509350505050565b80151581146114e9575f5ffd5b8035614d32816150db565b5f5f60408385031215615104575f5ffd5b823561510f81614d13565b91506020830135614e2f816150db565b5f5f60408385031215615130575f5ffd5b82359150602083013560088110614e2f575f5ffd5b5f5f5f5f60808587031215615158575f5ffd5b843561516381614d13565b9350602085013561517381614d13565b92506040850135915060608501356001600160401b03811115615194575f5ffd5b6151a087828801614f08565b91505092959194509250565b5f5f5f5f606085870312156151bf575f5ffd5b843593506020850135925060408501356001600160401b038111156151e2575f5ffd5b6151ee87828801615059565b95989497509550505050565b5f5f610260838503121561520c575f5ffd5b823561521781614d13565b91506152268460208501614fa6565b90509250929050565b5f5f60408385031215615240575f5ffd5b823561524b81614d13565b91506020830135614e2f81614d13565b634e487b7160e01b5f52602160045260245ffd5b6002811061527f5761527f61525b565b9052565b6003811061527f5761527f61525b565b6008811061527f5761527f61525b565b5f610260820190508251825260208301516020830152604083015160408301526060830151606083015260808301516152e2608084018261ffff169052565b5060a08301516152f860a084018261ffff169052565b5060c083015161531360c08401826001600160401b03169052565b5060e083015161532e60e08401826001600160a01b03169052565b5061010083015161534b6101008401826001600160401b03169052565b506101208301516153686101208401826001600160401b03169052565b5061014083015161537d61014084018261526f565b50610160830151615392610160840182615283565b506101808301516153a861018084018215159052565b506101a08301516101a08301526101c08301516101c08301526101e08301516101e08301526102008301516102008301526102208301516153ed610220840182615293565b5061024083015161247e61024084018215159052565b600181811c9082168061541757607f821691505b602082108103614fb757634e487b7160e01b5f52602260045260245ffd5b5f82601f830112615444575f5ffd5b8151615452614f2582614ee2565b818152846020838601011115615466575f5ffd5b8160208501602083015e5f918101602001919091529392505050565b600281106114e9575f5ffd5b8051614d3281615482565b8051614d32816150db565b61ffff811681146114e9575f5ffd5b8051614d32816154a4565b8051614d3281615017565b5f602082840312156154d9575f5ffd5b81516001600160401b038111156154ee575f5ffd5b82016101208185031215615500575f5ffd5b615508614e89565b81516001600160401b0381111561551d575f5ffd5b61552986828501615435565b8252506155386020830161548e565b602082015261554960408301615499565b604082015261555a606083016154b3565b606082015261556b608083016154be565b608082015261557c60a083016154b3565b60a082015261558d60c083016154b3565b60c082015261559e60e083016154b3565b60e08201526155b061010083016154be565b610100820152949350505050565b5f602082840312156155ce575f5ffd5b5051919050565b5f5f604083850312156155e6575f5ffd5b82516020840151909250614e2f81615017565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561098f5761098f6155f9565b808202811582820484141761098f5761098f6155f9565b5f8261565157634e487b7160e01b5f52601260045260245ffd5b500490565b5f60208284031215615666575f5ffd5b81516122ca816150db565b8051614d3281614d13565b5f6020828403121561568c575f5ffd5b81516122ca81614d13565b604081016156a58285615293565b6122ca6020830184615293565b8035614d32816154a4565b8035614d3281615482565b803560038110614d32575f5ffd5b813581526020808301359082015260408083013590820152606080830135908201526102408101615709608084016156b2565b61ffff16608083015261571e60a084016156b2565b61ffff1660a083015261573360c0840161502b565b6001600160401b031660c083015261574d60e08401614d27565b6001600160a01b031660e0830152615768610100840161502b565b6001600160401b0316610100830152615784610120840161502b565b6001600160401b03166101208301526157a061014084016156bd565b6157ae61014084018261526f565b506157bc61016084016156c8565b6157ca610160840182615283565b506157d861018084016150e8565b15156101808301526101a083810135908301526101c080840135908301526101e08084013590830152610200808401359083015261581961022084016150e8565b80151561022084015261247e565b610140810161584182615839856156b2565b61ffff169052565b61584d6020840161502b565b6001600160401b031660208301526158676040840161502b565b6001600160401b031660408301526158816060840161502b565b6001600160401b0316606083015261589b608084016156bd565b6158a8608084018261526f565b506158b560a084016156c8565b6158c260a0840182615283565b506158cf60c084016150e8565b151560c083015260e08381013590830152610100808401359083015261012092830135929091019190915290565b838152826020820152606060408201525f614a596060830184614ca8565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b838152604060208201525f614a5960408301848661591b565b5f60c082840312801561596d575f5ffd5b5060405160c081016001600160401b038111828210171561599057615990614e75565b604052825161599e816154a4565b815260208301516159ae816154a4565b602082015260408301516159c181615017565b604082015260608301516159d481615017565b606082015260808301516159e781615017565b608082015260a08301516159fa81615017565b60a08201529392505050565b83815260608101615a1a6020830185615293565b614af56040830184615293565b848152836020820152606060408201525f6130f860608301848661591b565b5f81518060208401855e5f93019283525090919050565b5f614af5615a6b8386615a46565b84615a46565b828152604060208201525f614af56040830184614ca8565b5f610120828403128015615a9b575f5ffd5b50615aa4614e89565b8251815260208084015190820152604080840151908201526060808401519082015260808084015190820152615adc60a08401615671565b60a0820152615aed60c084016154be565b60c0820152615afe60e08401615499565b60e0820152615b106101008401615499565b6101008201529392505050565b5f61024082019050825182526020830151602083015260408301516040830152606083015160608301526080830151615b5c608084018261ffff169052565b5060a0830151615b7260a084018261ffff169052565b5060c0830151615b8d60c08401826001600160401b03169052565b5060e0830151615ba860e08401826001600160a01b03169052565b50610100830151615bc56101008401826001600160401b03169052565b50610120830151615be26101208401826001600160401b03169052565b50610140830151615bf761014084018261526f565b50610160830151615c0c610160840182615283565b50610180830151615c2261018084018215159052565b506101a08301516101a08301526101c08301516101c08301526101e08301516101e083015261020083015161020083015261022083015161247e61022084018215159052565b600a811061527f5761527f61525b565b828152604081016122ca6020830184615c68565b5f5f5f60608486031215615c9e575f5ffd5b83516020850151909350615cb181615017565b6040850151909250615cc2816150db565b809150509250925092565b84815260808101615ce16020830186615c68565b60408201939093526060015292915050565b6001600160a01b03858116825284166020820152604081018390526080606082018190525f906130f890830184614ca8565b5f60208284031215615d35575f5ffd5b81516122ca81614c78565b5f60208284031215615d50575f5ffd5b81356122ca816154a4565b5f60208284031215615d6b575f5ffd5b81356122ca81615017565b5f60208284031215615d86575f5ffd5b81356122ca81615482565b5f60208284031215615da1575f5ffd5b6122ca826156c8565b5f60208284031215615dba575f5ffd5b81356122ca816150db565b8082018082111561098f5761098f6155f9565b5f60018201615de957615de96155f9565b5060010190565b601f8211156113bf57805f5260205f20601f840160051c81016020851015615e155750805b601f840160051c820191505b81811015610f86575f8155600101615e21565b81516001600160401b03811115615e4d57615e4d614e75565b615e6181615e5b8454615403565b84615df0565b6020601f821160018114615e93575f8315615e7c5750848201515b5f19600385901b1c1916600184901b178455610f86565b5f84815260208120601f198516915b82811015615ec25787850151825560209485019460019092019101615ea2565b5084821015615edf57868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b5f6122ca8284615a4656fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc59abfac6520ec36a6556b2a4dd949cc40007459bcd5cd2507f1e5cc77b6bc97e55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041a2646970667358221220c3531ecb31a12d07ac2a5b80686148d5b1422882613bddc46935f784acdcd92564736f6c634300081e0033","name":"ClaimBridge","is_blueprint":false,"license_type":"none","is_fully_verified":false,"is_verified_via_eth_bytecode_db":true,"language":"solidity","evm_version":"cancun","can_be_visualized_via_sol2uml":true,"is_verified_via_sourcify":true,"additional_sources":[{"file_path":"lib/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity >=0.4.16;\n\n/**\n * @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n    /**\n     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n     * address.\n     *\n     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n     * function revert if invoked through a proxy.\n     */\n    function proxiableUUID() external view returns (bytes32);\n}\n"},{"file_path":"lib/openzeppelin-contracts-upgradeable/contracts/utils/ReentrancyGuardUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)\n\npragma solidity ^0.8.20;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,\n * consider using {ReentrancyGuardTransient} instead.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant NOT_ENTERED = 1;\n    uint256 private constant ENTERED = 2;\n\n    /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard\n    struct ReentrancyGuardStorage {\n        uint256 _status;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.ReentrancyGuard\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;\n\n    function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {\n        assembly {\n            $.slot := ReentrancyGuardStorageLocation\n        }\n    }\n\n    /**\n     * @dev Unauthorized reentrant call.\n     */\n    error ReentrancyGuardReentrantCall();\n\n    function __ReentrancyGuard_init() internal onlyInitializing {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n        $._status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n        // On the first call to nonReentrant, _status will be NOT_ENTERED\n        if ($._status == ENTERED) {\n            revert ReentrancyGuardReentrantCall();\n        }\n\n        // Any calls to nonReentrant after this point will fail\n        $._status = ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        $._status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n        return $._status == ENTERED;\n    }\n}\n"},{"file_path":"src/libraries/Config.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\n/// @title Config\n/// @notice Single source of truth for token naming and protocol default parameters\n///         (brief Part 12: names are final but kept in one module so a rebrand is a\n///         single change).\nlibrary Config {\n    // ── Token naming (final per brief Part 12) ──────────────────────────\n    string internal constant USDFR_NAME = \"Forest Road Dollar\";\n    string internal constant USDFR_SYMBOL = \"USDfr\";\n    string internal constant SUSDFR_NAME = \"Staked Forest Road Dollar\";\n    string internal constant SUSDFR_SYMBOL = \"sUSDfr\";\n    string internal constant GROVE_NAME = \"Forest Road Grove\";\n    string internal constant GROVE_SYMBOL = \"GROVE\";\n    string internal constant SGROVE_NAME = \"Staked Forest Road Grove\";\n    string internal constant SGROVE_SYMBOL = \"sGROVE\";\n\n    // ── Collateral class IDs (ADR-0003 as amended: all FIVE live at genesis) ──\n    uint256 internal constant CLASS_FILM_TAX_CREDITS = 1;\n    uint256 internal constant CLASS_RENEWABLE_ENERGY = 2;\n    uint256 internal constant CLASS_LIFE_SCIENCES = 3;\n    uint256 internal constant CLASS_REAL_ESTATE = 4;\n    /// @dev Marked-to-market, related-party class (ADR-0015) — distinct margin/\n    ///      liquidation model, NOT the receivable model of classes 1-4.\n    uint256 internal constant CLASS_DIGITAL_ASSETS = 5;\n    uint256 internal constant NUM_CLASSES = 5;\n\n    // ── Credit-layer defaults (ADR-0004 / ADR-0014; governance-adjustable) ──\n    /// @dev USD amounts in 18 decimals (USDfr units).\n    uint256 internal constant DEFAULT_FIRST_LOSS_PER_CLASS = 10_000_000e18;\n    uint256 internal constant SGROVE_UNBONDING_PERIOD = 21 days;\n    // Reward streaming window (ADR-0021 / audit R4-EC1): notified rewards drip linearly\n    // over this period rather than distributing instantly, so rewards accrue in real time\n    // (Pendle-compatible) and cannot be sandwiched by a deposit-before-harvest. Governance\n    // tunable via setRewardsDuration, bounded by SGROVE_MAX_REWARDS_DURATION.\n    uint64 internal constant SGROVE_REWARDS_DURATION = 7 days;\n    uint64 internal constant SGROVE_MAX_REWARDS_DURATION = 365 days;\n\n    // ── Governance defaults (ADR-0013/0021; FR-controlled at launch) ─────\n    /// @dev Fixed at genesis, minted to the Forest Road treasury (ADR-0013).\n    uint256 internal constant GROVE_INITIAL_SUPPLY = 1_000_000_000e18;\n    uint48 internal constant GOV_VOTING_DELAY = 1 days;\n    /// @dev Fresh Ethereum genesis: owner-approved 2026-09-18; existing proxy settings persist.\n    uint32 internal constant GOV_VOTING_PERIOD = 2 days;\n    uint256 internal constant GOV_PROPOSAL_THRESHOLD = 1_000_000e18; // 0.1% of supply\n    uint256 internal constant GOV_QUORUM_FRACTION = 4; // % of total votes\n    uint256 internal constant TIMELOCK_MIN_DELAY = 2 days;\n    /// @dev C-01 reserve-loss pre-arm floor. The live arm duration is derived from the\n    ///      bound Governor and Timelock at arm time and may be longer; this immutable\n    ///      floor prevents a broken or shortened timing dependency from failing open.\n    uint256 internal constant RESERVE_LOSS_MIN_PREARM_DURATION = 11 days;\n    uint256 internal constant RESERVE_LOSS_SCHEDULING_SLACK = 1 days;\n    /// @dev Preserve the original curator pre-arm floor when launch voting is shortened.\n    ///      Longer live governance schedules still extend the derived protection.\n    uint256 internal constant CURATOR_PRE_ARM_MIN_GOVERNANCE_PATH = 10 days;\n\n    /// @dev Protocol fee on distributed interest (waterfall), in bps. Launch default\n    ///      is deliberately modest; governance-adjustable; economic-review item.\n    uint256 internal constant DEFAULT_PROTOCOL_FEE_BPS = 1_000; // 10% of interest\n\n    /// @dev AUDIT FIX (SWEEP-2 S2-F1) — PERMANENT HARD CAP ON THE INTEREST PROTOCOL FEE.\n    ///      DO NOT DELETE AND DO NOT RAISE WITHOUT FOREST ROAD DIRECTION.\n    ///\n    ///      Before this, `WaterfallEngine.setProtocolFee` was bounded only by `Config.BPS` — it was\n    ///      the ONLY fee rate in the protocol with no permanent ceiling, while its three siblings\n    ///      (`setOriginationFee` -> `MAX_ORIGINATION_FEE_BPS`, `sUSDfr.setPerformanceFee` ->\n    ///      `MAX_PERFORMANCE_FEE_BPS`, `setManagementFee` -> `MAX_MANAGEMENT_FEE_BPS`) all carry\n    ///      one and two of those are PUBLISHED to holders (`maxPerformanceFeeBps()`,\n    ///      `maxManagementFeeBps()`) and described here as \"permanent in v1\". MEASURED: 10,000 bps\n    ///      was accepted and took the ENTIRE senior yield leg (`toVault` 0, `toFee` the whole\n    ///      interest receipt). Because `_routeInterest` takes this fee FIRST, off the same senior\n    ///      income stream the vault's 20% performance cap protects, total capture of senior yield\n    ///      was reachable AROUND a cap the protocol advertises as permanent — and the fee recipient\n    ///      holds plain USDfr, so it is not a cascade layer.\n    ///\n    ///      The LEVEL mirrors `MAX_PERFORMANCE_FEE_BPS` (20%), i.e. 2x the launch default, which\n    ///      is the house convention for \"a permanent ceiling with real governance room under it\".\n    ///      The level is an economic-review item; the EXISTENCE of the ceiling is not.\n    uint16 internal constant MAX_PROTOCOL_FEE_BPS = 2_000; // 20% of interest — permanent in v1\n\n    /// @dev Protocol-level performance fee on sUSDfr NAV gains above the global,\n    ///      post-fee high-water mark. Launches at 10% and may only be changed\n    ///      prospectively by timelocked governance. The hard cap is permanent in v1.\n    uint16 internal constant DEFAULT_PERFORMANCE_FEE_BPS = 1_000; // 10% of profit\n    uint16 internal constant MAX_PERFORMANCE_FEE_BPS = 2_000; // 20% of profit\n\n    /// @dev Effective-annual sUSDfr management fee on a 365-day basis. Launches disabled\n    ///      and may only be enabled prospectively by timelocked governance. Fractional\n    ///      periods use geometric retention; the hard cap is permanent in v1.\n    uint16 internal constant DEFAULT_MANAGEMENT_FEE_BPS = 0;\n    uint16 internal constant MAX_MANAGEMENT_FEE_BPS = 200; // 2% per 365-day year\n    uint64 internal constant MANAGEMENT_FEE_YEAR = 365 days;\n\n    /// @dev Origination fee charged at facility funding, in bps of principal (OID\n    ///      mechanics: the borrower nets principal minus fee). Market range for the\n    ///      book's verticals is ~1-2% (ADR-0019); per-class governance-adjustable,\n    ///      capped at MAX_ORIGINATION_FEE_BPS; economic-review item.\n    uint16 internal constant DEFAULT_ORIGINATION_FEE_BPS = 200; // 2% of principal (Forest Road direction)\n    uint16 internal constant MAX_ORIGINATION_FEE_BPS = 1_000; // 10% hard cap\n\n    /// @dev Margin-call cure window for marked-to-market classes (ADR-0015:\n    ///      \"hours-to-days\"). Governance-adjustable per class; economic-review item.\n    uint64 internal constant DEFAULT_MARGIN_CURE_WINDOW = 1 days;\n\n    // ── Liquidity-layer defaults (ADR-0010/0022; governance-adjustable) ──\n    /// @dev Settlement HEARTBEAT (ADR-0022): how often `closeEpoch` may run and refresh\n    ///      the liquidity budget. Under the ADR-0022 cooldown model this is NOT the\n    ///      holding period — `DEFAULT_REDEEM_COOLDOWN` is. The heartbeat must be SHORT\n    ///      relative to the cooldown so the effective wait ≈ cooldown (no compounding).\n    ///      Heartbeat/liquidity calibration is an economic-review item (ADR-0022 §X.5).\n    uint64 internal constant DEFAULT_EPOCH_DURATION = 1 days;\n    /// @dev Share of the treasury's idle canonical-USDC liquidity a settlement may\n    ///      distribute to the queue PER\n    ///      HEARTBEAT, leaving the remainder for direct USDfr redemptions. Rescaled from\n    ///      the legacy 50%/30-day batch to preserve ~50%/30-day throughput at a 1-day\n    ///      heartbeat (5000/30 ≈ 167). Economic-review item (ADR-0022 §X.5).\n    uint16 internal constant DEFAULT_EPOCH_LIQUIDITY_BPS = 167; // ~1.67%/day ≈ 50%/30d\n\n    /// @dev ADR-0022: forced per-request redemption cooldown. A queued redemption cannot\n    ///      settle until `requestedAt + DEFAULT_REDEEM_COOLDOWN`. Matches\n    ///      `SGROVE_UNBONDING_PERIOD` (21 days) — long enough that a senior cannot exit\n    ///      ahead of a foreseeable loss (front-running / loss-dodge defense).\n    uint64 internal constant DEFAULT_REDEEM_COOLDOWN = 21 days;\n\n    /// @dev AUDIT FIX (SWEEP-2 CSG-F2) — the UPPER bound on `RedemptionQueue.setRedeemCooldown`.\n    ///      The LOWER bound is `DEFAULT_REDEEM_COOLDOWN` itself and is not a separate constant on\n    ///      purpose: the G2W relief ramp in `CollateralRegistry.conservativeSeniorMark` is written\n    ///      against that exact constant, so the floor must BE it — a second constant is a second\n    ///      thing to forget to move (SEAM-1). 180 days is the same order as\n    ///      `SGrove.setUnbondingPeriod`'s `AUDIT FIX (L)` ceiling and exists for the same reason:\n    ///      an unbounded setter can permanently freeze every queued senior exit by fat finger.\n    uint64 internal constant MAX_REDEEM_COOLDOWN = 180 days;\n\n    /// @dev C-1 anti-dust-wedge floor. Minimum REALIZED value (in USDfr, 18 decimals) a\n    ///      redemption request must be worth to enter the queue — $1. `closeEpoch` never burns a\n    ///      position worth zero at the conservative mark; it stops there, so a sub-wei \"dust\" head\n    ///      could otherwise wedge the queue for the real positions behind it. Barring dust at entry\n    ///      makes that wedge reachable only when the exchange rate has collapsed by >1e18x (a\n    ///      >99.9999999999999999% senior loss), at which point every realistically-sized position\n    ///      is ALSO worth under a wei and halting the queue is the correct behaviour, not griefing.\n    ///      Measured at the REALIZED rate (`convertToAssets`), not the conservative one, so a\n    ///      declared-but-unrealized impairment does not lock new exits out of the queue.\n    ///      Governance-tunable via `RedemptionQueue.setMinRedemptionValue`.\n    uint256 internal constant DEFAULT_MIN_REDEMPTION_VALUE = 1e18; // 1 USDfr ($1)\n\n    // ── Optional senior-yield vesting (ADR-0023; governance-adjustable) ──\n    /// @dev Realized senior yield may be vested linearly into `sUSDfr.totalAssets()`\n    ///      instead of landing as an instant step. Only ALREADY-REALIZED yield can be\n    ///      streamed — nothing forward-looking is ever pre-credited, so ADR-0002\n    ///      variable-yield pass-through is untouched. Pendle accepts a valid stepwise SY\n    ///      exchange rate; smoothing is an optional market-design control against\n    ///      payment-timing games and abrupt asset-denominated price moves, not a Pendle\n    ///      protocol prerequisite. Forest Road selected instant recognition for launch.\n    ///      Governance may enable a non-zero window prospectively after economic review.\n    uint64 internal constant DEFAULT_YIELD_VESTING_PERIOD = 0;\n    /// @dev Hard ceiling on a newly opened stream. The vault also stores an absolute stream\n    ///      deadline that non-zero governance re-tunes and rollovers may shorten but never\n    ///      extend, so alternating settings cannot defer the same realized yield indefinitely.\n    uint64 internal constant MAX_YIELD_VESTING_PERIOD = 30 days;\n\n    /// @notice RAMP POSTURE (Forest Road direction, 2026-07-21): concentration limits are\n    ///         seeded WIDE OPEN so idle deposit capital can be deployed into originations —\n    ///         initially a facility to the digital-assets book — without a concentration\n    ///         dimension blocking it before the book has any diversity to measure.\n    /// @dev At `BPS` (100%) the admission test `exp > limitBps * base / BPS` reduces to\n    ///      `exp > base`, and no single dimension can exceed the book, so NOTHING BINDS.\n    ///      Two consequences the operator must hold in mind, both stated rather than implied:\n    ///        1. Concentration TELEMETRY GOES DARK. `isOverConcentrated`, the drift events and\n    ///           `concentrationHeadroom` all measure against the configured limit, so at 100%\n    ///           they report \"clean\" unconditionally. There is no on-chain early warning while\n    ///           this posture holds; monitoring must come from the `ExposureRecorded` stream.\n    ///        2. RATCHETING DOWN LATER IS A CLIFF. Limits are ADMISSION control and a standing\n    ///           breach is permitted (a decrease can never be blocked, or a risk limit could\n    ///           veto a loss being realized). So whatever is concentrated when a real limit is\n    ///           set will instantly read as breached and be frozen from further growth until\n    ///           the book grows around it. Set the first real limits AT or slightly above the\n    ///           actual composition at that time, then step down — do not jump straight to the\n    ///           target.\n    ///      `Validate.s.sol` prints an unmissable posture block whenever this is in force, so\n    ///      an unlimited deployment can never produce output identical to a limited one.\n    uint16 internal constant RAMP_CONCENTRATION_LIMIT_BPS = 10_000; // 100% = unbounded\n\n    uint256 internal constant BPS = 10_000;\n\n    /// @notice Forward weight, in bps, that an UNATTESTED permissionless past-due mark\n    ///         (`DefaultManager.markPastDue`) carries in the conservative redemption NAV,\n    ///         relative to an ATTESTED declared default. Used as the fallback whenever\n    ///         `DefaultManager`'s governed slot reads zero (see `pastDueWeightBps()`).\n    /// @dev OWNER DECISION (Forest Road, 2026-08-07): \"An unattested, permissionless past-due\n    ///      mark should NOT carry the same forward weight as an attested declared default.\"\n    ///\n    ///      DERIVED, NOT INVENTED. The protocol already governs an evidence ladder — but only on\n    ///      the marked-to-market side, where the three rungs are per-class registry parameters:\n    ///        - `maxLtvBps`         the rung the protocol is willing to be exposed at (healthy);\n    ///        - `marginCallLtvBps`  the rung at which a PERMISSIONLESS, REVERSIBLE early warning\n    ///                              fires (`marginCall`) — forward impairment weight ZERO, it only\n    ///                              starts a cure clock;\n    ///        - `liquidationLtvBps` the terminal rung, where `liquidate` records the FULL\n    ///                              outstanding into the impairment pool and `realizeLoss` becomes\n    ///                              reachable — forward impairment weight ONE.\n    ///      `markPastDue` is the receivable-side analogue of the MARGIN-CALL rung: permissionless,\n    ///      reversible, early, and strictly BEFORE the terminal attested rung (`declareDefault`).\n    ///      Governance placed that early rung exactly half way along the governed deterioration\n    ///      band. From the mainnet-v1 class-5 tuple in `script/Deploy.s.sol`\n    ///      (maxLtv 5_000, marginCall 6_500, liquidation 8_000):\n    ///\n    ///          (marginCallLtvBps - maxLtvBps) / (liquidationLtvBps - maxLtvBps)\n    ///            = (6_500 - 5_000) / (8_000 - 5_000) = 1_500 / 3_000 = 1/2 = 5_000 bps.\n    ///\n    ///      WHY NOT THE ADVANCE RATE ALONE. `maxLtvBps`/`ltvBps` cannot supply this weight, and the\n    ///      reasoning is recorded here so it is not re-attempted: the advance rate is DEFINED as the\n    ///      break-even recovery on the attested claim face (ClaimBridge documents the denominator as\n    ///      `principal * BPS / ltvBps`). Senior loss is `max(0, principal - recovery)`, so at a\n    ///      recovery equal to the advance rate the loss is identically ZERO — the advance rate\n    ///      derives a weight of 0, which re-opens H-5 and D5-03. Worse, every variant that forces a\n    ///      positive number out of it (haircut on face, re-advance against carried principal) is\n    ///      MONOTONE THE WRONG WAY: it marks a more conservatively underwritten facility harder.\n    ///\n    ///      DO NOT set this to zero (re-opens H-5: a conflicted servicer can sit on a declaration\n    ///      while seniors exit at par) or to `BPS` (restores the defect this constant fixes).\n    ///      `CollateralRegistry.setPastDueWeight` enforces both bounds.\n    uint256 internal constant DEFAULT_PAST_DUE_WEIGHT_BPS = 5_000; // 50%\n\n    /// @notice sUSDfr entry guard (audit H-3 residual): the maximum ratio of the STRANDED,\n    ///         realized-but-unvested yield stream (`sUSDfr.unvestedYield()`) to the DEPOSIT BASE\n    ///         (`sUSDfr.totalAssets()`) that vault entry tolerates before `deposit`/`mint` close as\n    ///         degenerate.\n    /// @dev THE HAZARD (ADR-0023): the vault physically holds realized yield that vests linearly\n    ///      into `totalAssets()` over a window and is EXCLUDED from `totalAssets()` until it does.\n    ///      Deposits price on `totalAssets()` (OZ's un-overridden `_convertToShares`), so a\n    ///      depositor entering while that stranded stream is large relative to the base buys shares\n    ///      cheaply and then skims a pro-rata slice of the stream as it vests — extracting from the\n    ///      incumbents who funded it. The hazard scales with `unvestedYield() / totalAssets()`, so\n    ///      the guard keys on exactly that ratio.\n    ///\n    ///      CALIBRATION (economic-review item; audit finding #3 re-key from 10 to 3, then audit\n    ///      R16-01). `sUSDfr._capStreamToBase` enforces a retention boundary against the ACTUAL\n    ///      staked base on both sides of the vault: after every yield delivery AND before every\n    ///      queue outflow, at most `1/(K+1)` of physical vault USDfr remains unvested and any\n    ///      excess is recognized immediately. A healthy low-staking vault therefore cannot be\n    ///      closed by receiving a payment that is large relative to deposits (FRV-FS-03), nor by\n    ///      an ordinary settlement shrinking the base under a live stream (RC-03).\n    ///      The guard remains meaningful after a senior write-down, which burns the recognized\n    ///      base while leaving an already-live stream physically present.\n    ///\n    ///      WHY 3 AND NOT 10 (the audit residual). The OLD `K = 10` reopened entry the moment the\n    ///      ratio fell to 10 — with the stranded stream still 10/11 (~91%) of the vault balance —\n    ///      leaving a near-total skim band `(0, 10]` open. It did NOT \"close the entire band\": near\n    ///      the top of that band a fresh depositor could still skim ~91% of the vault as the stream\n    ///      vested. Dropping to `K = 3` collapses the open band to `(0, 3)`. `K = 3` bounds the\n    ///      excluded stream at the closure point to 3/4 (~75%) of physical vault assets. It is a\n    ///      DIMENSIONLESS ratio, not a wei level, so it holds identically at every vault scale.\n    ///\n    ///      CORRECTION (AUDIT R16-01, HIGH — the previous justification of the open band was\n    ///      FALSE; do not restore it). This comment used to argue that the top of the `(0, K]` band\n    ///      is \"only reachable while the withheld stream is a MAJORITY of the vault, an\n    ///      already-catastrophic near-total-write-down state, never a healthy one\". That was wrong,\n    ///      and `K` was never what bounded a routine deposit's skim. The FRV-FS-03 inflow leg\n    ///      created exactly that ratio in a HEALTHY vault: the cap retained `K/(K+1)` of the\n    ///      balance, the largest retention the guard tolerates, which parks the vault at precisely\n    ///      `unvestedYield() == K * totalAssets()` — and `_isDegenerate`'s strict `>` left entry\n    ///      OPEN on that point. Servicing payments are sized off book principal, not off live\n    ///      sUSDfr supply, so any payment large relative to the staked base reached it. What bounds\n    ///      the routine skim is the CAP's retention target, now `1/(K+1)`: healthy operation parks\n    ///      at ratio `1/K`, a factor of `K^2` inside this guard, with a minority (25%) of the\n    ///      vault's cash excluded, and the boundary itself is now CLOSED (`>=`). The band between\n    ///      `1/K` and `K` is reachable only through a realized loss or a governance re-pricing of\n    ///      the vesting window.\n    ///\n    ///      Kept a constant rather than a governance-tunable for\n    ///      this pass: like `SUSDFR_MAX_SHARE_PRICE_COLLAPSE`, it is a defensive safety floor, not an\n    ///      operating knob, and adding storage/setter surface to the namespaced vault struct for it\n    ///      is unwarranted complexity here; a future pass may promote it to a governed parameter.\n    ///      See `SUSDfr._isDegenerate` and `SUSDfr._capStreamToBase`.\n    uint256 internal constant SUSDFR_MAX_STRANDED_YIELD_RATIO = 3;\n\n    /// @dev AUDIT R15-01. Vault entry closes once the realized per-share rate has collapsed to\n    ///      below `1 / SUSDFR_DEGENERATE_RATE_DIVISOR` of the stored high-water mark.\n    ///\n    ///      WHY A SECOND BAND IS NEEDED. `SUSDFR_MAX_STRANDED_YIELD_RATIO` above keys on\n    ///      `unvestedYield()`, which is identically zero at the launch instant-recognition policy\n    ///      (`DEFAULT_YIELD_VESTING_PERIOD == 0`). That band therefore cannot fire at launch,\n    ///      leaving only the `totalAssets() == 0` POINT — and one wei of a permissionless USDfr\n    ///      transfer steps off a point. `_isDegenerate`'s own rationale states the hazard is the\n    ///      whole neighbourhood, not the point; this restores the neighbourhood at every vesting\n    ///      setting.\n    ///\n    ///      WHY PAR IS THE REFERENCE. The stored high-water mark was tried first and rejected:\n    ///      `_accrueFees`'s empty-supply branch ratchets it to `(assets + 1) * 1e18` whenever any\n    ///      balance exists while `totalSupply() == 0`, so a pre-seed donation could inflate the\n    ///      hurdle arbitrarily and then permanently close entry through this band. That is\n    ///      harmless while the HWM only suppresses fees, and becomes a brick the moment entry\n    ///      depends on it — the invariant suite caught exactly that. Par is derived from the\n    ///      token's own decimals, is scale-free, and no actor can move it.\n    ///\n    ///      WHY 100. The band must separate a catastrophic collapse from a merely bad year, because\n    ///      closing entry is a governance event: a vault below 1% of its high-water mark is the\n    ///      near-total write-down the guard exists for, while a 50%-drawdown vault stays open to\n    ///      new capital. ECONOMIC-REVIEW ITEM, on the same footing as `K = 3` above — the shape is\n    ///      a safety floor, but the exact multiple is a judgement about when recapitalization must\n    ///      route through governance rather than through an ordinary deposit.\n    uint256 internal constant SUSDFR_DEGENERATE_RATE_DIVISOR = 100;\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/math/Math.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\nimport {Panic} from \"../Panic.sol\";\nimport {SafeCast} from \"./SafeCast.sol\";\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Floor, // Toward negative infinity\n        Ceil, // Toward positive infinity\n        Trunc, // Toward zero\n        Expand // Away from zero\n    }\n\n    /**\n     * @dev Return the 512-bit addition of two uint256.\n     *\n     * The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.\n     */\n    function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {\n        assembly (\"memory-safe\") {\n            low := add(a, b)\n            high := lt(low, a)\n        }\n    }\n\n    /**\n     * @dev Return the 512-bit multiplication of two uint256.\n     *\n     * The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.\n     */\n    function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {\n        // 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use\n        // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n        // variables such that product = high * 2²⁵⁶ + low.\n        assembly (\"memory-safe\") {\n            let mm := mulmod(a, b, not(0))\n            low := mul(a, b)\n            high := sub(sub(mm, low), lt(mm, low))\n        }\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, with a success flag (no overflow).\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            uint256 c = a + b;\n            success = c >= a;\n            result = c * SafeCast.toUint(success);\n        }\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            uint256 c = a - b;\n            success = c <= a;\n            result = c * SafeCast.toUint(success);\n        }\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            uint256 c = a * b;\n            assembly (\"memory-safe\") {\n                // Only true when the multiplication doesn't overflow\n                // (c / a == b) || (a == 0)\n                success := or(eq(div(c, a), b), iszero(a))\n            }\n            // equivalent to: success ? c : 0\n            result = c * SafeCast.toUint(success);\n        }\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a success flag (no division by zero).\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            success = b > 0;\n            assembly (\"memory-safe\") {\n                // The `DIV` opcode returns zero when the denominator is 0.\n                result := div(a, b)\n            }\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            success = b > 0;\n            assembly (\"memory-safe\") {\n                // The `MOD` opcode returns zero when the denominator is 0.\n                result := mod(a, b)\n            }\n        }\n    }\n\n    /**\n     * @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.\n     */\n    function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {\n        (bool success, uint256 result) = tryAdd(a, b);\n        return ternary(success, result, type(uint256).max);\n    }\n\n    /**\n     * @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.\n     */\n    function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {\n        (, uint256 result) = trySub(a, b);\n        return result;\n    }\n\n    /**\n     * @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.\n     */\n    function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {\n        (bool success, uint256 result) = tryMul(a, b);\n        return ternary(success, result, type(uint256).max);\n    }\n\n    /**\n     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.\n     *\n     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.\n     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute\n     * one branch when needed, making this function more expensive.\n     */\n    function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {\n        unchecked {\n            // branchless ternary works because:\n            // b ^ (a ^ b) == a\n            // b ^ 0 == b\n            return b ^ ((a ^ b) * SafeCast.toUint(condition));\n        }\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return ternary(a > b, a, b);\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return ternary(a < b, a, b);\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds towards infinity instead\n     * of rounding towards zero.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (b == 0) {\n            // Guarantee the same behavior as in a regular Solidity division.\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n\n        // The following calculation ensures accurate ceiling division without overflow.\n        // Since a is non-zero, (a - 1) / b will not overflow.\n        // The largest possible result occurs when (a - 1) / b is type(uint256).max,\n        // but the largest value we can obtain is type(uint256).max - 1, which happens\n        // when a = type(uint256).max and b = 1.\n        unchecked {\n            return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);\n        }\n    }\n\n    /**\n     * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n     * denominator == 0.\n     *\n     * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n     * Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            (uint256 high, uint256 low) = mul512(x, y);\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (high == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return low / denominator;\n            }\n\n            // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.\n            if (denominator <= high) {\n                Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));\n            }\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [high low].\n            uint256 remainder;\n            assembly (\"memory-safe\") {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                high := sub(high, gt(remainder, low))\n                low := sub(low, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n            uint256 twos = denominator & (0 - denominator);\n            assembly (\"memory-safe\") {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [high low] by twos.\n                low := div(low, twos)\n\n                // Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from high into low.\n            low |= high * twos;\n\n            // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such\n            // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv ≡ 1 mod 2⁴.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n            // works in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2⁸\n            inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶\n            inverse *= 2 - denominator * inverse; // inverse mod 2³²\n            inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴\n            inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸\n            inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶\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²⁵⁶. Since the preconditions guarantee that the outcome is\n            // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and high\n            // is no longer required.\n            result = low * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @dev Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);\n    }\n\n    /**\n     * @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.\n     */\n    function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {\n        unchecked {\n            (uint256 high, uint256 low) = mul512(x, y);\n            if (high >= 1 << n) {\n                Panic.panic(Panic.UNDER_OVERFLOW);\n            }\n            return (high << (256 - n)) | (low >> n);\n        }\n    }\n\n    /**\n     * @dev Calculates x * y >> n with full precision, following the selected rounding direction.\n     */\n    function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {\n        return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);\n    }\n\n    /**\n     * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.\n     *\n     * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.\n     * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.\n     *\n     * If the input value is not inversible, 0 is returned.\n     *\n     * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the\n     * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.\n     */\n    function invMod(uint256 a, uint256 n) internal pure returns (uint256) {\n        unchecked {\n            if (n == 0) return 0;\n\n            // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)\n            // Used to compute integers x and y such that: ax + ny = gcd(a, n).\n            // When the gcd is 1, then the inverse of a modulo n exists and it's x.\n            // ax + ny = 1\n            // ax = 1 + (-y)n\n            // ax ≡ 1 (mod n) # x is the inverse of a modulo n\n\n            // If the remainder is 0 the gcd is n right away.\n            uint256 remainder = a % n;\n            uint256 gcd = n;\n\n            // Therefore the initial coefficients are:\n            // ax + ny = gcd(a, n) = n\n            // 0a + 1n = n\n            int256 x = 0;\n            int256 y = 1;\n\n            while (remainder != 0) {\n                uint256 quotient = gcd / remainder;\n\n                (gcd, remainder) = (\n                    // The old remainder is the next gcd to try.\n                    remainder,\n                    // Compute the next remainder.\n                    // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd\n                    // where gcd is at most n (capped to type(uint256).max)\n                    gcd - remainder * quotient\n                );\n\n                (x, y) = (\n                    // Increment the coefficient of a.\n                    y,\n                    // Decrement the coefficient of n.\n                    // Can overflow, but the result is casted to uint256 so that the\n                    // next value of y is \"wrapped around\" to a value between 0 and n - 1.\n                    x - y * int256(quotient)\n                );\n            }\n\n            if (gcd != 1) return 0; // No inverse exists.\n            return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.\n        }\n    }\n\n    /**\n     * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.\n     *\n     * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is\n     * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that\n     * `a**(p-2)` is the modular multiplicative inverse of a in Fp.\n     *\n     * NOTE: this function does NOT check that `p` is a prime greater than `2`.\n     */\n    function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {\n        unchecked {\n            return Math.modExp(a, p - 2, p);\n        }\n    }\n\n    /**\n     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)\n     *\n     * Requirements:\n     * - modulus can't be zero\n     * - underlying staticcall to precompile must succeed\n     *\n     * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make\n     * sure the chain you're using it on supports the precompiled contract for modular exponentiation\n     * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,\n     * the underlying function will succeed given the lack of a revert, but the result may be incorrectly\n     * interpreted as 0.\n     */\n    function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {\n        (bool success, uint256 result) = tryModExp(b, e, m);\n        if (!success) {\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).\n     * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying\n     * to operate modulo 0 or if the underlying precompile reverted.\n     *\n     * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain\n     * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in\n     * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack\n     * of a revert, but the result may be incorrectly interpreted as 0.\n     */\n    function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {\n        if (m == 0) return (false, 0);\n        assembly (\"memory-safe\") {\n            let ptr := mload(0x40)\n            // | Offset    | Content    | Content (Hex)                                                      |\n            // |-----------|------------|--------------------------------------------------------------------|\n            // | 0x00:0x1f | size of b  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x20:0x3f | size of e  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x40:0x5f | size of m  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x60:0x7f | value of b | 0x<.............................................................b> |\n            // | 0x80:0x9f | value of e | 0x<.............................................................e> |\n            // | 0xa0:0xbf | value of m | 0x<.............................................................m> |\n            mstore(ptr, 0x20)\n            mstore(add(ptr, 0x20), 0x20)\n            mstore(add(ptr, 0x40), 0x20)\n            mstore(add(ptr, 0x60), b)\n            mstore(add(ptr, 0x80), e)\n            mstore(add(ptr, 0xa0), m)\n\n            // Given the result < m, it's guaranteed to fit in 32 bytes,\n            // so we can use the memory scratch space located at offset 0.\n            success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)\n            result := mload(0x00)\n        }\n    }\n\n    /**\n     * @dev Variant of {modExp} that supports inputs of arbitrary length.\n     */\n    function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {\n        (bool success, bytes memory result) = tryModExp(b, e, m);\n        if (!success) {\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Variant of {tryModExp} that supports inputs of arbitrary length.\n     */\n    function tryModExp(\n        bytes memory b,\n        bytes memory e,\n        bytes memory m\n    ) internal view returns (bool success, bytes memory result) {\n        if (_zeroBytes(m)) return (false, new bytes(0));\n\n        uint256 mLen = m.length;\n\n        // Encode call args in result and move the free memory pointer\n        result = abi.encodePacked(b.length, e.length, mLen, b, e, m);\n\n        assembly (\"memory-safe\") {\n            let dataPtr := add(result, 0x20)\n            // Write result on top of args to avoid allocating extra memory.\n            success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)\n            // Overwrite the length.\n            // result.length > returndatasize() is guaranteed because returndatasize() == m.length\n            mstore(result, mLen)\n            // Set the memory pointer after the returned data.\n            mstore(0x40, add(dataPtr, mLen))\n        }\n    }\n\n    /**\n     * @dev Returns whether the provided byte array is zero.\n     */\n    function _zeroBytes(bytes memory byteArray) private pure returns (bool) {\n        for (uint256 i = 0; i < byteArray.length; ++i) {\n            if (byteArray[i] != 0) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n     * towards zero.\n     *\n     * This method is based on Newton's method for computing square roots; the algorithm is restricted to only\n     * using integer operations.\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        unchecked {\n            // Take care of easy edge cases when a == 0 or a == 1\n            if (a <= 1) {\n                return a;\n            }\n\n            // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a\n            // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between\n            // the current value as `ε_n = | x_n - sqrt(a) |`.\n            //\n            // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root\n            // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is\n            // bigger than any uint256.\n            //\n            // By noticing that\n            // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`\n            // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar\n            // to the msb function.\n            uint256 aa = a;\n            uint256 xn = 1;\n\n            if (aa >= (1 << 128)) {\n                aa >>= 128;\n                xn <<= 64;\n            }\n            if (aa >= (1 << 64)) {\n                aa >>= 64;\n                xn <<= 32;\n            }\n            if (aa >= (1 << 32)) {\n                aa >>= 32;\n                xn <<= 16;\n            }\n            if (aa >= (1 << 16)) {\n                aa >>= 16;\n                xn <<= 8;\n            }\n            if (aa >= (1 << 8)) {\n                aa >>= 8;\n                xn <<= 4;\n            }\n            if (aa >= (1 << 4)) {\n                aa >>= 4;\n                xn <<= 2;\n            }\n            if (aa >= (1 << 2)) {\n                xn <<= 1;\n            }\n\n            // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).\n            //\n            // We can refine our estimation by noticing that the middle of that interval minimizes the error.\n            // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).\n            // This is going to be our x_0 (and ε_0)\n            xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)\n\n            // From here, Newton's method give us:\n            // x_{n+1} = (x_n + a / x_n) / 2\n            //\n            // One should note that:\n            // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a\n            //              = ((x_n² + a) / (2 * x_n))² - a\n            //              = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a\n            //              = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)\n            //              = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)\n            //              = (x_n² - a)² / (2 * x_n)²\n            //              = ((x_n² - a) / (2 * x_n))²\n            //              ≥ 0\n            // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n\n            //\n            // This gives us the proof of quadratic convergence of the sequence:\n            // ε_{n+1} = | x_{n+1} - sqrt(a) |\n            //         = | (x_n + a / x_n) / 2 - sqrt(a) |\n            //         = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |\n            //         = | (x_n - sqrt(a))² / (2 * x_n) |\n            //         = | ε_n² / (2 * x_n) |\n            //         = ε_n² / | (2 * x_n) |\n            //\n            // For the first iteration, we have a special case where x_0 is known:\n            // ε_1 = ε_0² / | (2 * x_0) |\n            //     ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))\n            //     ≤ 2**(2*e-4) / (3 * 2**(e-1))\n            //     ≤ 2**(e-3) / 3\n            //     ≤ 2**(e-3-log2(3))\n            //     ≤ 2**(e-4.5)\n            //\n            // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:\n            // ε_{n+1} = ε_n² / | (2 * x_n) |\n            //         ≤ (2**(e-k))² / (2 * 2**(e-1))\n            //         ≤ 2**(2*e-2*k) / 2**e\n            //         ≤ 2**(e-2*k)\n            xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5)  -- special case, see above\n            xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9)    -- general case with k = 4.5\n            xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18)   -- general case with k = 9\n            xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36)   -- general case with k = 18\n            xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72)   -- general case with k = 36\n            xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144)  -- general case with k = 72\n\n            // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision\n            // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either\n            // sqrt(a) or sqrt(a) + 1.\n            return xn - SafeCast.toUint(xn > a / xn);\n        }\n    }\n\n    /**\n     * @dev Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 x) internal pure returns (uint256 r) {\n        // If value has upper 128 bits set, log2 result is at least 128\n        r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;\n        // If upper 64 bits of 128-bit half set, add 64 to result\n        r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;\n        // If upper 32 bits of 64-bit half set, add 32 to result\n        r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;\n        // If upper 16 bits of 32-bit half set, add 16 to result\n        r |= SafeCast.toUint((x >> r) > 0xffff) << 4;\n        // If upper 8 bits of 16-bit half set, add 8 to result\n        r |= SafeCast.toUint((x >> r) > 0xff) << 3;\n        // If upper 4 bits of 8-bit half set, add 4 to result\n        r |= SafeCast.toUint((x >> r) > 0xf) << 2;\n\n        // Shifts value right by the current result and use it as an index into this lookup table:\n        //\n        // | x (4 bits) |  index  | table[index] = MSB position |\n        // |------------|---------|-----------------------------|\n        // |    0000    |    0    |        table[0] = 0         |\n        // |    0001    |    1    |        table[1] = 0         |\n        // |    0010    |    2    |        table[2] = 1         |\n        // |    0011    |    3    |        table[3] = 1         |\n        // |    0100    |    4    |        table[4] = 2         |\n        // |    0101    |    5    |        table[5] = 2         |\n        // |    0110    |    6    |        table[6] = 2         |\n        // |    0111    |    7    |        table[7] = 2         |\n        // |    1000    |    8    |        table[8] = 3         |\n        // |    1001    |    9    |        table[9] = 3         |\n        // |    1010    |   10    |        table[10] = 3        |\n        // |    1011    |   11    |        table[11] = 3        |\n        // |    1100    |   12    |        table[12] = 3        |\n        // |    1101    |   13    |        table[13] = 3        |\n        // |    1110    |   14    |        table[14] = 3        |\n        // |    1111    |   15    |        table[15] = 3        |\n        //\n        // The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.\n        assembly (\"memory-safe\") {\n            r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 x) internal pure returns (uint256 r) {\n        // If value has upper 128 bits set, log2 result is at least 128\n        r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;\n        // If upper 64 bits of 128-bit half set, add 64 to result\n        r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;\n        // If upper 32 bits of 64-bit half set, add 32 to result\n        r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;\n        // If upper 16 bits of 32-bit half set, add 16 to result\n        r |= SafeCast.toUint((x >> r) > 0xffff) << 4;\n        // Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8\n        return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);\n        }\n    }\n\n    /**\n     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n     */\n    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n        return uint8(rounding) % 2 == 1;\n    }\n}\n"},{"file_path":"src/interfaces/IAccrualLifecycle.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\n/// @title IAccrualLifecycle\n/// @notice Authenticated loan events consumed by the reserve's continuous accounting book.\n/// @dev These methods accept no caller-selected accounting timestamp or interest correction.\ninterface IAccrualLifecycle {\n    /// @notice Supported forward fixed-rate terms, projected from a consumed bridge amendment.\n    struct Terms {\n        uint16 rateBps;\n        uint32 yearSeconds;\n        uint64 nextPaymentDue;\n        uint64 paymentInterval;\n        uint64 maturity;\n    }\n\n    /// @notice Prospective fixed Actual/360 terms for one concurrent cash/PIK facility.\n    struct MixedTerms {\n        uint16 cashRateBps;\n        uint16 pikRateBps;\n        uint32 yearSeconds;\n        uint64 nextPikCapitalization;\n        uint64 pikCapitalizationInterval;\n        uint64 maturity;\n    }\n\n    /// @notice Contractual debt, separately disclosed from the reserve's streamed accounting face.\n    struct Debt {\n        uint256 principal;\n        uint256 interest;\n        uint256 balanceCeiling;\n        uint64 accruedThrough;\n        uint64 nextCapitalization;\n        uint64 maturity;\n        bool pik;\n        bool active;\n        bool known;\n    }\n\n    /// @notice Current unpaid interest separated by its legal settlement leg.\n    /// @dev `mixed` distinguishes a concurrent facility from the equivalent balances on a\n    ///      one-leg note. Unknown or disabled records return the all-zero shape.\n    struct InterestLegs {\n        uint256 cash;\n        uint256 pik;\n        uint64 accruedThrough;\n        bool mixed;\n        bool known;\n    }\n\n    /// @notice Registers the bound waterfall's just-funded, authenticated bridge facility.\n    function registerAccruingLoan(uint256 facilityId) external;\n\n    /// @notice Processes a bounded number of chronological due events; partial progress persists.\n    function checkpointAccrual(uint256 maximum) external returns (uint256 processed, bool fresh);\n\n    /// @notice Transfers one facility's existing virtual receivable into its native face ledger.\n    function postAccruedLoan(uint256 facilityId) external returns (uint256 amount);\n\n    /// @notice Applies the bridge's consumed, authenticated amendment prospectively.\n    function amendAccruingLoan(uint256 facilityId, Terms calldata terms) external;\n\n    /// @notice Applies the bridge's consumed, authenticated two-leg amendment prospectively.\n    function amendMixedAccruingLoan(uint256 facilityId, MixedTerms calldata terms) external;\n\n    /// @notice Aligns and permanently stops the facility before its default declaration snapshot.\n    function stopAccruingLoan(uint256 facilityId) external;\n\n    /// @notice Changes only the bound default manager's growing past-due cohort membership.\n    function setAccrualPastDue(uint256 facilityId, bool marked) external;\n\n    /// @notice Contractual debt through the capped, coherent portfolio frontier, in constant time.\n    function accruedDebt(uint256 facilityId) external view returns (Debt memory);\n\n    /// @notice Current cash-pay and PIK balances through the same coherent frontier, in constant time.\n    function accruedInterestLegs(uint256 facilityId) external view returns (InterestLegs memory);\n\n    /// @notice Additional unposted interest on a class's marked past-due cohort.\n    function accruedPastDue(uint256 classId) external view returns (uint256 amount);\n\n    /// @notice Streamed book face not yet posted for one facility; distinct from canonical interest.\n    function unpostedAccruedLoan(uint256 facilityId) external view returns (uint256 amount);\n}\n\n/// @notice The reserve alone advances already signed PIK capitalization boundaries.\ninterface IAccrualBridge {\n    function setAccruedPaymentDue(uint256 facilityId, uint64 nextDue) external;\n}\n\n/// @notice Narrow notification of a posted receivable already counted in effective exposure.\ninterface IAccrualRegistry {\n    function recordAccruedExposure(uint256 classId, bytes32 borrowerId, bytes32 stateId, uint256 amount) external;\n}\n\n/// @notice Moves already-counted cohort growth into the default manager's recorded risk carrier.\ninterface IAccrualRisk {\n    function onAccrualPosted(uint256 facilityId, uint256 amount) external;\n}\n\n/// @notice The waterfall changes its standing interest fee only prospectively.\ninterface IAccrualFeeConfig {\n    function setAccrualFee(uint16 feeBps, address recipient) external;\n}\n\n/// @notice Constant-time servicing of signed dates with no positive queued accrual work.\ninterface IAccrualServicing {\n    function serviceAccruedLoan(uint256 facilityId) external returns (uint256 capitalized);\n    function accrualLoanScheduled(uint256 facilityId) external view returns (bool);\n}\n\n/// @notice Explicit native loss allocation of an independently derived sub-unit discrepancy.\ninterface IAccrualRounding {\n    /// @notice Monotone unabsorbed contractual rounding loss, never caller-selected debt relief.\n    function roundingLossUnabsorbed() external view returns (uint256);\n\n    /// @notice Controller-only consumption of one exact reserve-owned physical burn permit.\n    /// @dev Returns false outside a rounding continuation; normal loss admission then applies.\n    function consumeAccrualLossBurn(address caller, address from, uint256 amount) external returns (bool);\n}\n\n/// @notice The reserve reduces only a marked contribution whose face it has actually written down.\ninterface IAccrualRoundingRisk {\n    function onAccrualRounding(uint256 facilityId, uint256 amount) external;\n}\n\n/// @notice Registry continuation paired with a reserve-proved native rounding write-down.\ninterface IAccrualRoundingRegistry {\n    function recordAccruedWriteDown(uint256 classId, bytes32 borrowerId, bytes32 stateId, uint256 amount) external;\n}\n\n/// @notice Measured receipt settlement and terminal retirement, separately bound to servicing modules.\ninterface IAccrualReceipts {\n    /// @notice Measures an attested receipt and discharges separately tracked principal and interest.\n    function repayAccruingLoan(uint256 facilityId, address payer, uint256 principal, uint256 interest)\n        external\n        returns (uint256 outstanding);\n\n    /// @notice Releases a fully extinguished, resolved facility's active-book slot after its risk hooks.\n    function retireAccruedLoan(uint256 facilityId) external;\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/access/IAccessControl.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)\n\npragma solidity >=0.8.4;\n\n/**\n * @dev External interface of AccessControl declared to support ERC-165 detection.\n */\ninterface IAccessControl {\n    /**\n     * @dev The `account` is missing a role.\n     */\n    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n    /**\n     * @dev The caller of a function is not the expected one.\n     *\n     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n     */\n    error AccessControlBadConfirmation();\n\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted to signal this.\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).\n     * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `callerConfirmation`.\n     */\n    function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n"},{"file_path":"src/interfaces/ICollateralRegistry.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\n/// @title ICollateralRegistry\n/// @notice Per-vertical collateral-class parameters and book-level concentration\n///         accounting (ADR-0003 as amended: five classes at genesis, one of which is\n///         marked-to-market per ADR-0015).\ninterface ICollateralRegistry {\n    /// @notice How a class's collateral behaves — drives valuation and remedy paths.\n    enum CollateralModel {\n        Receivable, // legal-enforcement remedies (UCC foreclosure, secondary sale)\n        MarkedToMarket // margin-call / liquidation remedies (ADR-0015)\n\n    }\n\n    struct ClassParams {\n        string name;\n        CollateralModel model;\n        bool active;\n        uint16 maxLtvBps; // draw ceiling (initial LTV for MTM classes)\n        uint64 maxMaturity; // seconds from origination\n        uint16 concentrationLimitBps; // max share of total book in this class\n        // ── marked-to-market extension (zero for receivable classes) ──────\n        uint16 marginCallLtvBps; // breach → MarginCalled + cure window\n        uint16 liquidationLtvBps; // breach / cure expiry → LiquidationInitiated\n        uint64 maxMarkAge; // valuation freshness bound (seconds)\n    }\n\n    event ClassSet(uint256 indexed classId);\n    event ExposureRecorded(uint256 indexed classId, bytes32 indexed borrowerId, bytes32 indexed stateId, int256 delta);\n\n    /// @notice Emitted alongside `ExposureRecorded` when the increase came from PIK capitalisation\n    ///         rather than from an origination, so the two are distinguishable in the event stream.\n    /// @dev Origination exposure is a decision somebody made and an admission check passed.\n    ///      Capitalised exposure is arithmetic on a term already agreed. A reader reconciling the\n    ///      book needs to tell them apart, and `ExposureRecorded` alone cannot.\n    event CapitalizedExposureRecorded(\n        uint256 indexed classId, bytes32 indexed borrowerId, bytes32 indexed stateId, uint256 principal\n    );\n    event BorrowerLimitSet(uint16 limitBps);\n    /// @notice Governance set a per-borrower concentration limit overriding the global one.\n    /// @param borrowerId The borrower key.\n    /// @param limitBps The borrower's own max share of the book, in bps.\n    event BorrowerLimitOverrideSet(bytes32 indexed borrowerId, uint16 limitBps);\n    /// @notice Governance removed a per-borrower override; the global limit applies again.\n    /// @param borrowerId The borrower key.\n    event BorrowerLimitOverrideCleared(bytes32 indexed borrowerId);\n    event StateLimitSet(uint16 limitBps);\n    event ConcentrationFloorSet(uint256 floor);\n    /// @notice Governance changed the forward weight of an UNATTESTED past-due mark\n    ///         (OWNER DECISION 2026-08-07).\n    /// @param bps The new weight, in bps of the executable senior charge.\n    event PastDueWeightSet(uint256 bps);\n\n    /// @notice A class crossed FROM within its concentration limit TO above it\n    ///         (AUDIT FIX M-02). This is a book-shrink artefact: an amortising\n    ///         repayment, a default write-down, or the retirement of an unfunded\n    ///         facility removes exposure elsewhere, so an untouched class's SHARE of the\n    ///         remaining book rises without that class growing. Such a decrease can never\n    ///         be blocked (blocking it would let a concentration limit veto a loss being\n    ///         realized, inverting the loss cascade), so the breach is reported, not\n    ///         prevented — and no new exposure may be added to the class while it stands.\n    /// @param classId The class now above its limit.\n    /// @param exposure The class's exposure after the change (18-dec).\n    /// @param totalExposure The whole book's exposure after the change (18-dec).\n    /// @param limitBps The class's configured limit as a share of the book.\n    /// @param bookAboveFloor Whether the whole book is above the bootstrap floor. False\n    ///        means this is ordinary genesis concentration on a book too small for the\n    ///        relative limits to be the operative constraint (the absolute allowance\n    ///        `limitBps * floor / BPS` is); alerting should filter on this rather than\n    ///        treat a first facility at 100% of a tiny book as a risk incident.\n    event ConcentrationDrift(\n        uint256 indexed classId, uint256 exposure, uint256 totalExposure, uint16 limitBps, bool bookAboveFloor\n    );\n\n    /// @notice A class that was above its concentration limit is back within it — because\n    ///         the book grew around it or its own exposure fell (AUDIT FIX M-02).\n    /// @param classId The class now within its limit.\n    /// @param exposure The class's exposure after the change (18-dec).\n    /// @param totalExposure The whole book's exposure after the change (18-dec).\n    /// @param limitBps The class's configured limit as a share of the book.\n    /// @param bookAboveFloor Whether the whole book is above the bootstrap floor.\n    event ConcentrationHealed(\n        uint256 indexed classId, uint256 exposure, uint256 totalExposure, uint16 limitBps, bool bookAboveFloor\n    );\n\n    /// @notice A borrower crossed FROM within its concentration limit TO above it\n    ///         (AUDIT FIX M-02). Emitted for the borrower a write touches and for any id\n    ///         passed to `syncConcentrationBreaches`; the borrower key set is unbounded and\n    ///         not enumerable on-chain, but is fully recoverable from `ExposureRecorded`.\n    event BorrowerConcentrationDrift(\n        bytes32 indexed borrowerId, uint256 exposure, uint256 totalExposure, uint16 limitBps, bool bookAboveFloor\n    );\n\n    /// @notice A borrower that was above its concentration limit is back within it.\n    event BorrowerConcentrationHealed(\n        bytes32 indexed borrowerId, uint256 exposure, uint256 totalExposure, uint16 limitBps, bool bookAboveFloor\n    );\n\n    /// @notice A US state crossed FROM within its concentration limit TO above it.\n    event StateConcentrationDrift(\n        bytes32 indexed stateId, uint256 exposure, uint256 totalExposure, uint16 limitBps, bool bookAboveFloor\n    );\n\n    /// @notice A US state that was above its concentration limit is back within it.\n    event StateConcentrationHealed(\n        bytes32 indexed stateId, uint256 exposure, uint256 totalExposure, uint16 limitBps, bool bookAboveFloor\n    );\n\n    error Registry_UnknownClass(uint256 classId);\n    error Registry_ClassInactive(uint256 classId);\n    error Registry_BadParams();\n    /// @notice A configured class cannot change between receivable and marked-to-market\n    ///         accounting. The model selects materially different valuation and remedy\n    ///         paths and is fixed for the lifetime of a launch class.\n    error Registry_ModelImmutable(uint256 classId);\n    /// @notice The requested principal would push the book past the range in which the\n    ///         concentration arithmetic is provably overflow-free. Fails loudly with a\n    ///         decodable error rather than an arithmetic panic.\n    error Registry_PrincipalTooLarge();\n    /// @notice `setPastDueWeight` was asked for a weight of zero (which re-opens H-5/D5-03 by\n    ///         disabling the only permissionless senior protection on receivables) or a weight of\n    ///         `Config.BPS` or more (which restores the defect the weight exists to fix: an\n    ///         unattested mark carrying the same forward weight as an attested declared default).\n    ///         OWNER DECISION 2026-08-07. DO NOT DELETE EITHER BOUND.\n    /// @param bps The rejected weight.\n    error Registry_InvalidPastDueWeight(uint256 bps);\n    error Registry_ConcentrationExceeded(uint256 classId, uint256 wouldBe, uint256 limit);\n    error Registry_BorrowerConcentrationExceeded(bytes32 borrowerId, uint256 wouldBe, uint256 limit);\n    error Registry_StateConcentrationExceeded(bytes32 stateId, uint256 wouldBe, uint256 limit);\n    error Registry_ExposureUnderflow();\n\n    /// @notice Sets/updates a collateral class. Timelocked governance only.\n    /// @dev A class's collateral model is immutable after its first configuration.\n    function setClass(uint256 classId, ClassParams calldata p) external;\n\n    /// @notice Sets a per-borrower concentration limit overriding the global borrower limit.\n    function setBorrowerLimitOverride(bytes32 borrowerId, uint16 limitBps) external;\n\n    /// @notice Clears a per-borrower concentration limit override.\n    function clearBorrowerLimitOverride(bytes32 borrowerId) external;\n\n    /// @notice Class parameters (reverts for unknown classes).\n    function classParams(uint256 classId) external view returns (ClassParams memory);\n\n    /// @notice Reverts unless adding `principal` for (`classId`,`borrowerId`,`stateId`)\n    ///         respects every concentration limit (class, borrower, state). View-only;\n    ///         `recordExposure` performs the same checks at write time.\n    function checkConcentration(uint256 classId, bytes32 borrowerId, bytes32 stateId, uint256 principal)\n        external\n        view;\n\n    /// @notice Records an exposure increase (origination). Only CREDIT_ROLE (the\n    ///         collateral/credit layer). Enforces all concentration limits.\n    function recordExposureIncrease(uint256 classId, bytes32 borrowerId, bytes32 stateId, uint256 principal) external;\n\n    /// @notice Records an exposure increase that came from PIK interest CAPITALISATION rather than\n    ///         from an origination. Only CREDIT_ROLE. Books the exposure and reports every\n    ///         concentration breach exactly as the origination path does, but does NOT revert on\n    ///         one.\n    ///\n    /// @dev WHY THIS IS NOT A HOLE IN THE CONCENTRATION LIMIT, and why it is not optional.\n    ///      A concentration limit governs ADMISSION: it decides whether the book takes on a new\n    ///      risk somebody chose to take. Compounding interest is not that. Nobody elects it, the\n    ///      borrower cannot decline it, no capital moves, and the obligation was priced at\n    ///      origination when the limit was checked. Routing it through `recordExposureIncrease`\n    ///      meant a PIK book grew into its own limit with no adversary and then FROZE, and because\n    ///      `ClaimBridge.nextPaymentDue` only advances inside `WaterfallEngine.capitalizePik`, the\n    ///      freeze turned a borrower performing exactly as contracted into a permissionlessly\n    ///      markable past-due facility, and through `DefaultManager.pastDueExposure` into pending\n    ///      senior impairment. The protocol's own refusal became the credit event.\n    ///\n    ///      WHAT IS PRESERVED. The class must be known; the overflow bound that keeps the\n    ///      concentration arithmetic safe still applies; the exposure is booked in full, which is\n    ///      what keeps the facility WRITEABLE OFF (`realizeLoss` pairs its write-down with\n    ///      `recordExposureDecrease`, which reverts `Registry_ExposureUnderflow` if exposure lags);\n    ///      and every breach flag and drift event fires. Governance sees the limit crossed. The\n    ///      limit keeps its whole observation function and loses only its ability to brick a\n    ///      performing borrower.\n    ///\n    ///      `recordExposureDecrease` already carries this exact reasoning for the same reason:\n    ///      \"Reporting only - never a revert path.\"\n    ///\n    ///      WHAT THIS ADDS TO `CREDIT_ROLE`, stated because an auditor will ask. The role could\n    ///      already move exposure in both directions: `recordExposureIncrease` upward subject to\n    ///      the limits, and `recordExposureDecrease` downward with no check at all. This adds an\n    ///      upward path that skips the limit, so a CREDIT_ROLE holder can now inflate a class past\n    ///      its concentration ceiling. That moves NO VALUE - exposure is a reporting and\n    ///      write-off-accounting quantity, not a balance - and it moves the book in the\n    ///      CONSERVATIVE direction, making it read as more concentrated than it is. The role\n    ///      remains a protocol-modules-only grant for the reasons recorded on\n    ///      `recordExposureDecrease`, and this function does not change that requirement.\n    ///\n    ///      IF FOREST ROAD WANTS CAPITALISATION TO HARD-STOP AT THE LIMIT INSTEAD, that is a\n    ///      one-line change back to `recordExposureIncrease` in `WaterfallEngine.capitalizePik`,\n    ///      and it reinstates the denial of service knowingly rather than by accident.\n    function recordCapitalizedExposure(uint256 classId, bytes32 borrowerId, bytes32 stateId, uint256 principal)\n        external;\n\n    /// @notice Records an exposure decrease (repayment/writedown). Only CREDIT_ROLE.\n    function recordExposureDecrease(uint256 classId, bytes32 borrowerId, bytes32 stateId, uint256 principal) external;\n\n    /// @notice Current book exposure per class / borrower / state (18-dec).\n    function classExposure(uint256 classId) external view returns (uint256);\n    function borrowerExposure(bytes32 borrowerId) external view returns (uint256);\n    function stateExposure(bytes32 stateId) external view returns (uint256);\n    function totalBookExposure() external view returns (uint256);\n\n    /// @notice A class's current share of the whole book, in bps (0 on an empty book).\n    function classConcentrationBps(uint256 classId) external view returns (uint256);\n\n    /// @notice Whether a dimension's CURRENT share of the book exceeds its configured\n    ///         limit — the standing disclosure fact, floor-independent (AUDIT FIX M-02).\n    function isOverConcentrated(uint256 classId, bytes32 borrowerId, bytes32 stateId)\n        external\n        view\n        returns (bool classOver, bool borrowerOver, bool stateOver);\n\n    /// @notice The forward weight, in bps, that an UNATTESTED permissionless past-due mark\n    ///         (`DefaultManager.markPastDue`) carries in the conservative redemption NAV,\n    ///         relative to an ATTESTED declared default (OWNER DECISION 2026-08-07).\n    /// @dev Governed credit-risk policy, so it lives with the advance rates and concentration\n    ///      limits rather than in DefaultManager (which is EIP-170 constrained and contended).\n    ///      Never returns zero: an unset slot reads `Config.DEFAULT_PAST_DUE_WEIGHT_BPS`.\n    /// @return bps The effective weight, strictly between 0 and `Config.BPS`.\n    function pastDueWeightBps() external view returns (uint256 bps);\n\n    /// @notice Applies the governed unattested-past-due weight to an executable senior charge.\n    /// @dev Called by `DefaultManager.pendingSeniorImpairment` on the past-due cohort's charge\n    ///      AFTER the executable bound has been applied. Rounds UP (over-mark is the safe\n    ///      direction). OWNER DECISION 2026-08-07 — DO NOT turn this into a pass-through.\n    /// @param amount The executable senior charge attributable to the past-due cohort.\n    /// @return weighted The discounted charge that enters the conservative redemption NAV.\n    function weightedPastDueImpairment(uint256 amount) external view returns (uint256 weighted);\n\n    /// @notice The TOTAL conservative senior mark: the attested cohort at full weight plus the\n    ///         unattested past-due cohort, clamped to executable capacity and ramp-weighted.\n    /// @dev OWNER DECISION 2026-08-07. Clamps `pastDueSenior` to the senior absorption capacity\n    ///      `realizeLoss` could actually reach today (`vaultAssets` less the attested cohort's prior\n    ///      claim), THEN applies the governed weight, which itself ramps from\n    ///      `pastDueWeightBps()` back to `Config.BPS` over one `Config.DEFAULT_REDEEM_COOLDOWN`.\n    ///      Both the CLAMP-BEFORE-WEIGHT order and the ramp's expiry are load-bearing; see the\n    ///      implementation NatSpec.\n    /// @param pastDueSenior The past-due cohort's post-junior senior residual.\n    /// @param residual The TOTAL post-junior senior residual (both cohorts), unweighted.\n    /// @param vault The `sUSDfr` vault whose `totalAssets()` is layer 3's hard ceiling in\n    ///        `realizeLoss`. Read here rather than passed in as a number so the governed weight and\n    ///        the ceiling it is applied to stay in one timelocked module; see the implementation\n    ///        NatSpec, which also carries the recursion warning.\n    /// @param anchor `DefaultManager.pastDueReliefAnchor`. ZERO (unset) fails SAFE to full weight.\n    /// @return mark The total conservative senior impairment entering the redemption NAV.\n    function conservativeSeniorMark(uint256 pastDueSenior, uint256 residual, address vault, uint256 anchor)\n        external\n        view\n        returns (uint256 mark);\n\n    /// @notice The forward weight, in bps, an unattested past-due mark carries after `elapsed`\n    ///         seconds of its relief ramp (OWNER DECISION 2026-08-07).\n    /// @dev Ramps linearly from `pastDueWeightBps()` at `elapsed == 0` to `Config.BPS` at\n    ///      `elapsed >= Config.DEFAULT_REDEEM_COOLDOWN`, and stays at `Config.BPS` thereafter.\n    ///      A read-only convenience for operations and reference models; the mark itself does NOT\n    ///      route through it (see the implementation NatSpec for why).\n    /// @param elapsed Seconds since `DefaultManager.pastDueReliefAnchor`.\n    /// @return bps The effective weight, in `[pastDueWeightBps(), Config.BPS]`.\n    function pastDueRampWeightBps(uint256 elapsed) external view returns (uint256 bps);\n\n    /// @notice Governance sets the forward weight of an unattested past-due mark.\n    /// @dev Rejects 0 (re-opens H-5/D5-03) and `Config.BPS` or more (restores the defect).\n    /// @param bps The new weight, strictly between 0 and `Config.BPS`.\n    function setPastDueWeight(uint256 bps) external;\n\n    /// @notice Bitmap of classes currently above their limit; bit `classId - 1` set.\n    /// @dev Recomputed from the book on every call — never served from a cached slot, so it\n    ///      cannot report a clean book in the window after an implementation upgrade.\n    function overConcentratedClasses() external view returns (uint256 bitmap);\n\n    /// @notice The borrower concentration limit actually in force for `borrowerId`.\n    /// @dev The global limit assumes a vertical has many borrowers. A SINGLE-BORROWER vertical\n    ///      (Digital Assets, ADR-0015) makes the class and borrower dimensions measure the same\n    ///      exposure, so governance may set a per-borrower override. Every admission, breach\n    ///      and headroom read routes through this same number.\n    /// @param borrowerId The borrower key.\n    /// @return limitBps The effective limit in bps.\n    /// @return overridden True when a per-borrower override is set.\n    function effectiveBorrowerLimitBps(bytes32 borrowerId) external view returns (uint16 limitBps, bool overridden);\n\n    /// @notice Whether each supplied borrower currently holds more than the per-borrower limit\n    ///         as a share of the book — its OWN limit where one is overridden. The key set is\n    ///         unbounded on-chain; recover it from the `ExposureRecorded` stream and pass it in.\n    function overConcentratedBorrowers(bytes32[] calldata borrowerIds) external view returns (bool[] memory over);\n\n    /// @notice Whether each supplied state currently holds more than the per-state limit as\n    ///         a share of the book. Zero ids read false.\n    function overConcentratedStates(bytes32[] calldata stateIds) external view returns (bool[] memory over);\n\n    /// @notice Recomputes and events every concentration transition for all five classes\n    ///         plus the supplied borrower/state ids. Permissionless: it moves no value and\n    ///         only publishes facts the views already expose, so anyone (a keeper, a risk\n    ///         desk, the upgrade transaction itself) can announce a standing breach without\n    ///         waiting for the next origination or repayment.\n    function syncConcentrationBreaches(bytes32[] calldata borrowerIds, bytes32[] calldata stateIds) external;\n\n    /// @notice The largest `principal` that `checkConcentration` would admit right now for\n    ///         (`classId`,`borrowerId`,`stateId`) — the binding minimum across the class,\n    ///         borrower and state dimensions. Zero for an unknown or inactive class.\n    function concentrationHeadroom(uint256 classId, bytes32 borrowerId, bytes32 stateId)\n        external\n        view\n        returns (uint256);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/Panic.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Helper library for emitting standardized panic codes.\n *\n * ```solidity\n * contract Example {\n *      using Panic for uint256;\n *\n *      // Use any of the declared internal constants\n *      function foo() { Panic.GENERIC.panic(); }\n *\n *      // Alternatively\n *      function foo() { Panic.panic(Panic.GENERIC); }\n * }\n * ```\n *\n * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].\n *\n * _Available since v5.1._\n */\n// slither-disable-next-line unused-state\nlibrary Panic {\n    /// @dev generic / unspecified error\n    uint256 internal constant GENERIC = 0x00;\n    /// @dev used by the assert() builtin\n    uint256 internal constant ASSERT = 0x01;\n    /// @dev arithmetic underflow or overflow\n    uint256 internal constant UNDER_OVERFLOW = 0x11;\n    /// @dev division or modulo by zero\n    uint256 internal constant DIVISION_BY_ZERO = 0x12;\n    /// @dev enum conversion error\n    uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;\n    /// @dev invalid encoding in storage\n    uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;\n    /// @dev empty array pop\n    uint256 internal constant EMPTY_ARRAY_POP = 0x31;\n    /// @dev array out of bounds access\n    uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;\n    /// @dev resource error (too large allocation or too large array)\n    uint256 internal constant RESOURCE_ERROR = 0x41;\n    /// @dev calling invalid internal function\n    uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;\n\n    /// @dev Reverts with a panic code. Recommended to use with\n    /// the internal constants with predefined codes.\n    function panic(uint256 code) internal pure {\n        assembly (\"memory-safe\") {\n            mstore(0x00, 0x4e487b71)\n            mstore(0x20, code)\n            revert(0x1c, 0x24)\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Utils.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (proxy/ERC1967/ERC1967Utils.sol)\n\npragma solidity ^0.8.21;\n\nimport {IBeacon} from \"../beacon/IBeacon.sol\";\nimport {IERC1967} from \"../../interfaces/IERC1967.sol\";\nimport {Address} from \"../../utils/Address.sol\";\nimport {StorageSlot} from \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This library provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.\n */\nlibrary ERC1967Utils {\n    /**\n     * @dev Storage slot with the address of the current implementation.\n     * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1.\n     */\n    // solhint-disable-next-line private-vars-leading-underscore\n    bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n    /**\n     * @dev The `implementation` of the proxy is invalid.\n     */\n    error ERC1967InvalidImplementation(address implementation);\n\n    /**\n     * @dev The `admin` of the proxy is invalid.\n     */\n    error ERC1967InvalidAdmin(address admin);\n\n    /**\n     * @dev The `beacon` of the proxy is invalid.\n     */\n    error ERC1967InvalidBeacon(address beacon);\n\n    /**\n     * @dev An upgrade function sees `msg.value > 0` that may be lost.\n     */\n    error ERC1967NonPayable();\n\n    /**\n     * @dev Returns the current implementation address.\n     */\n    function getImplementation() internal view returns (address) {\n        return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the ERC-1967 implementation slot.\n     */\n    function _setImplementation(address newImplementation) private {\n        if (newImplementation.code.length == 0) {\n            revert ERC1967InvalidImplementation(newImplementation);\n        }\n        StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;\n    }\n\n    /**\n     * @dev Performs implementation upgrade with additional setup call if data is nonempty.\n     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected\n     * to avoid stuck value in the contract.\n     *\n     * Emits an {IERC1967-Upgraded} event.\n     */\n    function upgradeToAndCall(address newImplementation, bytes memory data) internal {\n        _setImplementation(newImplementation);\n        emit IERC1967.Upgraded(newImplementation);\n\n        if (data.length > 0) {\n            Address.functionDelegateCall(newImplementation, data);\n        } else {\n            _checkNonPayable();\n        }\n    }\n\n    /**\n     * @dev Storage slot with the admin of the contract.\n     * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1.\n     */\n    // solhint-disable-next-line private-vars-leading-underscore\n    bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n    /**\n     * @dev Returns the current admin.\n     *\n     * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using\n     * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n     * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n     */\n    function getAdmin() internal view returns (address) {\n        return StorageSlot.getAddressSlot(ADMIN_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the ERC-1967 admin slot.\n     */\n    function _setAdmin(address newAdmin) private {\n        if (newAdmin == address(0)) {\n            revert ERC1967InvalidAdmin(address(0));\n        }\n        StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;\n    }\n\n    /**\n     * @dev Changes the admin of the proxy.\n     *\n     * Emits an {IERC1967-AdminChanged} event.\n     */\n    function changeAdmin(address newAdmin) internal {\n        emit IERC1967.AdminChanged(getAdmin(), newAdmin);\n        _setAdmin(newAdmin);\n    }\n\n    /**\n     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n     * This is the keccak-256 hash of \"eip1967.proxy.beacon\" subtracted by 1.\n     */\n    // solhint-disable-next-line private-vars-leading-underscore\n    bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n    /**\n     * @dev Returns the current beacon.\n     */\n    function getBeacon() internal view returns (address) {\n        return StorageSlot.getAddressSlot(BEACON_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new beacon in the ERC-1967 beacon slot.\n     */\n    function _setBeacon(address newBeacon) private {\n        if (newBeacon.code.length == 0) {\n            revert ERC1967InvalidBeacon(newBeacon);\n        }\n\n        StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;\n\n        address beaconImplementation = IBeacon(newBeacon).implementation();\n        if (beaconImplementation.code.length == 0) {\n            revert ERC1967InvalidImplementation(beaconImplementation);\n        }\n    }\n\n    /**\n     * @dev Change the beacon and trigger a setup call if data is nonempty.\n     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected\n     * to avoid stuck value in the contract.\n     *\n     * Emits an {IERC1967-BeaconUpgraded} event.\n     *\n     * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since\n     * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for\n     * efficiency.\n     */\n    function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {\n        _setBeacon(newBeacon);\n        emit IERC1967.BeaconUpgraded(newBeacon);\n\n        if (data.length > 0) {\n            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n        } else {\n            _checkNonPayable();\n        }\n    }\n\n    /**\n     * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract\n     * if an upgrade doesn't perform an initialization call.\n     */\n    function _checkNonPayable() private {\n        if (msg.value > 0) {\n            revert ERC1967NonPayable();\n        }\n    }\n}\n"},{"file_path":"src/interfaces/IReserveManager.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\n/// @title IReserveManager\n/// @notice Mainnet-v1 treasury for canonical USDC and deployed facility principal.\n/// @dev USD values use 18 decimals. USDC amounts use the token's native 6 decimals.\ninterface IReserveManager {\n    /// @notice Recognition or an opening import makes a return to legacy accounting unsafe.\n    error ReserveManager_LegacyRollbackUnsafe();\n\n    /// @notice Refuses a legacy-code rollback once accrual activation or migration has started.\n    /// @dev Read-only execution guard for a governance batch, not authority to upgrade.\n    function requireLegacyRollbackSafe() external view;\n\n    /// @notice Canonical USDC was pulled into recorded idle custody.\n    event USDCDeposited(address indexed from, uint256 requested, uint256 credited);\n    /// @notice Canonical USDC was released from recorded idle custody.\n    event USDCReleased(address indexed to, uint256 amount);\n    /// @notice A permissionless observation compared recorded and live USDC custody.\n    event IdleUSDCObserved(uint256 recorded, uint256 live, uint256 shortfall);\n    /// @notice An adjudicated custody loss reduced recorded idle backing.\n    event IdleUSDCWrittenDown(uint256 amount, uint256 remaining);\n    /// @notice Returned USDC was credited against one arm's written-down recovery capacity.\n    event RecoveredIdleUSDCCredited(\n        uint256 indexed armId, uint256 nativeUnits, uint256 value, bytes32 indexed evidenceHash\n    );\n    /// @notice A custody loss reduced backing and fixed the supply reduction the cascade must absorb.\n    event ReserveLossRecognized(\n        uint256 indexed incidentId, uint256 backingReduction, uint256 surplusAbsorbed, uint256 supplyReductionRequired\n    );\n    /// @notice The complete surplus-to-senior allocation of one recognized custody loss.\n    event ReserveLossAllocated(\n        uint256 indexed incidentId,\n        uint256 backingReduction,\n        uint256 surplusAbsorbed,\n        uint256 curatorAbsorbed,\n        uint256 backstopCovered,\n        uint256 seniorBurned,\n        uint256 residualDeficit\n    );\n    /// @notice The controller used for supply, backing, and loss-burn checks changed.\n    event LossControllerSet(address indexed previousController, address indexed newController);\n    /// @notice The ordered custody-cascade and governance timing modules were wired.\n    event ReserveLossModulesSet(\n        address indexed curator, address indexed backstop, address indexed vault, address governor, address timelock\n    );\n    /// @notice A Guardian created a persistent reserve-loss interlock and evidence commitment.\n    event ReserveLossArmed(uint256 indexed armId, uint256 indexed incidentId, bytes32 evidenceHash);\n    /// @notice Governance cancelled an unused arm and disabled future Guardian arms.\n    event ReserveLossArmCancelled(uint256 indexed armId, bytes32 indexed evidenceHash);\n    /// @notice Governance cancelled a custody false alarm while retaining all credit marks.\n    event UnratifiedReserveLossArmCancelled(\n        uint256 indexed armId, bytes32 indexed evidenceHash, uint256 retainedPrincipalImpairment\n    );\n    /// @notice A previously ratified arm must use the incident settlement path.\n\n    error ReserveManager_ArmAlreadyRatified(uint256 armId);\n\n    /// @notice Governance closed the arm-bound incident and disabled future Guardian arms.\n    event ReserveLossArmFinalized(uint256 indexed armId, uint256 indexed incidentId, bytes32 indexed evidenceHash);\n    /// @notice Governance ratified and executed the current objective custody shortfall.\n    event ReserveLossRatified(\n        uint256 indexed armId,\n        uint256 indexed incidentId,\n        uint256 approvedMaxLoss,\n        uint256 actualLoss,\n        bytes32 evidenceHash\n    );\n    /// @notice Governance enabled or disabled creation of new Guardian reserve-loss arms.\n    event GuardianReserveLossArmsEnabled(bool enabled);\n    /// @notice A custody-loss incident entered the active register under its bound arm.\n    event ReserveLossIncidentOpened(uint256 indexed incidentId, uint256 indexed armId, bytes32 evidenceHash);\n    /// @notice The active custody-loss incident left the register.\n    event ReserveLossIncidentClosed(uint256 indexed incidentId);\n    /// @notice A cascade changed the latched unabsorbed reserve deficit.\n    event ReserveDeficitUpdated(uint256 indexed incidentId, uint256 previousDeficit, uint256 currentDeficit);\n    /// @notice Governance cleared a cured reserve-deficit latch with supporting evidence.\n    event ReserveDeficitResolved(uint256 previousDeficit, bytes32 evidenceHash);\n    /// @notice Idle USDC became deployed principal for a facility.\n    event PrincipalDeployed(uint256 indexed facilityId, uint256 amount);\n    /// @notice A retained origination fee became additional facility principal.\n    event FeeCapitalized(uint256 indexed facilityId, uint256 amount);\n\n    /// @notice Contractually accrued PIK interest joined a facility's deployed principal.\n    /// @dev No cash moved and, unlike `FeeCapitalized`, none was retained either.\n    /// @param facilityId The facility.\n    /// @param amount 18-decimal value capitalised.\n    /// @param deployedAfter The facility's deployed principal after the act.\n    event PikCapitalized(uint256 indexed facilityId, uint256 amount, uint256 deployedAfter);\n    /// @notice A cash receipt increased idle custody and reduced the stated principal leg.\n    event PaymentReceived(\n        uint256 indexed facilityId, address indexed payer, uint256 usdcAmount, uint256 principalReturned\n    );\n    /// @notice Realized facility principal was removed from backing.\n    event PrincipalWrittenDown(uint256 indexed facilityId, uint256 amount);\n    /// @notice Governance added an evidence-backed conservative facility impairment.\n    event PrincipalImpairmentRecognized(\n        uint256 indexed facilityId,\n        uint256 amount,\n        uint256 facilityImpairment,\n        uint256 totalImpairment,\n        uint256 backingAfter,\n        bytes32 evidenceHash\n    );\n    /// @notice Governance released part of an evidence-backed conservative facility impairment.\n    event PrincipalImpairmentReleased(\n        uint256 indexed facilityId,\n        uint256 amount,\n        uint256 facilityImpairment,\n        uint256 totalImpairment,\n        bytes32 evidenceHash\n    );\n    /// @notice A principal write-down consumed the corresponding previously recognized impairment.\n    event PrincipalImpairmentRealized(\n        uint256 indexed facilityId, uint256 amount, uint256 facilityImpairment, uint256 totalImpairment\n    );\n    /// @notice The retained compatibility loss-absorber binding changed.\n    event LossAbsorberSet(address indexed previousAbsorber, address indexed newAbsorber);\n    /// @notice A funder supplied new canonical USDC backing without minting claims.\n    event Recapitalized(\n        address indexed funder, uint256 units, uint256 credited, uint256 backingAfter, uint256 deficitOutstanding\n    );\n    /// @notice A senior-exit junior draw was added to the historical prepayment ledger.\n    event ExitPrepaymentRecorded(uint256 amount, uint256 outstanding);\n    /// @notice A facility loss consumed part of the historical exit-prepayment ledger.\n    event ExitPrepaymentConsumed(uint256 indexed facilityId, uint256 consumed, uint256 outstanding);\n    /// @notice A custody loss consumed the surplus backing part of an exit prepayment.\n    event ExitPrepaymentAbsorbedByCustody(uint256 indexed incidentId, uint256 consumed, uint256 outstanding);\n    /// @notice Governance permanently bound the borrower-payout policy used before USDC deployment.\n    event BorrowerPayoutRegistrySet(address indexed registry);\n\n    /// @notice Requested USDC value exceeds recorded idle value.\n    error ReserveManager_InsufficientIdleValue(uint256 requestedValue, uint256 idleValue);\n    /// @notice Requested principal reduction exceeds the facility's live deployed principal.\n    error ReserveManager_InsufficientDeployedPrincipal(uint256 facilityId, uint256 requested, uint256 deployed);\n    /// @notice A value-moving call supplied a zero amount.\n    error ReserveManager_ZeroAmount();\n    /// @notice A required account or module address is zero.\n    error ReserveManager_ZeroAddress();\n    /// @notice The caller is not an authorised controller or credit depositor.\n    error ReserveManager_NotDepositor(address caller);\n    /// @notice A pull expected canonical USDC but received no value.\n    error ReserveManager_NoValueReceived();\n    /// @notice The token balance delta differed from the requested USDC transfer.\n    error ReserveManager_UnexpectedUSDCReceipt(uint256 expected, uint256 received);\n    /// @notice A legacy idle write-down exceeds recorded idle value.\n    error ReserveManager_WriteDownExceedsIdle(uint256 amount, uint256 idle);\n    /// @notice A USDC release or deployment attempted to target the ReserveManager itself.\n    error ReserveManager_SelfDeployment();\n    /// @notice An 18-decimal value cannot be represented exactly in native USDC units.\n    error ReserveManager_ValueNotUSDCExact(uint256 value);\n    /// @notice The configured custody token does not use canonical USDC's six decimals.\n    error ReserveManager_InvalidUSDCDecimals(uint8 decimals);\n    /// @notice A payment allocated more principal than the USDC value actually received.\n    error ReserveManager_PrincipalExceedsPayment(uint256 principal, uint256 paymentValue);\n    /// @notice A proposed curator, backstop, vault, or absorber fails its binding contract.\n    error ReserveManager_InvalidLossAbsorber(address absorber);\n    /// @notice A proposed controller fails its module and reserve binding contract.\n    error ReserveManager_InvalidLossController(address controller);\n    /// @notice A loss layer's reported burn differs from the observed USDfr supply reduction.\n    error ReserveManager_LossAbsorberContractViolated(uint256 backingReduction, uint256 supplyBurned);\n    /// @notice Reported cascade allocation does not reconcile to the recognized loss.\n    error ReserveManager_LossAllocationMismatch(\n        uint256 expectedSurplus, uint256 reportedSurplus, uint256 expectedAccounted, uint256 reportedAccounted\n    );\n    /// @notice The terminal live supply/backing deficit differs from the cascade calculation.\n    error ReserveManager_PostLossDeficitMismatch(uint256 expectedDeficit, uint256 observedDeficit);\n    /// @notice A custody incident id has already been consumed.\n    error ReserveManager_IncidentAlreadyUsed(uint256 incidentId);\n    /// @notice A new arm or incident cannot replace the currently active incident.\n    error ReserveManager_IncidentAlreadyActive(uint256 incidentId);\n    /// @notice A terminal action requires an active custody incident.\n    error ReserveManager_NoActiveIncident();\n    /// @notice The supplied custody incident does not match the active incident.\n    error ReserveManager_IncidentMismatch(uint256 expected, uint256 supplied);\n    /// @notice The caller lacks the reserve-administration authority required for the live loss path.\n    error ReserveManager_ReserveLossCallerNotAdmin(address caller);\n    /// @notice A reserve-loss allocation used an id outside the custody-event namespace.\n    error ReserveManager_InvalidReserveLossIncident(uint256 incidentId);\n    /// @notice A cascade was requested without a recognized supply reduction.\n    error ReserveManager_NoRecognizedReserveLoss();\n    /// @notice Finalization was attempted while recognized loss remains unallocated.\n    error ReserveManager_RecognizedLossOutstanding(uint256 amount);\n    /// @notice Finalization was attempted while live USDC custody remains short.\n    error ReserveManager_LiveShortfallExists(uint256 nativeUnits);\n    /// @notice Finalization was attempted while supply still exceeds backing.\n    error ReserveManager_DeficitStillExists(uint256 recordedDeficit, uint256 observedDeficit);\n    /// @notice Creation of new Guardian reserve-loss arms is disabled.\n    error ReserveManager_GuardianArmsDisabled();\n    /// @notice A new arm cannot replace the currently active arm.\n    error ReserveManager_ArmAlreadyActive(uint256 armId);\n    /// @notice An arm-bound action requires an active arm.\n    error ReserveManager_NoActiveArm();\n    /// @notice The supplied arm id does not match the active arm.\n    error ReserveManager_ArmMismatch(uint256 expected, uint256 supplied);\n    /// @notice Ratification evidence does not match the Guardian's armed commitment.\n    error ReserveManager_ArmEvidenceMismatch(bytes32 expected, bytes32 supplied);\n    /// @notice The monotonic arm id space is exhausted.\n    error ReserveManager_ArmIdExhausted();\n    /// @notice Ratification found that the objective custody shortfall was already cured.\n    error ReserveManager_ShortfallCured();\n    /// @notice The live custody loss exceeds governance's approved maximum.\n    error ReserveManager_LossExceedsApproval(uint256 actualLoss, uint256 approvedMaxLoss);\n    /// @notice No physically returned USDC is available for the supplied arm.\n    error ReserveManager_NoRecoveredUSDC(uint256 armId);\n    /// @notice Finalization found returned USDC that has not yet been credited.\n    error ReserveManager_RecoveredUSDCNotCredited(uint256 armId, uint256 nativeUnits);\n    /// @notice The superseded arbitrary idle-write-down entry is permanently disabled.\n    error ReserveManager_LegacyPathDisabled();\n    /// @notice Cancellation would release an interlock while a loss condition remains live.\n    error ReserveManager_InterlockReleaseForbidden();\n    /// @notice Loss-module rebinding is forbidden while an arm, incident, shortfall, or deficit is live.\n    error ReserveManager_ModuleRebindForbidden();\n    /// @notice The proposed governor and timelock do not expose one coherent live timing path.\n    error ReserveManager_InvalidGovernanceTiming(address governor, address timelock);\n    /// @notice An evidence-backed transition supplied the zero evidence hash.\n    error ReserveManager_ZeroEvidenceHash();\n    /// @notice A conservative impairment would exceed the facility's remaining face principal.\n    error ReserveManager_ImpairmentExceedsFace(uint256 facilityId, uint256 requested, uint256 remainingFace);\n    /// @notice An impairment release exceeds the amount currently recognized for the facility.\n    error ReserveManager_ImpairmentReleaseExceedsRecognized(uint256 facilityId, uint256 requested, uint256 recognized);\n    /// @notice The caller is not the retained compatibility loss absorber.\n    error ReserveManager_NotLossAbsorber(address caller);\n    /// @notice Recorded idle USDC exceeds live custody, so a protected out-door is closed.\n    error ReserveManager_IdleCustodyShortfall(uint256 recordedUnits, uint256 liveUnits);\n    /// @notice A legacy incident nonce is zero or enters the reserved custody namespace.\n    error ReserveManager_InvalidIncidentNonce(uint256 incidentNonce);\n    /// @notice Deficit resolution was requested without a recorded deficit.\n    error ReserveManager_NoReserveDeficit();\n    /// @notice An incident close requires its recorded deficit to be resolved first.\n    error ReserveManager_DeficitResolutionRequired(uint256 recordedDeficit);\n    /// @notice The borrower-payout policy was already bound and cannot be replaced.\n    error BorrowerPayout_RegistryAlreadySet(address registry);\n    /// @notice A proposed borrower-payout policy has no compatible code.\n    error BorrowerPayout_InvalidRegistry(address registry);\n    /// @notice Loan proceeds may not be directed to this address.\n    error BorrowerPayout_RecipientNotAllowed(address recipient);\n\n    /// @notice Pulls exact canonical USDC from `from` into recorded idle custody.\n    function depositUSDC(address from, uint256 amount) external returns (uint256 credited);\n    /// @notice Releases recorded idle USDC through the controller-only redemption path.\n    function releaseUSDC(address to, uint256 amount) external;\n\n    /// @notice Permanently binds the timelock-managed borrower-payout registry.\n    function setBorrowerPayoutRegistry(address registry) external;\n\n    /// @notice The permanent borrower-payout policy, or zero before the required binding.\n    function borrowerPayoutRegistry() external view returns (address);\n\n    /// @notice Permissionlessly checkpoints the objective live-vs-recorded custody shortfall.\n    /// @dev Observation never changes backing and never moves junior or senior capital.\n    /// @return shortfall Native six-decimal USDC units missing from custody.\n    function reconcileIdleUSDC() external returns (uint256 shortfall);\n\n    /// @notice Permissionless live-vs-recorded custody observation; never changes accounting.\n    function observeIdleUSDC() external view returns (uint256 recorded, uint256 live, uint256 shortfall);\n\n    /// @notice Native USDC units by which recorded idle custody exceeds the live token balance.\n    function idleCustodyShortfall() external view returns (uint256);\n    /// @notice Recorded backing net of any physically observable idle-custody shortfall.\n    function recognizedBackingValue() external view returns (uint256);\n    /// @notice Whether an arm, incident, recognized loss, deficit, or live shortfall locks exits.\n    function custodyLossUnabsorbed() external view returns (bool);\n\n    /// @notice Wires the controller used for direct supply/backing and loss-burn checks.\n    function setLossController(address controller) external;\n    /// @notice Wires the retained compatibility absorber after verifying its reserve binding.\n    function setLossAbsorber(address absorber) external;\n\n    /// @notice Legacy incident controls retained as non-credit compatibility surfaces while\n    ///         new custody accounting uses the arm-bound ratification path.\n    function openReserveLossIncident(uint256 incidentNonce, bytes32 evidenceHash)\n        external\n        returns (uint256 incidentId);\n    /// @notice Closes the exact active legacy incident once no deficit remains.\n    function closeReserveLossIncident(uint256 incidentId) external;\n    /// @notice Clears a cured legacy reserve-deficit latch with supporting evidence.\n    function resolveReserveDeficit(bytes32 evidenceHash) external;\n    /// @notice Canonical USDC held above the amount recorded as idle custody.\n    function unrecordedUSDC() external view returns (uint256);\n\n    /// @notice Wires the ordered custody cascade and its live governance timing sources.\n    function setReserveLossModules(address curator, address backstop, address vault, address governor, address timelock)\n        external;\n\n    /// @notice Guardian-only persistent interlock created before an amount-bearing proposal.\n    /// @return armId Monotonic internal id consumed only by an explicit governance terminal action.\n    /// @return incidentId Structurally bound upper-half custody event id.\n    function armReserveLossFreeze(bytes32 evidenceHash) external returns (uint256 armId, uint256 incidentId);\n\n    /// @notice Governance consumes an unused arm only when the objective shortfall is zero and\n    ///         no adjudicated loss, incident or deficit exists; future Guardian arms stay disabled.\n    function cancelAndDisable(uint256 expectedArmId, bytes32 evidenceHash) external;\n\n    /// @notice Cancels an unratified custody false alarm and disables further guardian arms.\n    /// @dev Requires accounted custody and no unsettled custody incident or reserve deficit.\n    ///      Independent credit impairment and exit prepayments remain unchanged.\n    /// @param expectedArmId Exact active arm being cancelled.\n    /// @param evidenceHash Nonzero commitment to the governance resolution evidence.\n    function cancelUnratifiedArm(uint256 expectedArmId, bytes32 evidenceHash) external;\n\n    /// @notice Governance kill switch for repeated Guardian arms.\n    function setGuardianReserveLossArmsEnabled(bool enabled) external;\n\n    /// @notice Governance ratifies and atomically absorbs the live objective shortfall, bounded\n    ///         by the amount approved in the proposal. Every tranche under an arm reuses its id\n    ///         and must supply the Guardian's exact armed evidence commitment.\n    function ratifyAndOpen(uint256 expectedArmId, bytes32 evidenceHash, uint256 approvedMaxLoss)\n        external\n        returns (uint256 incidentId, uint256 actualLoss);\n\n    /// @notice Credits physically returned canonical USDC without minting USDfr, capped by the\n    ///         amount previously written down under `armId`. May execute after incident closure.\n    function creditRecoveredIdleUSDC(uint256 armId, bytes32 evidenceHash) external returns (uint256 credited);\n\n    /// @notice Atomically resolves a cured deficit, closes the arm-bound incident and disables\n    ///         future Guardian arms. It cannot release a shortfall or uncredited returned USDC.\n    function finalizeAndDisable(uint256 expectedArmId, bytes32 evidenceHash) external;\n\n    /// @notice Pulls new canonical USDC backing without minting USDfr claims.\n    function recapitalize(uint256 amount) external returns (uint256 credited);\n\n    /// @notice Controller used for supply, backing, and loss-burn verification.\n    function lossController() external view returns (address);\n    /// @notice Ordered curator, backstop, vault, governor, and timelock bindings.\n    function reserveLossModules()\n        external\n        view\n        returns (address curator, address backstop, address vault, address governor, address timelock);\n    /// @notice Active custody incident id and its evidence commitment.\n    function activeReserveLossIncident() external view returns (uint256 incidentId, bytes32 evidenceHash);\n    /// @notice Whether a custody incident id has already entered the durable register.\n    function reserveLossIncidentUsed(uint256 incidentId) external view returns (bool);\n    /// @notice Latched portion of adjudicated custody losses not absorbed by any capital layer.\n    function reserveDeficit() external view returns (uint256);\n    /// @notice Current recognized backing reduction and pending cascade requirement.\n    function recognizedReserveLoss()\n        external\n        view\n        returns (uint256 backingReduction, uint256 surplusAbsorbed, uint256 supplyReductionRequired);\n    /// @notice Active arm identity, derived incident, armed evidence, and future-arm switch.\n    function reserveLossArm()\n        external\n        view\n        returns (uint256 armId, uint256 incidentId, bytes32 evidenceHash, bool armsEnabled);\n    /// @notice Native USDC recovery capacity created by write-downs under one arm.\n    function reserveLossRecoveryCapacity(uint256 armId) external view returns (uint256 nativeUnits);\n    /// @notice Retained compatibility absorber bound to this reserve.\n    function lossAbsorber() external view returns (address);\n    /// @notice Historical junior prepayment still available for impairment release.\n    function exitPrepaidAbsorption() external view returns (uint256);\n    /// @notice Records a senior-exit junior draw in the compatibility prepayment ledger.\n    function recordExitPrepayment(uint256 amount) external;\n    /// @notice Consumes prepayment only against recognized impairment for a facility loss.\n    function consumeExitPrepayment(uint256 facilityId, uint256 loss) external returns (uint256 used);\n\n    /// @notice Shared fail-closed interlock consumed by curator withdrawals and queue settlement.\n    function reserveLossExitsLocked() external view returns (bool);\n\n    /// @notice Backwards-compatible semantic alias used by CuratorModule.\n    function curatorWithdrawalsLocked() external view returns (bool);\n\n    /// @notice Converts exact recorded idle USDC into deployed facility principal.\n    function recordDeployment(uint256 facilityId, address to, uint256 usdcAmount) external;\n    /// @notice Adds retained origination-fee cash as facility principal without moving custody.\n    function recordFeeCapitalization(uint256 facilityId, uint256 amount) external;\n\n    /// @notice Capitalises accrued PIK interest into a facility's deployed principal. No cash moves.\n    /// @dev CREDIT_ROLE, and in practice `WaterfallEngine.capitalizePik` alone, which carries every\n    ///      bound. See `ReserveManager.recordPikCapitalization` for why there is no idle check.\n    /// @param facilityId The facility.\n    /// @param amount 18-decimal value to capitalise, exact on the USDC grid.\n    function recordPikCapitalization(uint256 facilityId, uint256 amount) external;\n\n    /// @notice Atomically pulls exact USDC and accounts the principal leg.\n    function recordPayment(uint256 facilityId, address payer, uint256 usdcAmount, uint256 principal)\n        external\n        returns (uint256 receivedValue);\n\n    /// @notice Removes realized facility principal and consumes its corresponding impairment.\n    function recordPrincipalWritedown(uint256 facilityId, uint256 amount) external;\n\n    /// @notice Records an evidence-backed conservative mark without moving face principal or\n    ///         allocating the loss between capital layers.\n    function recognizePrincipalImpairment(uint256 facilityId, uint256 amount, bytes32 evidenceHash) external;\n\n    /// @notice Reverses a conservative mark, bounded by the amount previously recognized.\n    function releasePrincipalImpairment(uint256 facilityId, uint256 amount, bytes32 evidenceHash) external;\n\n    /// @notice Recorded idle custody expressed as 18-decimal USDfr value.\n    function idleReserve() external view returns (uint256);\n    /// @notice Recorded idle custody in native six-decimal USDC units.\n    function idleUSDC() external view returns (uint256);\n    /// @notice Aggregate deployed facility principal before conservative impairments.\n    function deployedPrincipal() external view returns (uint256);\n    /// @notice Aggregate evidence-backed conservative principal impairment.\n    function totalPrincipalImpairment() external view returns (uint256);\n    /// @notice Evidence-backed conservative impairment recorded for one facility.\n    function principalImpairmentOf(uint256 facilityId) external view returns (uint256);\n    /// @notice Recorded idle plus deployed principal, net of conservative impairments.\n    function totalBackingValue() external view returns (uint256);\n    /// @notice Outstanding receivable face deployed to one facility.\n    /// @dev Continuous accrual includes earned but unreceived cash and PIK interest.\n    function deployedTo(uint256 facilityId) external view returns (uint256);\n    /// @notice Canonical six-decimal USDC token held by the reserve.\n    function usdc() external view returns (address);\n    /// @notice Converts native six-decimal USDC units to 18-decimal protocol value.\n    function normalizeUSDC(uint256 amount) external pure returns (uint256);\n    /// @notice Converts exact 18-decimal protocol value to native USDC units.\n    function denormalizeUSDC(uint256 value) external pure returns (uint256);\n}\n"},{"file_path":"src/interfaces/IAccrualExposure.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\nimport {IContinuousAccrual} from \"./IContinuousAccrual.sol\";\n\n/// @title IAccrualExposure\n/// @notice Reserve-local unposted earned claims used by the collateral concentration book.\n/// @dev Values share the continuous Book's capped frontier and never scan facilities. A source\n///      must implement the complete continuous-accrual identity, snapshot and admission surface.\ninterface IAccrualExposure is IContinuousAccrual {\n    /// @notice Returns unposted normalized-18-decimal exposure for one aggregate identity.\n    /// @param kind Total=0, class=1, borrower=2, state=3.\n    /// @param identity Total uses zero; class uses bytes32(classId); borrower/state use their\n    ///      existing identity keys. A zero state represents no state tag and returns zero.\n    function accrualExposure(uint8 kind, bytes32 identity) external view returns (uint256);\n\n    /// @notice Additional future funded face already reserved beyond current effective exposure.\n    /// @dev Origination must preserve this numeric room, including while pending unfunded claims\n    ///      consume registry exposure. Concentration ratios continue to use current exposure.\n    function accrualReservedExposure() external view returns (uint256);\n\n    /// @notice Refuses an overlapping source operation without requiring its loan clock current.\n    /// @dev Repayment/loss decreases and governed recovery must not depend on keeper freshness.\n    function requireAccrualIdle() external view;\n}\n\n/// @title IAccrualExposureRegistry\n/// @notice Narrow registry continuation for physical posting of already earned exposure.\ninterface IAccrualExposureRegistry {\n    /// @notice Permanently binds the governed reserve that supplies virtual exposure.\n    function setAccrualReserve(address reserve) external;\n\n    /// @notice The permanent reserve, or zero while continuous exposure is disabled.\n    function accrualReserve() external view returns (address);\n\n    /// @notice Posts an already consumed reserve-local virtual claim into stored registry face.\n    /// @dev Only the bound reserve may call. It must first consume identical Book posting and\n    ///      write its native reserve face in the same protected operation. This is a neutral\n    ///      reclassification, bypassing origination limits while retaining the numeric cap.\n    function recordAccruedExposure(uint256 classId, bytes32 borrowerId, bytes32 stateId, uint256 amount) external;\n}\n"},{"file_path":"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.22;\n\nimport {IERC1822Proxiable} from \"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\";\nimport {ERC1967Utils} from \"@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol\";\nimport {Initializable} from \"./Initializable.sol\";\n\n/**\n * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an\n * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.\n *\n * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is\n * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing\n * `UUPSUpgradeable` with a custom implementation of upgrades.\n *\n * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.\n */\nabstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n    address private immutable __self = address(this);\n\n    /**\n     * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`\n     * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,\n     * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.\n     * If the getter returns `\"5.0.0\"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must\n     * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function\n     * during an upgrade.\n     */\n    string public constant UPGRADE_INTERFACE_VERSION = \"5.0.0\";\n\n    /**\n     * @dev The call is from an unauthorized context.\n     */\n    error UUPSUnauthorizedCallContext();\n\n    /**\n     * @dev The storage `slot` is unsupported as a UUID.\n     */\n    error UUPSUnsupportedProxiableUUID(bytes32 slot);\n\n    /**\n     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is\n     * a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case\n     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a\n     * function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to\n     * fail.\n     */\n    modifier onlyProxy() {\n        _checkProxy();\n        _;\n    }\n\n    /**\n     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be\n     * callable on the implementing contract but not through proxies.\n     */\n    modifier notDelegated() {\n        _checkNotDelegated();\n        _;\n    }\n\n    function __UUPSUpgradeable_init() internal onlyInitializing {\n    }\n\n    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the\n     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.\n     *\n     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.\n     */\n    function proxiableUUID() external view virtual notDelegated returns (bytes32) {\n        return ERC1967Utils.IMPLEMENTATION_SLOT;\n    }\n\n    /**\n     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call\n     * encoded in `data`.\n     *\n     * Calls {_authorizeUpgrade}.\n     *\n     * Emits an {Upgraded} event.\n     *\n     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall\n     */\n    function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {\n        _authorizeUpgrade(newImplementation);\n        _upgradeToAndCallUUPS(newImplementation, data);\n    }\n\n    /**\n     * @dev Reverts if the execution is not performed via delegatecall or the execution\n     * context is not of a proxy with an ERC-1967 compliant implementation pointing to self.\n     */\n    function _checkProxy() internal view virtual {\n        if (\n            address(this) == __self || // Must be called through delegatecall\n            ERC1967Utils.getImplementation() != __self // Must be called through an active proxy\n        ) {\n            revert UUPSUnauthorizedCallContext();\n        }\n    }\n\n    /**\n     * @dev Reverts if the execution is performed via delegatecall.\n     * See {notDelegated}.\n     */\n    function _checkNotDelegated() internal view virtual {\n        if (address(this) != __self) {\n            // Must not be called through delegatecall\n            revert UUPSUnauthorizedCallContext();\n        }\n    }\n\n    /**\n     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n     * {upgradeToAndCall}.\n     *\n     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.\n     *\n     * ```solidity\n     * function _authorizeUpgrade(address) internal onlyOwner {}\n     * ```\n     */\n    function _authorizeUpgrade(address newImplementation) internal virtual;\n\n    /**\n     * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.\n     *\n     * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value\n     * is expected to be the implementation slot in ERC-1967.\n     *\n     * Emits an {IERC1967-Upgraded} event.\n     */\n    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {\n        try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n            if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {\n                revert UUPSUnsupportedProxiableUUID(slot);\n            }\n            ERC1967Utils.upgradeToAndCall(newImplementation, data);\n        } catch {\n            // The implementation is not UUPS\n            revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)\n\npragma solidity >=0.4.16;\n\n/**\n * @dev Interface of the ERC-165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[ERC].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/token/ERC721/utils/ERC721Utils.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/utils/ERC721Utils.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721Receiver} from \"../IERC721Receiver.sol\";\nimport {IERC721Errors} from \"../../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Library that provide common ERC-721 utility functions.\n *\n * See https://eips.ethereum.org/EIPS/eip-721[ERC-721].\n *\n * _Available since v5.1._\n */\nlibrary ERC721Utils {\n    /**\n     * @dev Performs an acceptance check for the provided `operator` by calling {IERC721Receiver-onERC721Received}\n     * on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).\n     *\n     * The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).\n     * Otherwise, the recipient must implement {IERC721Receiver-onERC721Received} and return the acceptance magic value to accept\n     * the transfer.\n     */\n    function checkOnERC721Received(\n        address operator,\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes memory data\n    ) internal {\n        if (to.code.length > 0) {\n            try IERC721Receiver(to).onERC721Received(operator, from, tokenId, data) returns (bytes4 retval) {\n                if (retval != IERC721Receiver.onERC721Received.selector) {\n                    // Token rejected\n                    revert IERC721Errors.ERC721InvalidReceiver(to);\n                }\n            } catch (bytes memory reason) {\n                if (reason.length == 0) {\n                    // non-IERC721Receiver implementer\n                    revert IERC721Errors.ERC721InvalidReceiver(to);\n                } else {\n                    assembly (\"memory-safe\") {\n                        revert(add(reason, 0x20), mload(reason))\n                    }\n                }\n            }\n        }\n    }\n}\n"},{"file_path":"src/interfaces/IContinuousAccrual.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\n/// @title IContinuousAccrual\n/// @notice Reserve-owned accounting and exact delivery of previously accrued interest.\n/// @dev Separate from the legacy reserve interface so activation is explicit. Amounts are\n///      normalized to 18 decimals. Delivery changes physical balances, never economic ownership.\ninterface IContinuousAccrual {\n    /// @notice Modules bound to one independently backed chain instance.\n    /// @dev LAYOUT-FROZEN: embedded or array storage; changing its width shifts later live fields.\n    struct Modules {\n        address token;\n        address controller;\n        address vault;\n        address waterfall;\n        address bridge;\n        address registry;\n        address defaultManager;\n    }\n\n    /// @notice Constant-time accounting, capped at the first unprocessed schedule boundary.\n    /// @dev LAYOUT-FROZEN: embedded or array storage; changing its width shifts later live fields.\n    struct Snapshot {\n        uint256 gross;\n        uint256 unposted;\n        uint256 unissued;\n        uint256 seniorUnissued;\n        uint256 feeUnissued;\n        address feeRecipient;\n        uint64 accruedThrough;\n        bool enabled;\n        bool fresh;\n    }\n\n    /// @notice Vault-computed prices and permission for a neutral physical delivery.\n    /// @dev entryAssets includes any unvested assets; assets is the ordinary share-price base.\n    /// @dev LAYOUT-FROZEN: embedded or array storage; changing its width shifts later live fields.\n    struct PricingState {\n        uint256 assets;\n        uint256 entryAssets;\n        uint256 redemptionAssets;\n        uint256 performanceAssets;\n        uint256 feeAdjustedShares;\n        bool materializationAllowed;\n    }\n\n    /// @notice One immutable, same-transaction permit and coherent public price snapshot.\n    /// @dev Unselected amounts are zero. A zero/default inactive record grants no authority.\n    /// @dev LAYOUT-FROZEN: embedded or array storage; changing its width shifts later live fields.\n    struct Delivery {\n        uint256 nonce;\n        uint256 senior;\n        uint256 fee;\n        uint256 effectiveSupply;\n        uint256 backing;\n        uint256 recognizedBacking;\n        PricingState pricing;\n        address controller;\n        address vault;\n        address feeRecipient;\n        uint64 accruedThrough;\n        uint8 legs;\n        bool active;\n    }\n\n    /// @notice Reads the configured module identities, including before activation.\n    function accrualModules() external view returns (Modules memory);\n\n    /// @notice Reads recognized income and its outstanding physical posting/issuance.\n    function accrualSnapshot() external view returns (Snapshot memory);\n\n    /// @notice Reads the current delivery permit, or an inactive default record.\n    function accrualDelivery() external view returns (Delivery memory);\n\n    /// @notice Refuses a price-sensitive write at an unresolved accrual boundary or operation.\n    function requireAccrualFresh() external view;\n\n    /// @notice Delivers selected existing claims: senior=1, fee=2, both=3.\n    /// @dev No amount, destination, timestamp or fee rate is supplied by the caller.\n    function materializeAccrued(uint8 legs) external returns (uint256 senior, uint256 fee);\n}\n\n/// @notice Token continuation accepting only the bound reserve's current exact permit.\ninterface IAccrualToken {\n    /// @notice The immutable-once-configured accounting reserve, or zero before binding.\n    function accrualReserve() external view returns (address);\n\n    /// @notice Mints the selected legs of one unused, active delivery permit.\n    function mintAccrued(uint256 nonce) external;\n}\n\n/// @notice Controller continuation, callable only by its configured reserve.\ninterface IAccrualController {\n    /// @notice Relays one exact reserve-owned delivery permit to the token.\n    function mintAccrued(uint256 nonce) external;\n}\n\n/// @notice Vault views needed to admit a neutral delivery without a guarded write callback.\ninterface IAccrualVault {\n    /// @notice The immutable-once-configured accounting reserve, or zero before binding.\n    function accrualReserve() external view returns (address);\n\n    /// @notice Supplies a coherent price snapshot and current delivery admission state.\n    function accrualPricingState() external view returns (IContinuousAccrual.PricingState memory);\n}\n"},{"file_path":"src/libraries/BridgeMixedInterestLib.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\nimport {IAttestationOracle} from \"../interfaces/IAttestationOracle.sol\";\nimport {ICollateralRegistry} from \"../interfaces/ICollateralRegistry.sol\";\nimport {IContinuousAccrual} from \"../interfaces/IContinuousAccrual.sol\";\nimport {IAccrualLifecycle} from \"../interfaces/IAccrualLifecycle.sol\";\nimport {IComplianceRegistry} from \"../interfaces/IComplianceRegistry.sol\";\n\n/// @title BridgeMixedInterestLib\n/// @notice Signed metadata and monotone cash/PIK clocks for one-facility mixed-interest notes.\n/// @dev Public methods execute by delegatecall in ClaimBridge's context. Authority, class checks,\n///      attestation consumption and reentrancy protection remain in ClaimBridge. This library owns\n///      an independent ERC-7201 namespace so no historical bridge field moves.\nlibrary BridgeMixedInterestLib {\n    bytes32 internal constant FEATURE_VERSION = keccak256(\"forestroad.mixed-interest.v1\");\n    bytes32 private constant ORIGINATION_DOMAIN = keccak256(\"forestroad.mixed-interest.origination.v1\");\n    bytes32 private constant AMENDMENT_DOMAIN = keccak256(\"forestroad.mixed-interest.amendment.v1\");\n\n    /// @notice The two authenticated rates and servicing clocks.\n    /// @dev LAYOUT-FROZEN: stored as a mapping value and embedded in PendingAmendment; changing\n    ///      its width or field order would shift live proxy storage.\n    struct InterestLegTerms {\n        uint16 cashRateBps;\n        uint16 pikRateBps;\n        uint64 cashPaymentInterval;\n        uint64 nextCashPaymentDue;\n        uint64 pikCapitalizationInterval;\n        uint64 nextPikCapitalization;\n    }\n\n    /// @dev ABI-identical mirror of ClaimBridge.OriginationTerms. Enums encode as uint8.\n    struct OriginationTerms {\n        uint256 classId;\n        bytes32 borrowerId;\n        bytes32 stateId;\n        uint256 principal;\n        uint16 ltvBps;\n        uint16 interestRateBps;\n        uint64 maturity;\n        address fundingRecipient;\n        uint64 paymentInterval;\n        uint64 nextPaymentDue;\n        uint8 rateType;\n        uint8 dayCountConvention;\n        bool renewable;\n        bytes32 paymentScheduleHash;\n        bytes32 rateIndexRef;\n        bytes32 renewalTermsHash;\n        bytes32 offchainRef;\n        bool pik;\n    }\n\n    /// @dev ABI-identical mirror of ClaimBridge.Amendment. Enums encode as uint8.\n    struct Amendment {\n        uint16 interestRateBps;\n        uint64 maturity;\n        uint64 paymentInterval;\n        uint64 nextPaymentDue;\n        uint8 rateType;\n        uint8 dayCountConvention;\n        bool renewable;\n        bytes32 paymentScheduleHash;\n        bytes32 rateIndexRef;\n        bytes32 renewalTermsHash;\n    }\n\n    /// @dev Storage-identical mirror of ClaimBridge.Facility. Enums encode in one byte.\n    struct Facility {\n        uint256 classId;\n        bytes32 borrowerId;\n        bytes32 stateId;\n        uint256 principal;\n        uint16 ltvBps;\n        uint16 interestRateBps;\n        uint64 maturity;\n        address fundingRecipient;\n        uint64 paymentInterval;\n        uint64 nextPaymentDue;\n        uint8 rateType;\n        uint8 dayCountConvention;\n        bool renewable;\n        bytes32 paymentScheduleHash;\n        bytes32 rateIndexRef;\n        bytes32 renewalTermsHash;\n        bytes32 offchainRef;\n        uint8 loanState;\n        bool pik;\n    }\n\n    /// @dev Storage-identical mirror of ClaimBridge.BridgeStorage.\n    struct BridgeStorage {\n        ICollateralRegistry registry;\n        IAttestationOracle oracle;\n        uint256 nextId;\n        mapping(uint256 tokenId => Facility) facilities;\n        mapping(uint256 classId => uint256) requiredMintAttestations;\n        address accrualReserve;\n    }\n\n    /// @custom:storage-location erc7201:forestroad.storage.ClaimBridgeMixedInterest\n    struct State {\n        mapping(uint256 facilityId => InterestLegTerms) terms;\n        mapping(uint256 facilityId => bytes32) commitment;\n        mapping(uint256 facilityId => bytes32) originationCommonHash;\n        mapping(uint256 facilityId => PendingAmendment) pendingAmendment;\n        bool enabled;\n        IComplianceRegistry borrowerPayoutRegistry;\n        // A cancelled preparation is rejected history, even when an originator later presents\n        // byte-identical terms at the still-current next id. The generation domain makes every\n        // post-cancellation commitment fresh, so the prior attester quorum cannot be replayed.\n        mapping(uint256 facilityId => uint256) originationGeneration;\n    }\n\n    struct PendingAmendment {\n        InterestLegTerms terms;\n        bytes32 commonHash;\n        bytes32 amendmentId;\n        bytes32 attestationHash;\n    }\n\n    bytes32 private constant MIXED_STORAGE_LOCATION = 0x5b29875874efdde9f2b0d1556dcca4e06c98ca7e47c1bf35a515d9037c1efb00;\n    bytes32 private constant BRIDGE_SLOT = 0xc9c2da543a2a10e4b712709fb6548fb2c0c97cecbac3457453966d18f1663f00;\n\n    uint8 private constant _ACTIVE = 1;\n    uint8 private constant _AMORTIZING = 2;\n    uint8 private constant _FIXED = 0;\n    uint8 private constant _ACTUAL_360 = 0;\n    uint8 private constant _THIRTY_360 = 2;\n    uint16 private constant _MAX_INTEREST_RATE_BPS = 10_000;\n\n    error MixedInterest_NotEnabled();\n    error MixedInterest_AlreadyEnabled();\n    error MixedInterest_InvalidTerms();\n    error MixedInterest_AlreadyConfigured(uint256 facilityId);\n    error MixedInterest_NotConfigured(uint256 facilityId);\n    /// @notice A signed one-shot amendment must be applied or revoked before staging its replacement.\n    error MixedInterest_UnconsumedAmendment(uint256 facilityId, bytes32 payload);\n    error Bridge_BadFacility();\n    error Bridge_UnknownToken(uint256 tokenId);\n    error Bridge_InvalidTransition(uint256 tokenId, uint8 from, uint8 to);\n    error Bridge_LegacyPikScheduleRequiresMigration(uint256 tokenId);\n    error Bridge_TermsAmendmentNotAttested(uint256 tokenId);\n    error Bridge_AccrualUnsupportedTerms(uint256 tokenId);\n    error Bridge_MixedInterestUnavailable();\n    error Bridge_AccrualReserveOnly(address caller);\n    error Bridge_AccrualDueManaged(uint256 tokenId);\n    error BorrowerPayout_RegistryAlreadySet(address registry);\n    error BorrowerPayout_InvalidRegistry(address registry);\n    error BorrowerPayout_RecipientNotAllowed(address recipient);\n\n    event BorrowerPayoutRegistrySet(address indexed registry);\n\n    event MixedInterestEnabled(bytes32 indexed version);\n    /// @notice Exact leg metadata staged for an origination (`actionId == 0`) or amendment.\n    /// @dev A later Originated/TermsAmended event carrying `termsHash` makes the staged record live;\n    ///      cancellation or replacement leaves it as rejected history. This keeps the mixed-leg\n    ///      register reconstructable from logs without trusting transaction calldata archives.\n    event MixedInterestTermsStaged(\n        uint256 indexed facilityId,\n        bytes32 indexed actionId,\n        bytes32 indexed termsHash,\n        uint16 cashRateBps,\n        uint16 pikRateBps,\n        uint64 cashPaymentInterval,\n        uint64 nextCashPaymentDue,\n        uint64 pikCapitalizationInterval,\n        uint64 nextPikCapitalization\n    );\n    event MixedInterestLegDueSet(uint256 indexed facilityId, uint8 indexed leg, uint64 previousDue, uint64 nextDue);\n    event NextPaymentDueSet(uint256 indexed tokenId, uint64 previousDue, uint64 nextDue);\n    event TermsAmended(uint256 indexed tokenId, bytes32 indexed amendmentId, bytes32 termsHash);\n\n    function enable() public {\n        State storage s = _state();\n        if (s.enabled) revert MixedInterest_AlreadyEnabled();\n        s.enabled = true;\n        emit MixedInterestEnabled(FEATURE_VERSION);\n    }\n\n    function enabled() public view returns (bool) {\n        return _state().enabled;\n    }\n\n    function bindBorrowerPayoutRegistry(address registry_) public returns (address bound) {\n        State storage s = _state();\n        address current = address(s.borrowerPayoutRegistry);\n        if (current != address(0)) revert BorrowerPayout_RegistryAlreadySet(current);\n        if (!_isBorrowerPayoutRegistry(registry_)) revert BorrowerPayout_InvalidRegistry(registry_);\n        s.borrowerPayoutRegistry = IComplianceRegistry(registry_);\n        emit BorrowerPayoutRegistrySet(registry_);\n        return registry_;\n    }\n\n    function borrowerPayoutRegistry() public view returns (address) {\n        return address(_state().borrowerPayoutRegistry);\n    }\n\n    function requireFundingRecipientAllowed(address recipient) public view returns (bool allowed) {\n        IComplianceRegistry policy = _state().borrowerPayoutRegistry;\n        if (address(policy) == address(0) || !policy.isFundingRecipientAllowed(recipient)) {\n            revert BorrowerPayout_RecipientNotAllowed(recipient);\n        }\n        return true;\n    }\n\n    function configured(uint256 id) public view returns (bool) {\n        return _state().terms[id].cashRateBps != 0;\n    }\n\n    function terms(uint256 id) public view returns (InterestLegTerms memory result) {\n        result = _state().terms[id];\n        if (result.cashRateBps == 0) revert MixedInterest_NotConfigured(id);\n    }\n\n    function commitment(uint256 id) public view returns (bytes32) {\n        return _state().commitment[id];\n    }\n\n    /// @notice Validates and stores a mixed origination before the host's safe-mint callback.\n    function stageOrigination(uint256 id, bytes calldata encoded) public returns (bytes32 termsHash) {\n        State storage s = _state();\n        if (!s.enabled) revert MixedInterest_NotEnabled();\n        if (s.terms[id].cashRateBps != 0) revert MixedInterest_AlreadyConfigured(id);\n        (OriginationTerms memory common, InterestLegTerms memory legs) =\n            abi.decode(encoded, (OriginationTerms, InterestLegTerms));\n        _validateOrigination(common, legs);\n        termsHash = _originationHash(s.originationGeneration[id], common, legs);\n        s.terms[id] = legs;\n        s.commitment[id] = termsHash;\n        s.originationCommonHash[id] = keccak256(abi.encode(common));\n        emit MixedInterestTermsStaged(\n            id,\n            bytes32(0),\n            termsHash,\n            legs.cashRateBps,\n            legs.pikRateBps,\n            legs.cashPaymentInterval,\n            legs.nextCashPaymentDue,\n            legs.pikCapitalizationInterval,\n            legs.nextPikCapitalization\n        );\n    }\n\n    /// @notice Confirms the ordinary origination calldata is the common half staged for this id.\n    function preparedOrigination(uint256 id, bytes calldata encodedCommon) public view returns (bytes32 termsHash) {\n        State storage s = _state();\n        termsHash = s.commitment[id];\n        if (\n            termsHash == bytes32(0) || s.originationCommonHash[id] == bytes32(0)\n                || s.originationCommonHash[id] != keccak256(encodedCommon)\n        ) revert MixedInterest_InvalidTerms();\n    }\n\n    function clearPreparedOrigination(uint256 id) public {\n        State storage s = _state();\n        if (s.originationCommonHash[id] == bytes32(0)) revert MixedInterest_NotConfigured(id);\n        delete s.terms[id];\n        delete s.commitment[id];\n        delete s.originationCommonHash[id];\n        ++s.originationGeneration[id];\n    }\n\n    /// @notice Validates and stages prospective mixed terms without changing the live clocks.\n    function stageAmendment(uint256 id, bytes32 amendmentId, bytes calldata encoded)\n        public\n        returns (bytes32 attestationHash)\n    {\n        State storage s = _state();\n        if (!s.enabled) revert MixedInterest_NotEnabled();\n        if (s.terms[id].cashRateBps == 0) revert MixedInterest_NotConfigured(id);\n        (bytes32 standing,, bool satisfied) =\n            _bridgeStorage().oracle.latestPayload(id, IAttestationOracle.AttestationKind.TermsAmended);\n        if (satisfied) revert MixedInterest_UnconsumedAmendment(id, standing);\n        (Amendment memory common, InterestLegTerms memory legs) = abi.decode(encoded, (Amendment, InterestLegTerms));\n        _validateAmendment(common, legs);\n        attestationHash = keccak256(abi.encode(AMENDMENT_DOMAIN, amendmentId, id, common, legs));\n        s.pendingAmendment[id] = PendingAmendment({\n            terms: legs,\n            commonHash: keccak256(abi.encode(common)),\n            amendmentId: amendmentId,\n            attestationHash: attestationHash\n        });\n        emit MixedInterestTermsStaged(\n            id,\n            amendmentId,\n            attestationHash,\n            legs.cashRateBps,\n            legs.pikRateBps,\n            legs.cashPaymentInterval,\n            legs.nextCashPaymentDue,\n            legs.pikCapitalizationInterval,\n            legs.nextPikCapitalization\n        );\n    }\n\n    /// @notice Applies either the historical one-leg amendment or a prepared two-leg amendment.\n    /// @dev The host supplies role, pause, reentrancy and source-freshness gates. This linked\n    ///      implementation preserves the original bridge namespace and emits from the proxy.\n    function amendTerms(uint256 id, bytes32 amendmentId, bytes calldata encoded) public {\n        Amendment memory a = abi.decode(encoded, (Amendment));\n        BridgeStorage storage bridge = _bridgeStorage();\n        if (id == 0 || id >= bridge.nextId) revert Bridge_UnknownToken(id);\n        Facility storage facility = bridge.facilities[id];\n        if (facility.loanState != _ACTIVE && facility.loanState != _AMORTIZING) revert Bridge_BadFacility();\n        bool mixed = _state().terms[id].cashRateBps != 0;\n        ICollateralRegistry.ClassParams memory classTerms = bridge.registry.classParams(facility.classId);\n        _validateCommonAmendment(facility, a, amendmentId, classTerms.maxMaturity, mixed);\n\n        bool continuous =\n            bridge.accrualReserve != address(0) && IContinuousAccrual(bridge.accrualReserve).accrualSnapshot().enabled;\n        if (continuous) _requireAccrualTerms(id, facility.pik, a.rateType, a.dayCountConvention);\n        if (\n            !continuous && facility.pik\n                && (a.paymentInterval != facility.paymentInterval || a.nextPaymentDue != facility.nextPaymentDue)\n        ) revert Bridge_LegacyPikScheduleRequiresMigration(id);\n\n        bytes32 expected;\n        InterestLegTerms memory legs;\n        if (mixed) (expected, legs) = _preparedAmendment(id, amendmentId, encoded);\n        else expected = keccak256(abi.encode(amendmentId, id, a));\n        (bytes32 payload,, bool ok) = bridge.oracle.latestPayload(id, IAttestationOracle.AttestationKind.TermsAmended);\n        if (!ok || payload != expected) revert Bridge_TermsAmendmentNotAttested(id);\n        bridge.oracle.consume(id, IAttestationOracle.AttestationKind.TermsAmended);\n\n        _checkpointAmendment(bridge.accrualReserve, id, amendmentId, a, continuous, mixed, legs);\n        _writeAmendment(facility, a);\n        emit TermsAmended(id, amendmentId, mixed ? expected : _creditTermsHash(facility));\n    }\n\n    /// @notice Hash for a facility's first preparation, before any cancellation history.\n    /// @dev After cancellation, use the hash returned by `stageOrigination`; its generation is\n    ///      deliberately private to the bridge so callers cannot mistake a stale preview for the\n    ///      commitment that attesters must sign.\n    function originationHash(bytes calldata encoded) public pure returns (bytes32 termsHash) {\n        (OriginationTerms memory common, InterestLegTerms memory legs) =\n            abi.decode(encoded, (OriginationTerms, InterestLegTerms));\n        return _originationHash(0, common, legs);\n    }\n\n    function amendmentHash(uint256 id, bytes32 amendmentId, bytes calldata encoded)\n        public\n        pure\n        returns (bytes32 termsHash)\n    {\n        (Amendment memory common, InterestLegTerms memory legs) = abi.decode(encoded, (Amendment, InterestLegTerms));\n        return keccak256(abi.encode(AMENDMENT_DOMAIN, amendmentId, id, common, legs));\n    }\n\n    /// @notice Advances the cash clock while preserving the aggregate earliest-due bridge field.\n    /// @dev The host supplies CREDIT_ROLE, reentrancy and source-idle gates.\n    function setCashDue(uint256 id, uint64 nextDue) public {\n        BridgeStorage storage bridge = _bridgeStorage();\n        Facility storage facility = _liveFacility(bridge, id);\n        if (facility.loanState != _ACTIVE && facility.loanState != _AMORTIZING) {\n            revert Bridge_InvalidTransition(id, facility.loanState, facility.loanState);\n        }\n        if (_state().terms[id].cashRateBps != 0) {\n            (uint64 previousAggregate, uint64 nextAggregate) = _setCashDue(id, facility.maturity, nextDue);\n            facility.nextPaymentDue = nextAggregate;\n            if (nextAggregate != previousAggregate) emit NextPaymentDueSet(id, previousAggregate, nextAggregate);\n            return;\n        }\n        if (\n            facility.pik && bridge.accrualReserve != address(0)\n                && IContinuousAccrual(bridge.accrualReserve).accrualSnapshot().enabled\n        ) revert Bridge_AccrualDueManaged(id);\n        uint64 previous = facility.nextPaymentDue;\n        if (nextDue <= previous || nextDue > facility.maturity) revert Bridge_BadFacility();\n        facility.nextPaymentDue = nextDue;\n        emit NextPaymentDueSet(id, previous, nextDue);\n    }\n\n    /// @notice Advances or completes the PIK clock from the permanently bound reserve only.\n    function setPikDue(uint256 id, uint64 nextDue) public {\n        BridgeStorage storage bridge = _bridgeStorage();\n        if (bridge.accrualReserve == address(0) || msg.sender != bridge.accrualReserve) {\n            revert Bridge_AccrualReserveOnly(msg.sender);\n        }\n        Facility storage facility = _liveFacility(bridge, id);\n        if (!facility.pik) revert Bridge_BadFacility();\n        if (facility.loanState != _ACTIVE && facility.loanState != _AMORTIZING) {\n            revert Bridge_InvalidTransition(id, facility.loanState, facility.loanState);\n        }\n        if (_state().terms[id].cashRateBps != 0) {\n            (uint64 previousAggregate, uint64 nextAggregate) = _setPikDue(id, facility.maturity, nextDue);\n            facility.nextPaymentDue = nextAggregate;\n            if (nextAggregate != previousAggregate) emit NextPaymentDueSet(id, previousAggregate, nextAggregate);\n            return;\n        }\n        uint64 previous = facility.nextPaymentDue;\n        if (nextDue <= previous || nextDue > facility.maturity) revert Bridge_BadFacility();\n        facility.nextPaymentDue = nextDue;\n        emit NextPaymentDueSet(id, previous, nextDue);\n    }\n\n    function _validateOrigination(OriginationTerms memory common, InterestLegTerms memory legs) private view {\n        if (\n            !common.pik || common.rateType != 0 || common.dayCountConvention != 0\n                || common.paymentInterval != legs.cashPaymentInterval\n                || common.nextPaymentDue != _aggregate(legs.nextCashPaymentDue, legs.nextPikCapitalization, common.maturity)\n        ) revert MixedInterest_InvalidTerms();\n        _validateLegs(common.interestRateBps, common.maturity, legs);\n    }\n\n    function _validateAmendment(Amendment memory common, InterestLegTerms memory legs) private view {\n        if (\n            common.rateType != 0 || common.dayCountConvention != 0 || common.paymentInterval != legs.cashPaymentInterval\n                || common.nextPaymentDue != _aggregate(legs.nextCashPaymentDue, legs.nextPikCapitalization, common.maturity)\n        ) revert MixedInterest_InvalidTerms();\n        _validateLegs(common.interestRateBps, common.maturity, legs);\n    }\n\n    function _validateLegs(uint16 totalRate, uint64 maturity, InterestLegTerms memory legs) private view {\n        if (\n            legs.cashRateBps == 0 || legs.pikRateBps == 0 || uint256(legs.cashRateBps) + legs.pikRateBps != totalRate\n                || totalRate > 10_000 || legs.cashPaymentInterval == 0 || legs.pikCapitalizationInterval == 0\n                || legs.nextCashPaymentDue <= block.timestamp || legs.nextCashPaymentDue > maturity\n                || legs.nextPikCapitalization <= block.timestamp || legs.nextPikCapitalization > maturity\n                || legs.cashPaymentInterval > legs.nextCashPaymentDue\n                || legs.pikCapitalizationInterval > legs.nextPikCapitalization\n        ) revert MixedInterest_InvalidTerms();\n    }\n\n    function _validateCommonAmendment(\n        Facility storage facility,\n        Amendment memory a,\n        bytes32 amendmentId,\n        uint64 maxMaturity,\n        bool mixed\n    ) private view {\n        if (\n            amendmentId == bytes32(0) || a.interestRateBps == 0 || a.interestRateBps > _MAX_INTEREST_RATE_BPS\n                || a.paymentInterval == 0 || a.nextPaymentDue <= block.timestamp || a.nextPaymentDue > a.maturity\n                || (!mixed && a.paymentInterval > a.nextPaymentDue) || a.maturity <= block.timestamp\n                || a.maturity > block.timestamp + maxMaturity || a.paymentScheduleHash == bytes32(0)\n                || (a.maturity > facility.maturity && !facility.renewable)\n                || (a.rateType == _FIXED) != (a.rateIndexRef == bytes32(0))\n                || a.renewable != (a.renewalTermsHash != bytes32(0))\n                || (facility.pik && (a.rateType != _FIXED || a.dayCountConvention != _ACTUAL_360))\n        ) revert Bridge_BadFacility();\n    }\n\n    function _checkpointAmendment(\n        address reserve,\n        uint256 id,\n        bytes32 amendmentId,\n        Amendment memory a,\n        bool continuous,\n        bool mixed,\n        InterestLegTerms memory legs\n    ) private {\n        if (mixed) {\n            if (!continuous) revert Bridge_MixedInterestUnavailable();\n            IAccrualLifecycle(reserve).amendMixedAccruingLoan(\n                id,\n                IAccrualLifecycle.MixedTerms({\n                    cashRateBps: legs.cashRateBps,\n                    pikRateBps: legs.pikRateBps,\n                    yearSeconds: uint32(360 days),\n                    nextPikCapitalization: legs.nextPikCapitalization,\n                    pikCapitalizationInterval: legs.pikCapitalizationInterval,\n                    maturity: a.maturity\n                })\n            );\n            _commitAmendment(id, amendmentId, abi.encode(a));\n        } else if (continuous) {\n            IAccrualLifecycle(reserve).amendAccruingLoan(\n                id,\n                IAccrualLifecycle.Terms({\n                    rateBps: a.interestRateBps,\n                    yearSeconds: a.dayCountConvention == _ACTUAL_360 ? uint32(360 days) : uint32(365 days),\n                    nextPaymentDue: a.nextPaymentDue,\n                    paymentInterval: a.paymentInterval,\n                    maturity: a.maturity\n                })\n            );\n        }\n    }\n\n    function _preparedAmendment(uint256 id, bytes32 amendmentId, bytes memory encodedCommon)\n        private\n        view\n        returns (bytes32 attestationHash, InterestLegTerms memory legs)\n    {\n        PendingAmendment storage pending = _state().pendingAmendment[id];\n        if (\n            pending.attestationHash == bytes32(0) || pending.amendmentId != amendmentId\n                || pending.commonHash != keccak256(encodedCommon)\n        ) revert MixedInterest_InvalidTerms();\n        return (pending.attestationHash, pending.terms);\n    }\n\n    function _commitAmendment(uint256 id, bytes32 amendmentId, bytes memory encodedCommon)\n        private\n        returns (InterestLegTerms memory legs)\n    {\n        State storage s = _state();\n        PendingAmendment storage pending = s.pendingAmendment[id];\n        if (\n            pending.attestationHash == bytes32(0) || pending.amendmentId != amendmentId\n                || pending.commonHash != keccak256(encodedCommon)\n        ) revert MixedInterest_InvalidTerms();\n        legs = pending.terms;\n        s.terms[id] = legs;\n        s.commitment[id] = pending.attestationHash;\n        delete s.pendingAmendment[id];\n    }\n\n    function _writeAmendment(Facility storage facility, Amendment memory a) private {\n        facility.interestRateBps = a.interestRateBps;\n        facility.maturity = a.maturity;\n        facility.paymentInterval = a.paymentInterval;\n        facility.nextPaymentDue = a.nextPaymentDue;\n        facility.rateType = a.rateType;\n        facility.dayCountConvention = a.dayCountConvention;\n        facility.renewable = a.renewable;\n        facility.paymentScheduleHash = a.paymentScheduleHash;\n        facility.rateIndexRef = a.rateIndexRef;\n        facility.renewalTermsHash = a.renewalTermsHash;\n    }\n\n    function _creditTermsHash(Facility storage f) private view returns (bytes32) {\n        OriginationTerms memory original = OriginationTerms({\n            classId: f.classId,\n            borrowerId: f.borrowerId,\n            stateId: f.stateId,\n            principal: f.principal,\n            ltvBps: f.ltvBps,\n            interestRateBps: f.interestRateBps,\n            maturity: f.maturity,\n            fundingRecipient: f.fundingRecipient,\n            paymentInterval: f.paymentInterval,\n            nextPaymentDue: f.nextPaymentDue,\n            rateType: f.rateType,\n            dayCountConvention: f.dayCountConvention,\n            renewable: f.renewable,\n            paymentScheduleHash: f.paymentScheduleHash,\n            rateIndexRef: f.rateIndexRef,\n            renewalTermsHash: f.renewalTermsHash,\n            offchainRef: f.offchainRef,\n            pik: f.pik\n        });\n        return keccak256(abi.encode(original));\n    }\n\n    function _requireAccrualTerms(uint256 id, bool pik, uint8 rateType, uint8 dayCount) private pure {\n        if (rateType != _FIXED || dayCount == _THIRTY_360 || (pik && dayCount != _ACTUAL_360)) {\n            revert Bridge_AccrualUnsupportedTerms(id);\n        }\n    }\n\n    function _aggregate(uint64 cashDue, uint64 pikDue, uint64 maturity) private pure returns (uint64) {\n        uint64 effectivePik = pikDue == 0 ? maturity : pikDue;\n        return cashDue < effectivePik ? cashDue : effectivePik;\n    }\n\n    function _originationHash(uint256 generation, OriginationTerms memory common, InterestLegTerms memory legs)\n        private\n        pure\n        returns (bytes32)\n    {\n        // Generation zero preserves the reviewed first-preparation commitment. Only a deliberate\n        // cancellation changes the domain, minimizing tooling churn while making that act durable.\n        if (generation == 0) return keccak256(abi.encode(ORIGINATION_DOMAIN, common, legs));\n        return keccak256(abi.encode(ORIGINATION_DOMAIN, generation, common, legs));\n    }\n\n    function _setCashDue(uint256 id, uint64 maturity, uint64 nextDue)\n        private\n        returns (uint64 previousAggregate, uint64 nextAggregate)\n    {\n        InterestLegTerms storage leg = _known(id);\n        uint64 previous = leg.nextCashPaymentDue;\n        // A bullet cash schedule can receive more than one partial payment after its cash clock\n        // has reached legal maturity. The aggregate bridge clock may still expose an earlier PIK\n        // boundary, so WaterfallEngine cannot identify this no-op from Facility.nextPaymentDue.\n        // Admit only the exact terminal repetition; every other cash-clock update stays strict.\n        if (nextDue == previous && nextDue == maturity) {\n            previousAggregate = _aggregate(previous, leg.nextPikCapitalization, maturity);\n            return (previousAggregate, previousAggregate);\n        }\n        if (nextDue <= previous || nextDue > maturity) revert MixedInterest_InvalidTerms();\n        previousAggregate = _aggregate(previous, leg.nextPikCapitalization, maturity);\n        leg.nextCashPaymentDue = nextDue;\n        nextAggregate = _aggregate(nextDue, leg.nextPikCapitalization, maturity);\n        emit MixedInterestLegDueSet(id, 0, previous, nextDue);\n    }\n\n    function _setPikDue(uint256 id, uint64 maturity, uint64 nextDue)\n        private\n        returns (uint64 previousAggregate, uint64 nextAggregate)\n    {\n        InterestLegTerms storage leg = _known(id);\n        uint64 previous = leg.nextPikCapitalization;\n        if (previous == 0 || (nextDue != 0 && (nextDue <= previous || nextDue > maturity))) {\n            revert MixedInterest_InvalidTerms();\n        }\n        previousAggregate = _aggregate(leg.nextCashPaymentDue, previous, maturity);\n        leg.nextPikCapitalization = nextDue;\n        nextAggregate = _aggregate(leg.nextCashPaymentDue, nextDue, maturity);\n        emit MixedInterestLegDueSet(id, 1, previous, nextDue);\n    }\n\n    function _liveFacility(BridgeStorage storage bridge, uint256 id) private view returns (Facility storage facility) {\n        if (id == 0 || id >= bridge.nextId) revert Bridge_UnknownToken(id);\n        return bridge.facilities[id];\n    }\n\n    function _known(uint256 id) private view returns (InterestLegTerms storage leg) {\n        leg = _state().terms[id];\n        if (leg.cashRateBps == 0) revert MixedInterest_NotConfigured(id);\n    }\n\n    function _state() private pure returns (State storage $) {\n        assembly {\n            $.slot := MIXED_STORAGE_LOCATION\n        }\n    }\n\n    function _isBorrowerPayoutRegistry(address registry_) private view returns (bool valid) {\n        if (registry_.code.length == 0) return false;\n        (bool ok, bytes memory data) =\n            registry_.staticcall(abi.encodeCall(IComplianceRegistry.isFundingRecipientAllowed, (address(0))));\n        if (!ok || data.length != 32) return false;\n        uint256 word;\n        assembly (\"memory-safe\") {\n            word := mload(add(data, 0x20))\n        }\n        return word <= 1;\n    }\n\n    function _bridgeStorage() private pure returns (BridgeStorage storage bridge) {\n        assembly {\n            bridge.slot := BRIDGE_SLOT\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/interfaces/IERC1967.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1967.sol)\n\npragma solidity >=0.4.11;\n\n/**\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\n */\ninterface IERC1967 {\n    /**\n     * @dev Emitted when the implementation is upgraded.\n     */\n    event Upgraded(address indexed implementation);\n\n    /**\n     * @dev Emitted when the admin account has changed.\n     */\n    event AdminChanged(address previousAdmin, address newAdmin);\n\n    /**\n     * @dev Emitted when the beacon is changed.\n     */\n    event BeaconUpgraded(address indexed beacon);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/Strings.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SafeCast} from \"./math/SafeCast.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    using SafeCast for *;\n\n    bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n    uint8 private constant ADDRESS_LENGTH = 20;\n    uint256 private constant SPECIAL_CHARS_LOOKUP =\n        (1 << 0x08) | // backspace\n            (1 << 0x09) | // tab\n            (1 << 0x0a) | // newline\n            (1 << 0x0c) | // form feed\n            (1 << 0x0d) | // carriage return\n            (1 << 0x22) | // double quote\n            (1 << 0x5c); // backslash\n\n    /**\n     * @dev The `value` string doesn't fit in the specified `length`.\n     */\n    error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n    /**\n     * @dev The string being parsed contains characters that are not in scope of the given base.\n     */\n    error StringsInvalidChar();\n\n    /**\n     * @dev The string being parsed is not a properly formatted address.\n     */\n    error StringsInvalidAddressFormat();\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        unchecked {\n            uint256 length = Math.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            assembly (\"memory-safe\") {\n                ptr := add(add(buffer, 0x20), length)\n            }\n            while (true) {\n                ptr--;\n                assembly (\"memory-safe\") {\n                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toStringSigned(int256 value) internal pure returns (string memory) {\n        return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\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        unchecked {\n            return toHexString(value, Math.log256(value) + 1);\n        }\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        uint256 localValue = value;\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_DIGITS[localValue & 0xf];\n            localValue >>= 4;\n        }\n        if (localValue != 0) {\n            revert StringsInsufficientHexLength(value, length);\n        }\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\n     * representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal\n     * representation, according to EIP-55.\n     */\n    function toChecksumHexString(address addr) internal pure returns (string memory) {\n        bytes memory buffer = bytes(toHexString(addr));\n\n        // hash the hex part of buffer (skip length + 2 bytes, length 40)\n        uint256 hashValue;\n        assembly (\"memory-safe\") {\n            hashValue := shr(96, keccak256(add(buffer, 0x22), 40))\n        }\n\n        for (uint256 i = 41; i > 1; --i) {\n            // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)\n            if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {\n                // case shift by xoring with 0x20\n                buffer[i] ^= 0x20;\n            }\n            hashValue >>= 4;\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n\n    /**\n     * @dev Parse a decimal string and returns the value as a `uint256`.\n     *\n     * Requirements:\n     * - The string must be formatted as `[0-9]*`\n     * - The result must fit into an `uint256` type\n     */\n    function parseUint(string memory input) internal pure returns (uint256) {\n        return parseUint(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseUint-string} that parses a substring of `input` located between position `begin` (included) and\n     * `end` (excluded).\n     *\n     * Requirements:\n     * - The substring must be formatted as `[0-9]*`\n     * - The result must fit into an `uint256` type\n     */\n    function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {\n        (bool success, uint256 value) = tryParseUint(input, begin, end);\n        if (!success) revert StringsInvalidChar();\n        return value;\n    }\n\n    /**\n     * @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.\n     *\n     * NOTE: This function will revert if the result does not fit in a `uint256`.\n     */\n    function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {\n        return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid\n     * character.\n     *\n     * NOTE: This function will revert if the result does not fit in a `uint256`.\n     */\n    function tryParseUint(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) internal pure returns (bool success, uint256 value) {\n        if (end > bytes(input).length || begin > end) return (false, 0);\n        return _tryParseUintUncheckedBounds(input, begin, end);\n    }\n\n    /**\n     * @dev Implementation of {tryParseUint-string-uint256-uint256} that does not check bounds. Caller should make sure that\n     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.\n     */\n    function _tryParseUintUncheckedBounds(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) private pure returns (bool success, uint256 value) {\n        bytes memory buffer = bytes(input);\n\n        uint256 result = 0;\n        for (uint256 i = begin; i < end; ++i) {\n            uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));\n            if (chr > 9) return (false, 0);\n            result *= 10;\n            result += chr;\n        }\n        return (true, result);\n    }\n\n    /**\n     * @dev Parse a decimal string and returns the value as a `int256`.\n     *\n     * Requirements:\n     * - The string must be formatted as `[-+]?[0-9]*`\n     * - The result must fit in an `int256` type.\n     */\n    function parseInt(string memory input) internal pure returns (int256) {\n        return parseInt(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and\n     * `end` (excluded).\n     *\n     * Requirements:\n     * - The substring must be formatted as `[-+]?[0-9]*`\n     * - The result must fit in an `int256` type.\n     */\n    function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {\n        (bool success, int256 value) = tryParseInt(input, begin, end);\n        if (!success) revert StringsInvalidChar();\n        return value;\n    }\n\n    /**\n     * @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if\n     * the result does not fit in a `int256`.\n     *\n     * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.\n     */\n    function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {\n        return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);\n    }\n\n    uint256 private constant ABS_MIN_INT256 = 2 ** 255;\n\n    /**\n     * @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid\n     * character or if the result does not fit in a `int256`.\n     *\n     * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.\n     */\n    function tryParseInt(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) internal pure returns (bool success, int256 value) {\n        if (end > bytes(input).length || begin > end) return (false, 0);\n        return _tryParseIntUncheckedBounds(input, begin, end);\n    }\n\n    /**\n     * @dev Implementation of {tryParseInt-string-uint256-uint256} that does not check bounds. Caller should make sure that\n     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.\n     */\n    function _tryParseIntUncheckedBounds(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) private pure returns (bool success, int256 value) {\n        bytes memory buffer = bytes(input);\n\n        // Check presence of a negative sign.\n        bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty\n        bool positiveSign = sign == bytes1(\"+\");\n        bool negativeSign = sign == bytes1(\"-\");\n        uint256 offset = (positiveSign || negativeSign).toUint();\n\n        (bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);\n\n        if (absSuccess && absValue < ABS_MIN_INT256) {\n            return (true, negativeSign ? -int256(absValue) : int256(absValue));\n        } else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {\n            return (true, type(int256).min);\n        } else return (false, 0);\n    }\n\n    /**\n     * @dev Parse a hexadecimal string (with or without \"0x\" prefix), and returns the value as a `uint256`.\n     *\n     * Requirements:\n     * - The string must be formatted as `(0x)?[0-9a-fA-F]*`\n     * - The result must fit in an `uint256` type.\n     */\n    function parseHexUint(string memory input) internal pure returns (uint256) {\n        return parseHexUint(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseHexUint-string} that parses a substring of `input` located between position `begin` (included) and\n     * `end` (excluded).\n     *\n     * Requirements:\n     * - The substring must be formatted as `(0x)?[0-9a-fA-F]*`\n     * - The result must fit in an `uint256` type.\n     */\n    function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {\n        (bool success, uint256 value) = tryParseHexUint(input, begin, end);\n        if (!success) revert StringsInvalidChar();\n        return value;\n    }\n\n    /**\n     * @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.\n     *\n     * NOTE: This function will revert if the result does not fit in a `uint256`.\n     */\n    function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {\n        return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an\n     * invalid character.\n     *\n     * NOTE: This function will revert if the result does not fit in a `uint256`.\n     */\n    function tryParseHexUint(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) internal pure returns (bool success, uint256 value) {\n        if (end > bytes(input).length || begin > end) return (false, 0);\n        return _tryParseHexUintUncheckedBounds(input, begin, end);\n    }\n\n    /**\n     * @dev Implementation of {tryParseHexUint-string-uint256-uint256} that does not check bounds. Caller should make sure that\n     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.\n     */\n    function _tryParseHexUintUncheckedBounds(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) private pure returns (bool success, uint256 value) {\n        bytes memory buffer = bytes(input);\n\n        // skip 0x prefix if present\n        bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2(\"0x\"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty\n        uint256 offset = hasPrefix.toUint() * 2;\n\n        uint256 result = 0;\n        for (uint256 i = begin + offset; i < end; ++i) {\n            uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));\n            if (chr > 15) return (false, 0);\n            result *= 16;\n            unchecked {\n                // Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).\n                // This guarantees that adding a value < 16 will not cause an overflow, hence the unchecked.\n                result += chr;\n            }\n        }\n        return (true, result);\n    }\n\n    /**\n     * @dev Parse a hexadecimal string (with or without \"0x\" prefix), and returns the value as an `address`.\n     *\n     * Requirements:\n     * - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`\n     */\n    function parseAddress(string memory input) internal pure returns (address) {\n        return parseAddress(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseAddress-string} that parses a substring of `input` located between position `begin` (included) and\n     * `end` (excluded).\n     *\n     * Requirements:\n     * - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`\n     */\n    function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {\n        (bool success, address value) = tryParseAddress(input, begin, end);\n        if (!success) revert StringsInvalidAddressFormat();\n        return value;\n    }\n\n    /**\n     * @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly\n     * formatted address. See {parseAddress-string} requirements.\n     */\n    function tryParseAddress(string memory input) internal pure returns (bool success, address value) {\n        return tryParseAddress(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly\n     * formatted address. See {parseAddress-string-uint256-uint256} requirements.\n     */\n    function tryParseAddress(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) internal pure returns (bool success, address value) {\n        if (end > bytes(input).length || begin > end) return (false, address(0));\n\n        bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2(\"0x\"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty\n        uint256 expectedLength = 40 + hasPrefix.toUint() * 2;\n\n        // check that input is the correct length\n        if (end - begin == expectedLength) {\n            // length guarantees that this does not overflow, and value is at most type(uint160).max\n            (bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);\n            return (s, address(uint160(v)));\n        } else {\n            return (false, address(0));\n        }\n    }\n\n    function _tryParseChr(bytes1 chr) private pure returns (uint8) {\n        uint8 value = uint8(chr);\n\n        // Try to parse `chr`:\n        // - Case 1: [0-9]\n        // - Case 2: [a-f]\n        // - Case 3: [A-F]\n        // - otherwise not supported\n        unchecked {\n            if (value > 47 && value < 58) value -= 48;\n            else if (value > 96 && value < 103) value -= 87;\n            else if (value > 64 && value < 71) value -= 55;\n            else return type(uint8).max;\n        }\n\n        return value;\n    }\n\n    /**\n     * @dev Escape special characters in JSON strings. This can be useful to prevent JSON injection in NFT metadata.\n     *\n     * WARNING: This function should only be used in double quoted JSON strings. Single quotes are not escaped.\n     *\n     * NOTE: This function escapes all unicode characters, and not just the ones in ranges defined in section 2.5 of\n     * RFC-4627 (U+0000 to U+001F, U+0022 and U+005C). ECMAScript's `JSON.parse` does recover escaped unicode\n     * characters that are not in this range, but other tooling may provide different results.\n     */\n    function escapeJSON(string memory input) internal pure returns (string memory) {\n        bytes memory buffer = bytes(input);\n        bytes memory output = new bytes(2 * buffer.length); // worst case scenario\n        uint256 outputLength = 0;\n\n        for (uint256 i; i < buffer.length; ++i) {\n            bytes1 char = bytes1(_unsafeReadBytesOffset(buffer, i));\n            if (((SPECIAL_CHARS_LOOKUP & (1 << uint8(char))) != 0)) {\n                output[outputLength++] = \"\\\\\";\n                if (char == 0x08) output[outputLength++] = \"b\";\n                else if (char == 0x09) output[outputLength++] = \"t\";\n                else if (char == 0x0a) output[outputLength++] = \"n\";\n                else if (char == 0x0c) output[outputLength++] = \"f\";\n                else if (char == 0x0d) output[outputLength++] = \"r\";\n                else if (char == 0x5c) output[outputLength++] = \"\\\\\";\n                else if (char == 0x22) {\n                    // solhint-disable-next-line quotes\n                    output[outputLength++] = '\"';\n                }\n            } else {\n                output[outputLength++] = char;\n            }\n        }\n        // write the actual length and deallocate unused memory\n        assembly (\"memory-safe\") {\n            mstore(output, outputLength)\n            mstore(0x40, add(output, shl(5, shr(5, add(outputLength, 63)))))\n        }\n\n        return string(output);\n    }\n\n    /**\n     * @dev Reads a bytes32 from a bytes array without bounds checking.\n     *\n     * NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the\n     * assembly block as such would prevent some optimizations.\n     */\n    function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {\n        // This is not memory safe in the general case, but all calls to this private function are within bounds.\n        assembly (\"memory-safe\") {\n            value := mload(add(add(buffer, 0x20), offset))\n        }\n    }\n}\n"},{"file_path":"src/interfaces/IMintRedeemController.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\n/// @notice The one-bit pause surface of a wired module, declared here because `previewRedeem` must\n///         read the reserve's pause and `IReserveManager` does not declare it.\n/// @dev CANTINA 3.1.3 LIMB (a), CLOSED BY CONSTRUCTION ON THIS INSTANCE. On Ethereum the quote read\n///      the controller pause and the token pause but not the reserve's, so it could publish a full\n///      price for a redemption whose every release is `whenNotPaused`. The disposition there was\n///      \"an integrator should read `ReserveManager.paused()` alongside the quote\", because closing\n///      it was an upgrade. The mechanical reason the sibling fix missed the third surface is that\n///      `ReserveManager` gets `paused()` from `PausableUpgradeable` and never declares it on its own\n///      interface, so nothing in the type system pointed at it. This declaration is that pointer.\ninterface IPausableModule {\n    /// @notice True while the module refuses its `whenNotPaused` entry points.\n    function paused() external view returns (bool);\n}\n\n/// @title IMintRedeemController\n/// @notice KYC-gated issuance and redemption of USDfr against canonical USDC, and the enforcement\n///         point of the protocol's solvency rule. MINT is at par and is CLOSED while the protocol\n///         is under-backed. REDEMPTION is at par while the protocol is whole; while it is short it\n///         settles at the JUNIOR-DRAWN price, which is at least the coverage ratio and MAY BE PAR,\n///         and which the caller must elect via `redeem(uint256,uint256)`.\n///         AUDIT FIX (SWEEP-2 S2-I1) — THIS FILE-LEVEL LINE SAID \"at the coverage ratio while it is\n///         short\", the THIRD round in which a false settlement claim sat on the one line an\n///         explorer or ABI doc renders first. SWEEP-1 MRC-F2 corrected the two `redeem` overloads\n///         and the contract-level block and left this headline. Falsified by the shipped\n///         `ADR0034Y_AtomicJuniorExitDraw::test_Y_theExitSettlesAtParWhileCuratorCapitalStandsIntact`\n///         and by SWEEP-2 S2-F3, in which a sub-par book settled at PAR because ADR-0034 Y-bis drew\n///         junior capital forward to fund it.\n/// @dev THE SOLVENCY RULE IS NOT ADR-0012's ABSOLUTE PREDICATE ANY MORE, AND THIS HEADLINE USED TO\n///      SAY IT WAS (corrected in audit round R18). Until R18 this contract-level notice line read \"KYC-gated 1:1\n///      mint/redeem … `USDfr.totalSupply() <= backingValue()` after every supply-affecting op\".\n///      Both halves were false of the shipped code, and an auditor handed ADR-0012 plus this\n///      interface as the specification would reasonably have reported \"the contract does not\n///      enforce its stated invariant\" as a High. What the contract actually enforces:\n///        - Redemption is NOT 1:1. R16-M3 made the exit price `backing / supply` while short, and\n///          R17 gave the one-argument form a PAR FLOOR, so it reverts rather than settling short.\n///        - The absolute predicate was REPLACED by the NON-WORSENING rule: an operation may not\n///          increase `deficit = max(0, totalSupply - backingValue)`. While the protocol is whole\n///          that reduces exactly to ADR-0012 and still reverts with\n///          `Controller_BackingInvariantViolated`; while it is short it permits the operations that\n///          repair holders' position and refuses the ones that dilute it. See\n///          `MintRedeemController`'s contract-level NatSpec, which sets out the whole model.\n///        - It is not asserted \"after every supply-affecting op\": `burnLoss` carries NO solvency\n///          assertion, deliberately (finding M6 — the assertion it used to carry was unfalsifiable).\n///      The comment was not independently wrong: it correctly quoted `ADR/0012-backing-invariant.md`\n///      (Status: Accepted), which still states the superseded absolute rule verbatim as \"a hard\n///      on-chain check on every supply-affecting operation\". THAT ADR MUST BE AMENDED OR SUPERSEDED\n///      so the code and the decision record agree; it is OUTSTANDING and is Forest Road's to take\n///      (CLAUDE.md §0.7).\ninterface IMintRedeemController {\n    // ── Events ───────────────────────────────────────────────────────────\n    event Minted(address indexed user, uint256 usdcIn, uint256 usdfrOut);\n    event Redeemed(address indexed user, uint256 usdfrIn, uint256 usdcOut);\n    /// @notice Emitted when USDfr is minted against attested yield receipts (waterfall path).\n    event YieldMinted(address indexed to, uint256 amount);\n    /// @notice Emitted when USDfr is burned to realize a loss (cascade layer 3).\n    event LossBurned(address indexed from, uint256 amount);\n    /// @notice AUDIT FIX (R16-M3). Emitted IN ADDITION to `Redeemed` when a redemption settled\n    ///         below par because the protocol was under-backed. Carries the supply and backing\n    ///         the quote was struck against, so the coverage ratio applied to any exit is\n    ///         reconstructable purely from events (CLAUDE.md §3.1).\n    /// @param user The redeemer.\n    /// @param usdfrBurned USDfr burned (whole-USDC-unit aligned).\n    /// @param usdcOut Native USDC units actually paid out.\n    /// @param supply `totalUSDfr()` before the redemption.\n    /// @param backing `backingValue()` before the redemption.\n    event SubParRedemption(address indexed user, uint256 usdfrBurned, uint256 usdcOut, uint256 supply, uint256 backing);\n    /// @notice AUDIT FIX (R17). Emitted alongside `SubParRedemption`. Records the value\n    ///         PERMANENTLY crystallised out of the senior layer by an exit priced against a\n    ///         REVERSIBLE impairment mark, and the running total. `mintableHeadroom()` nets the\n    ///         running total out, so value recovered when the mark is released stays in the pool\n    ///         as coverage instead of being minted to the `sUSDfr` vault as yield.\n    /// @param user The redeemer who bore it.\n    /// @param amount `usdfrBurned - usdcOut * 1e12` for this exit, in 18-decimal USD.\n    /// @param cumulative `seniorSubParShortfall()` after this exit.\n    event SeniorShortfallCrystallised(address indexed user, uint256 amount, uint256 cumulative);\n    /// @notice AUDIT FIX (R16-M1). Governance authorized or revoked a `mintYield` destination.\n    event YieldSinkUpdated(address indexed account, bool authorized);\n    /// @notice AUDIT FIX (R16-M1/M2). Governance authorized or revoked a `burnLoss` source.\n    event LossSourceUpdated(address indexed account, bool authorized);\n\n    // ── Errors ───────────────────────────────────────────────────────────\n    error Controller_NotKYCAllowed(address account);\n    error Controller_BackingInvariantViolated(uint256 supply, uint256 backing);\n    error Controller_ZeroAmount();\n    error Controller_AmountTooSmall(uint256 usdfrAmount);\n\n    /// @notice An unratified arm refused a direct redemption.\n    /// @param armId Active custody arm.\n    /// @param usdcOut Proposed settlement in native USDC units.\n    /// @param usdfrIn USDfr claims proposed for redemption.\n    error Controller_ReserveLossArmFreeze(uint256 armId, uint256 usdcOut, uint256 usdfrIn);\n\n    /// @notice The redemption would have burned more USDfr than the post-draw supply.\n    /// @dev CANTINA 3.1.1, RE-DERIVED AT SCALE 1 AND CLOSED RATHER THAN ACKNOWLEDGED. On Ethereum\n    ///      the whole-unit grid returned `M mod 1e12` wei of headroom at the top of the range, so\n    ///      `usdfrIn + drawn` overflowed only for inputs within 1e12 of `type(uint256).max` - a\n    ///      panic window of width at most 2**40, which is why \"acknowledged\" was a defensible\n    ///      judgement. At scale 1 the grid is the identity, `usdfrIn == usdfrAmount` exactly, and\n    ///      the window widens to the whole top `drawn` of the range. That is not the same judgement\n    ///      about the same object. Bounding the SUM rather than the addend makes the overflow\n    ///      UNREPRESENTABLE rather than merely unlikely, refuses only inputs no holder can hold, and\n    ///      makes `previewRedeem` answer a controller error instead of `Panic(0x11)`.\n    /// @param usdfrIn The amount the exit would burn.\n    /// @param bound `supply - drawn`, which `supply - drawn <= supply` makes underflow-free because\n    ///        `drawn` was burned out of `supply`.\n    error Controller_RedeemExceedsSupply(uint256 usdfrIn, uint256 bound);\n    /// @notice AUDIT FIX (R4-01): the user par paths are closed while the reserve holds less USDC\n    ///         than its idle ledger claims. Recognition of the gap is permissionless and immediate;\n    ///         restoring custody, or the authenticated custody-loss cascade writing the ledger down\n    ///         to the live balance, reopens mint and redeem with no governance action.\n    /// @param shortfallValue The observable custody gap in 18-decimal USD.\n    /// @param recognizedBacking Backing net of that gap — the honest basis.\n    error Controller_ReserveCustodyShortfall(uint256 shortfallValue, uint256 recognizedBacking);\n\n    /// @notice AUDIT FIX (R16-M3/M4/M5). The operation would have WIDENED an already-standing\n    ///         backing deficit. Distinct from `Controller_BackingInvariantViolated`, which is\n    ///         raised when a whole protocol would be pushed below par: an integrator seeing that\n    ///         error inside a knowingly sub-par protocol would reasonably read it as the standing\n    ///         condition rather than as a refusal of this specific call.\n    /// @param deficitBefore `max(0, totalUSDfr() - backingValue())` before the operation.\n    /// @param deficitAfter The same quantity after it, which must not exceed `deficitBefore`.\n    error Controller_DeficitWorsened(uint256 deficitBefore, uint256 deficitAfter);\n\n    /// @notice A paired-yield baseline is already open, so a second cannot be started.\n    error Controller_PairedYieldAlreadyOpen(address caller);\n    /// @notice A split mint must consume this caller's existing paired backing baseline.\n    error Controller_PairedYieldRequired();\n    /// @notice A paired operation cannot complete against a changed retention obligation.\n    error Controller_PairedRetentionChanged(uint256 beforeRequirement, uint256 afterRequirement);\n    /// @notice The protocol fee cannot exceed the total amount being issued.\n    error Controller_InvalidYieldSplit(uint256 total, uint256 fee);\n\n    /// @notice A paired-yield baseline was recorded before its caller moved backing.\n    event PairedYieldOpened(address indexed caller, uint256 supplyBefore, uint256 backingBefore);\n\n    /// @notice A stranded paired-yield baseline was cleared by governance.\n    event PairedYieldCleared(address indexed caller);\n\n    /// @notice Records the supply/backing baseline for a yield mint whose backing leg moves first.\n    function beginPairedYield() external;\n\n    /// @notice Governance escape for a paired-yield baseline stranded by a reverted operation.\n    function clearStalePairedYield() external;\n\n    /// @notice AUDIT FIX (R16-M3). Par issuance is closed while the protocol is under-backed for\n    ///         ANY reason — a G3 conservative mark or a residual cascade deficit as well as the\n    ///         R4-01 custody gap. `redeem` deliberately stays OPEN in this state and re-prices to\n    ///         the coverage ratio; see `previewRedeem`.\n    /// @param supply `totalUSDfr()` at the time of refusal.\n    /// @param backing `backingValue()` at the time of refusal.\n    error Controller_MintClosedWhileUnderBacked(uint256 supply, uint256 backing);\n\n    /// @notice AUDIT FIX (R16-L2). The USDC the user was charged did not arrive in the reserve's\n    ///         custody, or the reserve credited a value that does not match it. Measured from the\n    ///         reserve's own token balance rather than from anything the reserve reports about\n    ///         itself, so `mint` no longer derives both sides of its safety check from one module.\n    /// @param requested Native USDC units pulled from the user.\n    /// @param delivered The reserve's measured USDC balance increase.\n    /// @param credited The 18-decimal value `depositUSDC` reported.\n    error Controller_DepositNotCustodied(uint256 requested, uint256 delivered, uint256 credited);\n\n    /// @notice AUDIT FIX (R16-M1). `to` is not a governance-authorized yield destination.\n    error Controller_NotYieldSink(address to);\n\n    /// @notice AUDIT FIX (R16-M1/M2). `from` is not a governance-authorized loss source. Without\n    ///         this, `burnLoss` and `mintYield` composed into arbitrary confiscation, and\n    ///         `USDfr.burn`'s allowance-free burn made any holder seizable one-sidedly.\n    error Controller_NotLossSource(address from);\n\n    /// @notice AUDIT FIX (R17). A loss source must be a CONTRACT. `burnLoss` burns with no\n    ///         allowance, carries no backing assertion and is deliberately not pausable, so\n    ///         listing an EOA would restore finding M2 — a forced, non-pro-rata seizure of one\n    ///         named holder — in a single routine-looking timelock transaction. Mirrors\n    ///         `ReserveManager.setLossAbsorber`/`setLossController`. Deliberately NOT applied to\n    ///         `setYieldSink`, whose fee-recipient treasury may legitimately be an EOA.\n    error Controller_LossSourceNotContract(address account);\n\n    /// @notice AUDIT FIX (R17). The settled price was below the floor the caller named. The\n    ///         one-argument `redeem` supplies the PAR floor, so it reverts with this rather than\n    ///         silently haircutting a holder against a mark that may later be released.\n    /// @param usdcOut What the redemption would have paid.\n    /// @param minUsdcOut The floor the caller required.\n    error Controller_SlippageExceeded(uint256 usdcOut, uint256 minUsdcOut);\n\n    /// @notice AUDIT FIX (R17). Backing has fallen to zero, so there is nothing to pay out at any\n    ///         size. Previously this answered `Controller_AmountTooSmall`, which told the holder\n    ///         their amount was the problem when the truth was that the protocol was worth nothing.\n    /// @param supply `totalUSDfr()` at the time of refusal.\n    error Controller_NoRedeemableBacking(uint256 supply);\n\n    /// @notice AUDIT FIX (R17). The USDC the redemption was priced at did not reach the redeemer.\n    ///         The outflow twin of `Controller_DepositNotCustodied`: R16-L2 installed an\n    ///         independent measurement on the inflow leg only, leaving `redeem` to take the\n    ///         reserve's own word for a release on the leg where the holder's USDfr is already\n    ///         burned and the loss is irreversible.\n    /// @param expected The quoted payout in native USDC units.\n    /// @param settled The redeemer's measured USDC balance increase.\n    /// @param usdfrBurned The USDfr burned to pay for it.\n    error Controller_RedemptionNotSettled(uint256 expected, uint256 settled, uint256 usdfrBurned);\n\n    /// @notice AUDIT FIX (R17). USDC was left sitting on the controller after a mint. The\n    ///         controller is value-neutral at rest; a reserve that funded the deposit from\n    ///         somewhere other than the controller's allowance satisfies the delivery equality\n    ///         while leaving the user's cash here with a live approval against it.\n    /// @dev Measured as a DELTA across the call, never as an absolute balance: anyone can send\n    ///      USDC to the controller, so `balanceOf(this) != 0` would be a one-wei permanent\n    ///      griefing lock on `mint`.\n    /// @param balanceBefore The controller's USDC balance before the deposit leg.\n    /// @param balanceAfter Its balance after it. Any inequality is refused.\n    error Controller_CashStrandedOnController(uint256 balanceBefore, uint256 balanceAfter);\n\n    /// @notice AUDIT FIX (R17). The operation would have widened the deficit measured on the\n    ///         RECOGNITION-AWARE basis — backing net of the custody shortfall the reserve can\n    ///         observe right now. Raised only by `mintYield`, the one supply-EXPANDING path with\n    ///         no custody precondition; `mint` and `redeem` are refused earlier by\n    ///         `Controller_ReserveCustodyShortfall`, and `burnLoss` is deliberately ungated.\n    /// @param deficitBefore `max(0, totalUSDfr() - recognizedBackingValue())` before the call.\n    /// @param deficitAfter The same quantity after it.\n    error Controller_RecognizedDeficitWorsened(uint256 deficitBefore, uint256 deficitAfter);\n\n    /// @notice AUDIT FIX (R17). A yield mint would have consumed value retained against\n    ///         `seniorSubParShortfall()` — the haircut crystallised out of holders who exited\n    ///         against a REVERSIBLE impairment mark. `mintableHeadroom()` advertises the retention;\n    ///         this error enforces it.\n    /// @dev CORRECTED (SWEEP-1 MRC-F3, 2026-08-08). This sentence used to end \"...because\n    ///      `WaterfallEngine.fund`'s origination-fee mint is not sized off that headroom and would\n    ///      otherwise spend it.\" THAT JUSTIFICATION EXPIRED AT R18. `WaterfallEngine.fund` now\n    ///      reads `uint256 headroom = $.controller.mintableHeadroom();` and clamps\n    ///      `mintable = fee <= headroom ? fee : headroom` (WaterfallEngine.sol:195-197);\n    ///      `MintRedeemController` says so in two places, and\n    ///      `test_R18_A1_originationSurvivesACrystallisedHaircut` passes over the clamped path.\n    ///      This is the same class of defect the merge author fixed on\n    ///      `CollateralRegistry.conservativeSeniorMark`: a stale justification on a value path is\n    ///      a defect, because the next engineer prunes the guard once they discover the reason\n    ///      given for it is untrue.\n    ///\n    ///      THE ERROR IS STILL LOAD-BEARING, ON A DIFFERENT GROUND — DO NOT DELETE IT. It is the\n    ///      LAST line of defence rather than the only one. `CREDIT_ROLE` gates `mintYield`, and\n    ///      `Deploy.s.sol` grants that role to `WaterfallEngine` alone TODAY; a second grantee, or\n    ///      any future unclamped call site, would spend the junior retention silently. The clamp is\n    ///      a caller-side property; this is the callee-side one.\n    /// @param threshold THE BOUND THAT WAS ACTUALLY ENFORCED, which differs by branch and is why\n    ///        this parameter is not named `retention`. On an ordinary yield mint it is\n    ///        `seniorSubParShortfall()`, the junior retention the surplus must not fall below. On a\n    ///        PAIRED mint opened by `beginPairedYield` it is the surplus recorded BEFORE the caller\n    ///        moved any backing, because a paired move raises backing and supply by the identical\n    ///        amount and the property enforced there is exact neutrality rather than a floor.\n    ///        Reporting the retention on the paired branch made the error describe a rule that\n    ///        branch does not apply; corrected 2026-09-10.\n    /// @param surplus `max(0, recognizedBackingValue() - totalUSDfr())` after the mint.\n    error Controller_SeniorRetentionBreached(uint256 threshold, uint256 surplus);\n\n    /// @notice AUDIT FIX (R18). The reserve took the USDC and reported the right credit but did not\n    ///         BOOK it as backing. The recognition twin of `Controller_DepositNotCustodied`: R16-L2\n    ///         measured custody and R17 measured the reported credit, while recognition was left to\n    ///         the NON-WORSENING deficit rule — which a standing surplus silently pays for, up to\n    ///         its own size. Measured as a DELTA on `backingValue()` across the deposit leg, so no\n    ///         surplus can absorb it, and as an EQUALITY, so an over-booking reserve is refused too.\n    /// @param credited The 18-decimal value `depositUSDC` reported.\n    /// @param recognized The measured increase in `backingValue()` across the same call.\n    error Controller_DepositNotRecognized(uint256 credited, uint256 recognized);\n\n    /// @notice AUDIT FIX (R18). A loss source must not be an EIP-7702 DELEGATED EOA. Since Pectra\n    ///         an ordinary key-controlled wallet that signed a delegation carries a 23-byte\n    ///         `0xef0100`-prefixed code field, so `EXTCODESIZE` returns 23 and\n    ///         `Controller_LossSourceNotContract`'s check admitted it — leaving finding M2 (a\n    ///         forced, allowance-free, non-pro-rata seizure of one named holder, unstoppable by the\n    ///         guardian) one routine-looking timelock transaction away for exactly the class of\n    ///         wallet the guard claimed to exclude.\n    error Controller_LossSourceIsDelegatedEOA(address account);\n\n    /// @notice AUDIT FIX (R18). A composite view was read while this contract's reentrancy guard\n    ///         was entered — i.e. from inside a supply change that has not finished settling — and\n    ///         would have answered a number known to be false.\n    /// @dev `_redeem` burns before it releases, and `DefaultManager.realizeLoss` burns before it\n    ///      writes backing down; `USDfr._update` fires the participation-points hook inside every\n    ///      one of those burns. From there `mintableHeadroom()` read the entire realised loss of a\n    ///      cascade as distributable yield capacity, `backingInvariantHolds()` read TRUE on a short\n    ///      book and `previewRedeem` quoted PAR on it. Reverting is the honest answer and is\n    ///      fail-closed for an integrator; returning the number is the R4-01 self-contradiction one\n    ///      frame deeper. The raw delegating views (`backingValue`, `recognizedBackingValue`,\n    ///      `totalUSDfr`) are NOT gated: each is true whenever it is read. Only the composites are.\n    error Controller_ViewUnavailableMidTransition();\n\n    /// @notice `redeem(uint256,uint256,uint256)` was included after the caller's deadline\n    ///         (ADR-0034 W).\n    error Controller_DeadlinePassed(uint256 deadline, uint256 nowTimestamp);\n    /// @notice The junior-draw source named by `ReserveManager.lossAbsorber()` is not on the\n    ///         governance-maintained `setLossSource` list (ADR-0034 Y-bis). Fail-closed: the exit\n    ///         refuses rather than burning a third party's USDfr on an unvouched-for pointer.\n    error Controller_ExitDrawSourceNotAuthorised(address source);\n    /// @notice The junior-draw source reported one number and moved another, or delivered more\n    ///         than was asked of it (ADR-0034 Y-bis). Measured, not trusted.\n    error Controller_ExitDrawNotDelivered(uint256 requested, uint256 reported, uint256 measured);\n\n    /// @notice Junior capital was drawn forward, in cascade order, to fund this exit's price\n    ///         (ADR-0034 Y-bis). `drawn` USDfr was burned out of the junior layers.\n    event SeniorExitJuniorDrawn(address indexed redeemer, uint256 required, uint256 drawn);\n\n    // ── User paths (KYC-gated) ───────────────────────────────────────────\n    /// @notice Deposits USDC (6 decimals) and mints USDfr 1:1 in 18-decimal USD units.\n    function mint(uint256 usdcAmount) external returns (uint256 usdfrOut);\n\n    /// @notice Burns USDfr and releases the reserve's cash equivalent AT PAR. While the protocol\n    ///         is short this form settles at par out of JUNIOR capital drawn forward in the same\n    ///         transaction (ADR-0034 Y-bis), and reverts `Controller_SlippageExceeded` only once\n    ///         that draw cannot reach par. It never haircuts the caller. Use\n    ///         `redeem(uint256,uint256)` to elect a sub-par exit.\n    /// @dev AUDIT FIX (R18) CORRECTED THE NOTICE LINE ABOVE, which every block explorer, ABI\n    ///      doc and integrator reads first. It said this form is \"priced at the coverage ratio: par\n    ///      while the protocol is whole, `backing / supply` while it is short\". After R17's par\n    ///      floor that is false of THIS form. The coverage-ratio behaviour described below is\n    ///      R16-M3's and is true of the two-argument form.\n    /// @dev CORRECTED AGAIN (SWEEP-1 MRC-F2, 2026-08-08) — SAME LINE, ONE ROUND LATER. R18's\n    ///      replacement said this form \"REVERTS\" while short, full stop. That stopped being true\n    ///      at ADR-0034 Y-bis, which draws curator first-loss and the sGROVE backstop forward in\n    ///      the same transaction to fund the cascade-ordered price. MEASURED: with a gross quote of\n    ///      185,928.705440 USDC this form settled 200,000.000000 — AT PAR, out of junior capital.\n    ///      It reverts only when the draw cannot reach par. Two successive rounds put a false\n    ///      settlement claim on the one line integrators read first; check it against\n    ///      `MintRedeemController._quoteRedeem` and `_drawJuniorForExit` before editing it again.\n    /// @dev AUDIT FIX (R17): THIS FORM SUPPLIES THE PAR FLOOR. It settles at par or reverts with\n    ///      `Controller_SlippageExceeded`. R16 made the price a live function of state and left\n    ///      this one-argument signature accepting whatever the ratio was at inclusion, while\n    ///      several NON-timelocked paths move backing down in the same block. Taking a haircut is\n    ///      now an explicit election: quote with `previewRedeem`, then call the two-argument form\n    ///      with the floor you will accept.\n    function redeem(uint256 usdfrAmount) external returns (uint256 usdcOut);\n\n    /// @notice Burns USDfr and releases the reserve's cash equivalent, refusing to settle below\n    ///         `minUsdcOut`. This is the form that accepts a SUB-PAR exit — an explicit, informed\n    ///         election by the holder (R16-M3, R17).\n    /// @dev CORRECTED (SWEEP-1 MRC-F2, 2026-08-08). This line said the form \"pays the COVERAGE\n    ///      RATIO\". It pays the JUNIOR-DRAWN price, which is >= the coverage ratio and may be par:\n    ///      ADR-0034 Y-bis draws curator first-loss and the sGROVE backstop forward in the same\n    ///      transaction, and the gross `backing / supply` mark is only the floor the price degrades\n    ///      to once junior capital is exhausted. Quote with `previewRedeem`, which shares the\n    ///      drawn arithmetic.\n    /// @dev AUDIT FIX (R17). `previewRedeem` is advisory ACROSS TRANSACTIONS — it shares\n    ///      `redeem`'s arithmetic, not its state — so this parameter is the only thing that binds\n    ///      the settlement price. Pass the value `previewRedeem` returned (or lower, to tolerate\n    ///      movement).\n    /// @dev THE DEADLINE IS NOW SHIPPED, ON A NEW SIGNATURE (ADR-0034 W). R17 wrote here that\n    ///      \"there is no deadline parameter: there is no AMM-style path here, and the floor alone\n    ///      is sufficient to make the exit refusable\", which argued an ACCEPTED requirement away.\n    ///      `redeem(uint256,uint256,uint256)` carries it. THIS form is deliberately left\n    ///      deadline-free rather than being given a new expiry semantic under an unchanged\n    ///      signature — see that overload's NatSpec. Prefer the three-argument form.\n    /// @param usdfrAmount USDfr offered; the burn is snapped down to the whole-USDC-unit grid.\n    /// @param minUsdcOut The lowest native-USDC payout the caller will accept. Zero accepts ANY\n    ///        price, including a deep haircut — pass zero only deliberately.\n    function redeem(uint256 usdfrAmount, uint256 minUsdcOut) external returns (uint256 usdcOut);\n\n    /// @notice Burns USDfr and releases the reserve's cash equivalent, refusing to settle below\n    ///         `minUsdcOut` or after `deadline`. THE CANONICAL EXIT (ADR-0034 W).\n    /// @dev A minimum-out bounds the PRICE; it does not bound WHEN the exit executes. Every path\n    ///      that moves the coverage ratio down is un-timelocked and publicly visible before it\n    ///      lands, so a transaction left in the mempool is a free option for whoever chooses\n    ///      inclusion. See the implementation NatSpec.\n    /// @param usdfrAmount USDfr offered; the burn is snapped down to the whole-USDC-unit grid.\n    /// @param minUsdcOut The lowest native-USDC payout the caller will accept.\n    /// @param deadline Latest `block.timestamp` at which this exit may settle.\n    function redeem(uint256 usdfrAmount, uint256 minUsdcOut, uint256 deadline) external returns (uint256 usdcOut);\n\n    // ── Protocol paths (credit layer; wired in Phases E/G) ───────────────\n    /// @notice Mints USDfr to `to` against newly received, attested backing (loan\n    ///         interest / reserve yield). `CREDIT_ROLE`.\n    /// @dev AUDIT FIX (R16-M1): `to` must be a governance-authorized yield sink. Refuses while\n    ///      the protocol is under-backed (incoming cash repairs the hole before it is paid out\n    ///      as yield) and while the controller is paused (a pause must never permit supply\n    ///      expansion). Callers should size the mint with `mintableHeadroom()`.\n    /// @dev AUDIT FIX (R17/R18): it ALSO refuses while the surplus is below\n    ///      `seniorSubParShortfall()` (`Controller_SeniorRetentionBreached`) — an ABSOLUTE level\n    ///      check that bites in states the protocol publishes as fully backed. EVERY CALLER MUST\n    ///      SIZE ITSELF OFF `mintableHeadroom()`: it is the one view that nets the retention, both\n    ///      pauses and the recognition basis. `WaterfallEngine` now does so on BOTH of its mints\n    ///      (interest since R16-M5, the origination fee since R18); a caller that does not will\n    ///      revert rather than withhold.\n    function mintYield(address to, uint256 amount) external;\n\n    /// @notice Issues one paired increase to two authorized sinks, checking the complete total.\n    /// @param senior Destination of total minus fee; unused when that amount is zero.\n    /// @param total Total new supply, justified by the backing increase since beginPairedYield.\n    /// @param feeRecipient Destination of fee; unused when fee is zero.\n    /// @param fee Part of total allocated before the senior leg, in normalized USDfr units.\n    function mintYieldSplit(address senior, uint256 total, address feeRecipient, uint256 fee) external;\n\n    /// @notice Burns USDfr from `from` to realize a loss through the cascade.\n    ///         `LOSS_BURNER_ROLE` — deliberately NOT `CREDIT_ROLE`.\n    /// @dev AUDIT FIX (R16-M1/M2): `from` must be a governance-authorized loss source, and the\n    ///      role is split from `CREDIT_ROLE` so `WaterfallEngine`, which never burns, no longer\n    ///      holds the power to. Never pausable: loss absorption must stay available.\n    function burnLoss(address from, uint256 amount) external;\n\n    // ── Governance: credit-layer endpoints (AUDIT FIX R16-M1) ────────────\n    /// @notice Authorizes (or revokes) an address as a destination for `mintYield`.\n    function setYieldSink(address account, bool authorized) external;\n\n    /// @notice Authorizes (or revokes) an address as a source for `burnLoss`.\n    function setLossSource(address account, bool authorized) external;\n\n    // ── Views ────────────────────────────────────────────────────────────\n    /// @notice Current backing value on the RECORDED-LEDGER basis\n    ///         (delegates to `ReserveManager.totalBackingValue()`).\n    /// @dev AUDIT FIX (R4-01): this is the basis the C-01 custody-loss arithmetic reconciles\n    ///      against within a single transaction and is deliberately NOT recognition-aware. For any\n    ///      solvency or exit-pricing question use `recognizedBackingValue()`.\n    function backingValue() external view returns (uint256);\n\n    /// @notice AUDIT FIX (R4-01). Backing net of the custody shortfall the reserve can observe\n    ///         right now (delegates to `ReserveManager.recognizedBackingValue()`).\n    function recognizedBackingValue() external view returns (uint256);\n\n    /// @notice Current USDfr total supply.\n    function totalUSDfr() external view returns (uint256);\n\n    /// @notice True if supply is covered on the RECORDED ledger.\n    /// @dev Compatibility diagnostic only. DELIBERATELY BLIND TO THE CUSTODY SHORTFALL and no\n    ///      longer consumed by `WaterfallEngine.distribute`: that path enforces exact receipt and\n    ///      a non-worsening recognised deficit. Do not use this absolute view as an admission\n    ///      gate, user-path condition, exit price, or solvency display.\n    function creditServicingBackingHolds() external view returns (bool);\n\n    /// @notice True if the backing invariant currently holds. Public so anyone can check.\n    /// @dev AUDIT FIX (R4-01): measured against `recognizedBackingValue()`, so it can no longer\n    ///      report true in the same block in which `observeIdleUSDC()` publishes a shortfall.\n    /// @dev AUDIT FIX (R18): reverts with `Controller_ViewUnavailableMidTransition` if called from\n    ///      inside an unsettled supply change — mid-burn it read TRUE on a 20%-short book.\n    function backingInvariantHolds() external view returns (bool);\n\n    /// @notice AUDIT FIX (R16-M4/M5). `max(0, totalUSDfr() - backingValue())` on the RECORDED\n    ///         basis — the quantity every supply-affecting path refuses to increase.\n    /// @dev AUDIT FIX (R18): reverts with `Controller_ViewUnavailableMidTransition` if called from\n    ///      inside an unsettled supply change; it composes a supply reading with a backing reading.\n    function backingDeficit() external view returns (uint256);\n\n    /// @notice AUDIT FIX (R16-M4). The same quantity on the RECOGNITION-AWARE basis (net of any\n    ///         observable custody shortfall).\n    /// @dev This is what `WaterfallEngine.distribute` gates on, comparing it before and after the\n    ///      call. Non-worsening rather than absolute, so a repayment that REPAIRS backing is not\n    ///      refused merely because the protocol was already short — which is what previously\n    ///      turned a single conservative mark into a total halt of repayment processing.\n    /// @dev AUDIT FIX (R18): reverts with `Controller_ViewUnavailableMidTransition` if called from\n    ///      inside an unsettled supply change, as `backingDeficit()` does.\n    function recognizedDeficit() external view returns (uint256);\n\n    /// @notice AUDIT FIX (R16-M5, corrected by R17, R18 and SWEEP-2 S2-F4). How much NEW supply may\n    ///         be minted without widening the deficit or paying away value the protocol owes:\n    ///         `(paused() || USDfr.paused()) ? 0 : max(0, recognizedBackingValue() - totalUSDfr() -\n    ///         seniorSubParShortfall() - ReserveManager.exitPrepaidAbsorption())`.\n    /// @dev AUDIT FIX (SWEEP-2 S2-F4) — THE FOURTH TERM WAS MISSING FROM THIS PUBLISHED FORMULA, AND\n    ///      THE STRING `exitPrepaid` APPEARED NOWHERE IN THIS FILE. ADR-0034 Y-bis added\n    ///      `ReserveManager.exitPrepaidAbsorption()` to the implementation and not to the\n    ///      specification. This is the one view that decides how much yield may be minted, and\n    ///      `mintYield`'s note below warns that \"a caller that does not size itself off\n    ///      `mintableHeadroom()` will revert rather than withhold\" — so a caller sizing off the\n    ///      PUBLISHED formula got `Controller_SeniorRetentionBreached` /\n    ///      `Controller_RecognizedDeficitWorsened` instead of a withholding. MEASURED: published\n    ///      formula 9,900.99e18, code 0, undocumented term 9,900.99e18. The retention has NO\n    ///      RESTITUTION PATH and is not necessarily released — see `mintableHeadroom`'s own\n    ///      implementation note and the SWEEP-2 S2-F3 register entry.\n    /// @dev AUDIT FIX (R18): the pause term reads BOTH pauses. R17 read only the controller's, while\n    ///      the same guardian key holds `GUARDIAN_ROLE` on `USDfr` and a token pause refuses every\n    ///      mint — so one transaction still reverted every interest-bearing\n    ///      `WaterfallEngine.distribute` in full. `WaterfallEngine.fund` now sizes its origination\n    ///      fee off this view as well, so under either pause it withholds the fee instead of\n    ///      reverting the origination.\n    /// @dev AUDIT FIX (R18): reverts with `Controller_ViewUnavailableMidTransition` if called from\n    ///      inside an unsettled supply change — mid-cascade it read the entire realised loss as\n    ///      distributable yield capacity.\n    /// @dev `WaterfallEngine._routeInterest` reads this and distributes only what fits,\n    ///      WITHHOLDING the rest so the cash stays in the reserve and repairs backing. That is\n    ///      the protocol-native cure for a residual deficit: loan interest closes the hole\n    ///      automatically, with no governance action and no recapitalisation, and yield resumes\n    ///      by itself once it is closed.\n    /// @dev AUDIT FIX (R17): the basis is RECOGNITION-AWARE. Measured on the recorded ledger the\n    ///      cure was blind to the entire deficit class R4-01 exists to recognise — a custody hole\n    ///      left headroom equal to the whole interest receipt, so the clamp withheld nothing, the\n    ///      protocol fee was taken on the gross, and the hole never closed while every user was\n    ///      frozen out of `mint` and `redeem`. It is also zero while the controller is PAUSED, so\n    ///      the pause withholds yield instead of reverting every borrower repayment, and it nets\n    ///      out `seniorSubParShortfall()`.\n    function mintableHeadroom() external view returns (uint256);\n\n    /// @notice AUDIT FIX (R17). Cumulative value crystallised out of the senior layer by sub-par\n    ///         exits, in 18-decimal USD. Monotonically non-decreasing; no setter.\n    /// @dev Sub-par exits are priced against `recognizePrincipalImpairment` marks, which are\n    ///      REVERSIBLE by design (`releasePrincipalImpairment`). The exiter's loss is not. Without\n    ///      this, value recovered when a mark is released reappeared as `mintableHeadroom()` and\n    ///      was minted to the `sUSDfr` vault — the senior's haircut becoming the yield layer's\n    ///      income, ahead of the §1.3 cascade's first two layers. Netting it out of the headroom\n    ///      keeps recovered value in the pool as coverage instead. Reconstructable from\n    ///      `SeniorShortfallCrystallised` events.\n    /// @dev AUDIT FIX (R18) — WHAT IT COSTS, CORRECTED. `mintYield` enforces this as an ABSOLUTE\n    ///      level check, so it withholds ORIGINATION FEES as well as interest, and it does so in\n    ///      states the protocol publishes as fully backed and even OVER-backed. Under R17 that\n    ///      REFUSED `WaterfallEngine.fund` outright and therefore blocked the only cure the\n    ///      mechanism names (interest requires a facility; a facility requires `fund`) — finding M5\n    ///      on the origination axis. `fund` now clamps its fee to `mintableHeadroom()` and withholds\n    ///      instead. The retention is unchanged. Read `MintRedeemController.seniorSubParShortfall`\n    ///      for the full statement, including the known over-charge on a REALISED (as opposed to\n    ///      released) loss, which is outstanding.\n    function seniorSubParShortfall() external view returns (uint256);\n\n    /// @notice AUDIT FIX (R16-M3/L3). Quotes a redemption without executing it: the USDC that\n    ///         would be paid and the USDfr that would actually be burned.\n    /// @dev Returns `(0, 0)` — BOTH components — in FOUR cases: the amount is below the settleable\n    ///      floor; the protocol has no backing; the protocol is empty (`totalUSDfr() == 0`); or\n    ///      REDEMPTION IS CLOSED because the reserve has an unreconciled custody shortfall\n    ///      (`idleCustodyShortfall() != 0`, AUDIT FIX R18). In all four, nothing is payable at any\n    ///      size, which is what `(0, 0)` has always meant here. A frontend can therefore state the\n    ///      floor, or state that redemption is unavailable, without simulating a revert.\n    /// @dev AUDIT FIX (R18) added the fourth case. R17 changed WHICH number this published over a\n    ///      custody hole; it did not change WHETHER one was published, so in the standing R4-01\n    ///      state — where `backingInvariantHolds()` already publishes FALSE — this returned a full,\n    ///      settleable-looking quote for a call that `_requireCustodiedReserve` then refuses with\n    ///      `Controller_ReserveCustodyShortfall`. Passing that number back in as `minUsdcOut`, as\n    ///      the sentence above directs, reverted.\n    /// @dev AUDIT FIX (R18): reverts with `Controller_ViewUnavailableMidTransition` if called from\n    ///      inside an unsettled supply change (the participation-points hook fires mid-burn, where\n    ///      this view quoted PAR on a short book).\n    /// @dev AUDIT FIX (R17), correcting R16's claim that \"quote and settlement cannot diverge\".\n    ///      This view shares `redeem`'s ARITHMETIC; it does not share `redeem`'s preconditions and\n    ///      it does not bind the price. Two consequences a caller must know:\n    ///        - It is priced on `recognizedBackingValue()`, because unlike `redeem` it is not\n    ///          behind `_requireCustodiedReserve`. On the recorded basis it published a par quote\n    ///          in exactly the state where the recorded ledger is known to be false and the call it\n    ///          quoted for would revert. Wherever `redeem` is reachable the two bases are equal, so\n    ///          the quote is exact there.\n    ///        - It is a snapshot of the current state, valid for that state only. Pass it back into\n    ///          `redeem(usdfrAmount, minUsdcOut)`; that parameter, not this view, is what binds.\n    function previewRedeem(uint256 usdfrAmount) external view returns (uint256 usdcOut, uint256 usdfrIn);\n\n    /// @notice AUDIT FIX (R16-M1). True if `account` may receive `mintYield`.\n    function isYieldSink(address account) external view returns (bool);\n\n    /// @notice AUDIT FIX (R16-M1/M2). True if `account` may be burned from by `burnLoss`.\n    function isLossSource(address account) external view returns (bool);\n\n    /// @notice Wired module addresses, used to bind ReserveManager's independent loss check to\n    ///         the controller that actually points back to that reserve.\n    function modules() external view returns (address usdfr, address compliance, address reserves);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity >=0.5.0;\n\n/**\n * @title ERC-721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC-721 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\n     * 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"},{"file_path":"src/libraries/BridgeAccrualLib.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\nimport {IContinuousAccrual, IAccrualToken} from \"../interfaces/IContinuousAccrual.sol\";\nimport {IMintRedeemController} from \"../interfaces/IMintRedeemController.sol\";\nimport {IReserveManager} from \"../interfaces/IReserveManager.sol\";\n\ninterface IMixedInterestVersion {\n    function mixedInterestVersion() external pure returns (bytes32);\n}\n\ninterface IMixedInterestReserve {\n    function enableMixedInterest() external;\n}\n\n/// @title BridgeAccrualLib\n/// @notice Fixed-ABI validation of the bridge's permanent continuous-accounting source.\n/// @dev Linked calls execute in the bridge's context. The host authenticates governance and\n///      writes its append-only reserve slot only after every read-only identity check succeeds.\nlibrary BridgeAccrualLib {\n    bytes32 private constant _MIXED_INTEREST_VERSION = keccak256(\"forestroad.mixed-interest.v1\");\n    /// @notice A proposed source does not identify the bridge's existing native module routes.\n\n    error BridgeAccrual_InvalidReserve(address reserve);\n\n    /// @notice Validates the token-first binding and both controller and native waterfall routes.\n    /// @param reserve The candidate accounting reserve proxy.\n    /// @param registry The bridge's already configured collateral registry.\n    /// @param oracle The bridge's already configured attestation oracle.\n    function validate(address reserve, address registry, address oracle) public view {\n        if (reserve.code.length == 0) revert BridgeAccrual_InvalidReserve(reserve);\n        bytes memory data = _reply(reserve, abi.encodeCall(IContinuousAccrual.accrualModules, ()), 224, reserve);\n        uint256[7] memory words = abi.decode(data, (uint256[7]));\n        for (uint256 i; i < 7; ++i) {\n            if (words[i] > type(uint160).max || address(uint160(words[i])).code.length == 0) {\n                revert BridgeAccrual_InvalidReserve(reserve);\n            }\n        }\n        IContinuousAccrual.Modules memory m = abi.decode(data, (IContinuousAccrual.Modules));\n        if (m.bridge != address(this) || m.registry != registry) revert BridgeAccrual_InvalidReserve(reserve);\n        data = _reply(m.token, abi.encodeCall(IAccrualToken.accrualReserve, ()), 32, reserve);\n        if (abi.decode(data, (uint256)) != uint256(uint160(reserve))) revert BridgeAccrual_InvalidReserve(reserve);\n        data = _reply(m.controller, abi.encodeCall(IMintRedeemController.modules, ()), 96, reserve);\n        uint256[3] memory controller = abi.decode(data, (uint256[3]));\n        if (\n            controller[0] != uint256(uint160(m.token)) || controller[1] > type(uint160).max\n                || controller[2] != uint256(uint160(reserve))\n        ) revert BridgeAccrual_InvalidReserve(reserve);\n        data = _reply(m.waterfall, abi.encodeWithSignature(\"modules()\"), 192, reserve);\n        uint256[6] memory waterfall = abi.decode(data, (uint256[6]));\n        if (\n            waterfall[0] != uint256(uint160(address(this))) || waterfall[1] != uint256(uint160(registry))\n                || waterfall[2] != uint256(uint160(reserve)) || waterfall[3] != uint256(uint160(m.controller))\n                || waterfall[4] != uint256(uint160(m.vault)) || waterfall[5] != uint256(uint160(oracle))\n        ) revert BridgeAccrual_InvalidReserve(reserve);\n        data = _reply(reserve, abi.encodeCall(IReserveManager.lossController, ()), 32, reserve);\n        if (abi.decode(data, (uint256)) != uint256(uint160(m.controller))) revert BridgeAccrual_InvalidReserve(reserve);\n    }\n\n    /// @notice Requires the reserve and bound waterfall to implement the same mixed-interest ABI.\n    function activateMixed(address reserve) public {\n        _requireMixedVersion(reserve, reserve);\n        bytes memory data = _reply(reserve, abi.encodeCall(IContinuousAccrual.accrualModules, ()), 224, reserve);\n        IContinuousAccrual.Modules memory m = abi.decode(data, (IContinuousAccrual.Modules));\n        if (m.bridge != address(this)) revert BridgeAccrual_InvalidReserve(reserve);\n        _requireMixedVersion(m.waterfall, reserve);\n        _requireMixedVersion(m.defaultManager, reserve);\n        IMixedInterestReserve(reserve).enableMixedInterest();\n    }\n\n    /// @notice Prevents a post-activation bridge downgrade to an implementation that cannot decode mixed state.\n    function validateMixedImplementation(address implementation) public view {\n        _requireMixedVersion(implementation, implementation);\n    }\n\n    function _requireMixedVersion(address target, address reported) private view {\n        bytes memory data = _reply(target, abi.encodeCall(IMixedInterestVersion.mixedInterestVersion, ()), 32, reported);\n        if (abi.decode(data, (bytes32)) != _MIXED_INTEREST_VERSION) {\n            revert BridgeAccrual_InvalidReserve(reported);\n        }\n    }\n\n    /// @dev Reject failed or malformed probes before decoding; no unchecked external result remains.\n    function _reply(address target, bytes memory request, uint256 length, address reserve)\n        private\n        view\n        returns (bytes memory data)\n    {\n        bool ok;\n        (ok, data) = target.staticcall(request);\n        if (!ok || data.length != length) revert BridgeAccrual_InvalidReserve(reserve);\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\nimport {SafeCast} from \"./SafeCast.sol\";\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n    /**\n     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.\n     *\n     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.\n     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute\n     * one branch when needed, making this function more expensive.\n     */\n    function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {\n        unchecked {\n            // branchless ternary works because:\n            // b ^ (a ^ b) == a\n            // b ^ 0 == b\n            return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));\n        }\n    }\n\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return ternary(a > b, a, b);\n    }\n\n    /**\n     * @dev Returns the smallest of two signed numbers.\n     */\n    function min(int256 a, int256 b) internal pure returns (int256) {\n        return ternary(a < b, a, b);\n    }\n\n    /**\n     * @dev Returns the average of two signed numbers without overflow.\n     * The result is rounded towards zero.\n     */\n    function average(int256 a, int256 b) internal pure returns (int256) {\n        // Formula from the book \"Hacker's Delight\"\n        int256 x = (a & b) + ((a ^ b) >> 1);\n        return x + (int256(uint256(x) >> 255) & (a ^ b));\n    }\n\n    /**\n     * @dev Returns the absolute unsigned value of a signed value.\n     */\n    function abs(int256 n) internal pure returns (uint256) {\n        unchecked {\n            // Formula from the \"Bit Twiddling Hacks\" by Sean Eron Anderson.\n            // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,\n            // taking advantage of the most significant (or \"sign\" bit) in two's complement representation.\n            // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,\n            // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).\n            int256 mask = n >> 255;\n\n            // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.\n            return uint256((n + mask) ^ mask);\n        }\n    }\n}\n"},{"file_path":"src/interfaces/IAttestationOracle.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\n/// @title IAttestationOracle\n/// @notice Off-chain → on-chain synchronization layer (ADR-0007). Facilities may not\n///         mint, and material state may not advance, without the required attestations.\n/// @dev TRUST NOTE (state prominently everywhere): the protocol executes faithfully on\n///      whatever authorized attesters assert. A false attestation or compromised\n///      attester key means the protocol acts on false information. This is the\n///      protocol's primary trust assumption (ADR-0007; brief Part 11 gate 6).\ninterface IAttestationOracle {\n    /// @notice Attestation kinds, per ADR-0007 / the legal-wrapper sync table.\n    enum AttestationKind {\n        AssignmentExecuted,\n        UCCFiled,\n        CreditIssued,\n        PaymentReceived,\n        DefaultDeclared,\n        Valuation,\n        LossRealized,\n        PastDueCured,\n        TermsAmended,\n        /// @dev One-shot opening debt for continuous accrual. The payload binds the reserve,\n        ///      migration session, cutoff, facility identity, contractual cursor and balances.\n        AccrualOpening\n    }\n\n    /// @notice Lifecycle of a single ECONOMIC FACT, keyed by (facilityId, kind, payload).\n    /// @dev AUDIT FIX (C4-01/C4-02). This enum exists because the EIP-712 DIGEST is the wrong\n    ///      uniqueness key: `nonce`, `asOf` and `expiry` are all inside the digest but outside the\n    ///      fact, so the SAME real-world event re-signed under a fresh nonce produced a fresh\n    ///      digest and sailed past `used[digest]`. The fact key is digest-independent, so a fact\n    ///      leaves `None` exactly once and never returns to it. See `attest`.\n    /// @custom:member None Never recorded — the only state from which `attest` accepts the fact.\n    /// @custom:member Recorded Accepted and standing; the credit layer has not spent it yet.\n    /// @custom:member Consumed Spent by a CREDIT_ROLE module (the write-down/distribution ran).\n    /// @custom:member Revoked Governance killed it (C4-02: a DURABLE tombstone, not just a flag).\n    enum FactStatus {\n        None,\n        Recorded,\n        Consumed,\n        Revoked\n    }\n\n    /// @notice One attested fact, signed by m-of-n authorized attesters over EIP-712.\n    /// @param facilityId The facility.\n    /// @param kind The attestation kind.\n    /// @param payload Kind-specific commitment. Valuation stores the 18-decimal value\n    ///        directly; operational facts commit to their complete action parameters\n    ///        (terms, payment id/payer/amounts/due date, evidence hash, or amendment id).\n    /// @param asOf The ATTESTED observation time (inside the signed payload — not the\n    ///        submission block time; freshness rules depend on this, ADR-0017 §4).\n    /// @param expiry Submission deadline for this signed bundle.\n    /// @param nonce Uniqueness salt (any unused value; digests are consume-once).\n    struct AttestationInput {\n        uint256 facilityId;\n        AttestationKind kind;\n        bytes32 payload;\n        uint64 asOf;\n        uint64 expiry;\n        uint256 nonce;\n    }\n\n    // ── Events ───────────────────────────────────────────────────────────\n    /// @notice Emitted once per recovered signer of an accepted attestation.\n    event Attested(uint256 indexed facilityId, AttestationKind indexed kind, address indexed attester, uint64 at);\n    /// @notice The fact is now on-chain truth (threshold met).\n    event AttestationSatisfied(uint256 indexed facilityId, AttestationKind indexed kind, bytes32 payload, uint64 asOf);\n    /// @notice A one-shot fact was consumed by the credit layer (e.g. a\n    ///         PaymentReceived spent by its distribution).\n    event AttestationConsumed(uint256 indexed facilityId, AttestationKind indexed kind, address indexed by);\n    /// @notice Governance revoked a fact (e.g. discovered-false attestation).\n    event AttestationRevoked(uint256 indexed facilityId, AttestationKind indexed kind);\n    event ThresholdSet(AttestationKind indexed kind, uint8 threshold);\n    // NOTE: `ValuationWatermarkReset` and the `resetValuationWatermark` lever were REMOVED\n    // (owner decision 2026-07-22). The H-02 anti-rollback watermark itself is unchanged; a stuck\n    // watermark is recovered via the oracle's timelocked UUPS upgrade, not a dedicated lever.\n\n    // ── Errors ───────────────────────────────────────────────────────────\n    error Oracle_Expired(uint64 expiry);\n    error Oracle_BadAsOf(uint64 asOf);\n    error Oracle_DigestAlreadyUsed(bytes32 digest);\n    error Oracle_ThresholdNotMet(uint8 required, uint256 provided);\n    error Oracle_NotAttester(address recovered);\n    error Oracle_UnorderedSigners(address prev, address current);\n    error Oracle_ZeroValuation();\n    error Oracle_StaleValuation(uint64 asOf, uint64 existing);\n    error Oracle_NotSatisfied(uint256 facilityId, AttestationKind kind);\n    /// @notice Process or revoke the current action before submitting another of the same kind.\n    error Oracle_UnconsumedFact(uint256 facilityId, AttestationKind kind, bytes32 payload);\n    error Oracle_BadThreshold();\n    /// @notice AUDIT FIX (C4-01/C4-02): this economic fact has already left `None`. It was\n    ///         recorded, spent, or revoked, and no re-signing under a fresh nonce brings it back.\n    /// @param factKey keccak256(abi.encode(facilityId, uint8(kind), payload)) — see `factKey`.\n    /// @param status The terminal-for-`attest` state the fact is already in.\n    error Oracle_FactAlreadyRealised(bytes32 factKey, FactStatus status);\n\n    // ── Submission (permissionless relay of attester signatures) ─────────\n    /// @notice Records `a` as on-chain truth if at least the kind's threshold of\n    ///         DISTINCT authorized attesters signed exactly this struct (EIP-712).\n    ///         Anyone may relay the bundle; the signatures are the authority.\n    function attest(AttestationInput calldata a, bytes[] calldata signatures) external;\n\n    // ── Credit-layer consumption ─────────────────────────────────────────\n    /// @notice Clears the satisfied flag of a one-shot fact (payload/asOf retained\n    ///         for audit). Only a wired CREDIT_ROLE module may consume a fact.\n    function consume(uint256 facilityId, AttestationKind kind) external;\n\n    // ── Governance ───────────────────────────────────────────────────────\n    /// @notice Revokes a fact (clears satisfied; a revoked Valuation is zeroed so the\n    ///         margin path blocks until a fresh mark). Timelocked governance only.\n    function revoke(uint256 facilityId, AttestationKind kind) external;\n\n    // NOTE (owner decision 2026-07-22): the `resetValuationWatermark` recovery lever was REMOVED.\n    // The H-02 anti-rollback watermark itself is unchanged. Rationale: the lever was also an\n    // attack surface -- governance goes through a PUBLIC timelock queue, so a queued reset let a\n    // holder of a pre-signed OLDER valuation race the watermark down the instant it executed,\n    // re-opening the rollback the watermark prevents. The rare \"watermark stuck at a far-future\n    // asOf after an attester-quorum compromise\" recovery is instead handled by the oracle's\n    // timelocked UUPS upgrade (redundant with the lever, without the race surface). This\n    // supersedes the 2026-07-21 decision to keep it.\n\n    /// @notice Sets a kind's m-of-n threshold (>= 1). Timelocked governance only.\n    function setThreshold(AttestationKind kind, uint8 threshold_) external;\n\n    // ── Views ────────────────────────────────────────────────────────────\n    /// @notice True if `facilityId` has a currently valid attestation of `kind`.\n    function isSatisfied(uint256 facilityId, AttestationKind kind) external view returns (bool);\n\n    /// @notice Latest attested valuation mark for a facility (conservative, haircut).\n    /// @return value 18-dec USD mark (0 = no valid mark).\n    /// @return asOf Attested observation time of the mark (staleness checks per\n    ///         ADR-0015 for marked-to-market classes).\n    function latestValuation(uint256 facilityId) external view returns (uint256 value, uint64 asOf);\n\n    /// @notice Latest recorded fact for (facility, kind).\n    function latestPayload(uint256 facilityId, AttestationKind kind)\n        external\n        view\n        returns (bytes32 payload, uint64 asOf, bool satisfied);\n\n    /// @notice The facility's valuation anti-rollback high-watermark: the highest attested\n    ///         `asOf` ever ACCEPTED for this facility, preserved across `revoke` and `consume`.\n    ///         A new `Valuation` must beat it strictly.\n    /// @param facilityId The facility identifier.\n    /// @return highestAsOf Highest accepted observation time (0 = never marked).\n    function valuationWatermark(uint256 facilityId) external view returns (uint64 highestAsOf);\n\n    /// @notice Current m-of-n threshold for a kind.\n    function threshold(AttestationKind kind) external view returns (uint8);\n\n    /// @notice True if an attestation digest was already submitted (replay guard).\n    /// @dev NOT a fact-uniqueness guard — it is defeated by re-signing the same fact under a\n    ///      fresh nonce. Read `factStatus` for \"has this real-world event already been realised\".\n    function digestUsed(bytes32 digest) external view returns (bool);\n\n    /// @notice The consume-once key for an economic fact: the (facility, kind, payload) triple,\n    ///         with the digest's replay salt (`nonce`/`asOf`/`expiry`) DELIBERATELY excluded.\n    /// @dev AUDIT FIX (C4-01). Exposed so relayers and attester tooling can check whether a fact\n    ///      is already spent before paying for signatures.\n    /// @param facilityId The facility the fact concerns.\n    /// @param kind The attestation kind.\n    /// @param payload The kind-specific commitment identifying the real-world event.\n    /// @return key keccak256(abi.encode(facilityId, uint8(kind), payload)).\n    function factKey(uint256 facilityId, AttestationKind kind, bytes32 payload) external pure returns (bytes32 key);\n\n    /// @notice Lifecycle state of one economic fact (C4-01/C4-02). `None` is the only state from\n    ///         which `attest` accepts it; the transition out of `None` is irreversible.\n    /// @dev Always `None` for `Valuation`: a valuation is a monotone OBSERVATION SERIES, not a\n    ///      one-shot event, and its uniqueness key is `valuationWatermark`, not the payload. Two\n    ///      genuinely distinct marks may legitimately carry the identical value.\n    /// @param facilityId The facility the fact concerns.\n    /// @param kind The attestation kind.\n    /// @param payload The kind-specific commitment identifying the real-world event.\n    /// @return status `None` if never realised; otherwise `Recorded`, `Consumed` or `Revoked`.\n    function factStatus(uint256 facilityId, AttestationKind kind, bytes32 payload)\n        external\n        view\n        returns (FactStatus status);\n\n    /// @notice The EIP-712 digest attesters sign for `a`.\n    /// @dev Exposed for signing tools, atomic executors, and replay-safe relayers.\n    function attestationDigest(AttestationInput calldata a) external view returns (bytes32);\n}\n"},{"file_path":"lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.20;\n\nimport {IAccessControl} from \"@openzeppelin/contracts/access/IAccessControl.sol\";\nimport {ContextUpgradeable} from \"../utils/ContextUpgradeable.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport {ERC165Upgradeable} from \"../utils/introspection/ERC165Upgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n *     require(hasRole(MY_ROLE, msg.sender));\n *     ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n    struct RoleData {\n        mapping(address account => bool) hasRole;\n        bytes32 adminRole;\n    }\n\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n\n    /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n    struct AccessControlStorage {\n        mapping(bytes32 role => RoleData) _roles;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n    function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n        assembly {\n            $.slot := AccessControlStorageLocation\n        }\n    }\n\n    /**\n     * @dev Modifier that checks that an account has a specific role. Reverts\n     * with an {AccessControlUnauthorizedAccount} error including the required role.\n     */\n    modifier onlyRole(bytes32 role) {\n        _checkRole(role);\n        _;\n    }\n\n    function __AccessControl_init() internal onlyInitializing {\n    }\n\n    function __AccessControl_init_unchained() internal onlyInitializing {\n    }\n    /// @inheritdoc IERC165\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n        AccessControlStorage storage $ = _getAccessControlStorage();\n        return $._roles[role].hasRole[account];\n    }\n\n    /**\n     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n     */\n    function _checkRole(bytes32 role) internal view virtual {\n        _checkRole(role, _msgSender());\n    }\n\n    /**\n     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n     * is missing `role`.\n     */\n    function _checkRole(bytes32 role, address account) internal view virtual {\n        if (!hasRole(role, account)) {\n            revert AccessControlUnauthorizedAccount(account, role);\n        }\n    }\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n        AccessControlStorage storage $ = _getAccessControlStorage();\n        return $._roles[role].adminRole;\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been revoked `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `callerConfirmation`.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n        if (callerConfirmation != _msgSender()) {\n            revert AccessControlBadConfirmation();\n        }\n\n        _revokeRole(role, callerConfirmation);\n    }\n\n    /**\n     * @dev Sets `adminRole` as ``role``'s admin role.\n     *\n     * Emits a {RoleAdminChanged} event.\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n        AccessControlStorage storage $ = _getAccessControlStorage();\n        bytes32 previousAdminRole = getRoleAdmin(role);\n        $._roles[role].adminRole = adminRole;\n        emit RoleAdminChanged(role, previousAdminRole, adminRole);\n    }\n\n    /**\n     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n        AccessControlStorage storage $ = _getAccessControlStorage();\n        if (!hasRole(role, account)) {\n            $._roles[role].hasRole[account] = true;\n            emit RoleGranted(role, account, _msgSender());\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n        AccessControlStorage storage $ = _getAccessControlStorage();\n        if (hasRole(role, account)) {\n            $._roles[role].hasRole[account] = false;\n            emit RoleRevoked(role, account, _msgSender());\n            return true;\n        } else {\n            return false;\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeCast {\n    /**\n     * @dev Value doesn't fit in an uint of `bits` size.\n     */\n    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n    /**\n     * @dev An int value doesn't fit in an uint of `bits` size.\n     */\n    error SafeCastOverflowedIntToUint(int256 value);\n\n    /**\n     * @dev Value doesn't fit in an int of `bits` size.\n     */\n    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n    /**\n     * @dev An uint value doesn't fit in an int of `bits` size.\n     */\n    error SafeCastOverflowedUintToInt(uint256 value);\n\n    /**\n     * @dev Returns the downcasted uint248 from uint256, reverting on\n     * overflow (when the input is greater than largest uint248).\n     *\n     * Counterpart to Solidity's `uint248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     */\n    function toUint248(uint256 value) internal pure returns (uint248) {\n        if (value > type(uint248).max) {\n            revert SafeCastOverflowedUintDowncast(248, value);\n        }\n        return uint248(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint240 from uint256, reverting on\n     * overflow (when the input is greater than largest uint240).\n     *\n     * Counterpart to Solidity's `uint240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     */\n    function toUint240(uint256 value) internal pure returns (uint240) {\n        if (value > type(uint240).max) {\n            revert SafeCastOverflowedUintDowncast(240, value);\n        }\n        return uint240(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint232 from uint256, reverting on\n     * overflow (when the input is greater than largest uint232).\n     *\n     * Counterpart to Solidity's `uint232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     */\n    function toUint232(uint256 value) internal pure returns (uint232) {\n        if (value > type(uint232).max) {\n            revert SafeCastOverflowedUintDowncast(232, value);\n        }\n        return uint232(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint224 from uint256, reverting on\n     * overflow (when the input is greater than largest uint224).\n     *\n     * Counterpart to Solidity's `uint224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     */\n    function toUint224(uint256 value) internal pure returns (uint224) {\n        if (value > type(uint224).max) {\n            revert SafeCastOverflowedUintDowncast(224, value);\n        }\n        return uint224(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint216 from uint256, reverting on\n     * overflow (when the input is greater than largest uint216).\n     *\n     * Counterpart to Solidity's `uint216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     */\n    function toUint216(uint256 value) internal pure returns (uint216) {\n        if (value > type(uint216).max) {\n            revert SafeCastOverflowedUintDowncast(216, value);\n        }\n        return uint216(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint208 from uint256, reverting on\n     * overflow (when the input is greater than largest uint208).\n     *\n     * Counterpart to Solidity's `uint208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     */\n    function toUint208(uint256 value) internal pure returns (uint208) {\n        if (value > type(uint208).max) {\n            revert SafeCastOverflowedUintDowncast(208, value);\n        }\n        return uint208(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint200 from uint256, reverting on\n     * overflow (when the input is greater than largest uint200).\n     *\n     * Counterpart to Solidity's `uint200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     */\n    function toUint200(uint256 value) internal pure returns (uint200) {\n        if (value > type(uint200).max) {\n            revert SafeCastOverflowedUintDowncast(200, value);\n        }\n        return uint200(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint192 from uint256, reverting on\n     * overflow (when the input is greater than largest uint192).\n     *\n     * Counterpart to Solidity's `uint192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     */\n    function toUint192(uint256 value) internal pure returns (uint192) {\n        if (value > type(uint192).max) {\n            revert SafeCastOverflowedUintDowncast(192, value);\n        }\n        return uint192(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint184 from uint256, reverting on\n     * overflow (when the input is greater than largest uint184).\n     *\n     * Counterpart to Solidity's `uint184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     */\n    function toUint184(uint256 value) internal pure returns (uint184) {\n        if (value > type(uint184).max) {\n            revert SafeCastOverflowedUintDowncast(184, value);\n        }\n        return uint184(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint176 from uint256, reverting on\n     * overflow (when the input is greater than largest uint176).\n     *\n     * Counterpart to Solidity's `uint176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     */\n    function toUint176(uint256 value) internal pure returns (uint176) {\n        if (value > type(uint176).max) {\n            revert SafeCastOverflowedUintDowncast(176, value);\n        }\n        return uint176(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint168 from uint256, reverting on\n     * overflow (when the input is greater than largest uint168).\n     *\n     * Counterpart to Solidity's `uint168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     */\n    function toUint168(uint256 value) internal pure returns (uint168) {\n        if (value > type(uint168).max) {\n            revert SafeCastOverflowedUintDowncast(168, value);\n        }\n        return uint168(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint160 from uint256, reverting on\n     * overflow (when the input is greater than largest uint160).\n     *\n     * Counterpart to Solidity's `uint160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     */\n    function toUint160(uint256 value) internal pure returns (uint160) {\n        if (value > type(uint160).max) {\n            revert SafeCastOverflowedUintDowncast(160, value);\n        }\n        return uint160(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint152 from uint256, reverting on\n     * overflow (when the input is greater than largest uint152).\n     *\n     * Counterpart to Solidity's `uint152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     */\n    function toUint152(uint256 value) internal pure returns (uint152) {\n        if (value > type(uint152).max) {\n            revert SafeCastOverflowedUintDowncast(152, value);\n        }\n        return uint152(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint144 from uint256, reverting on\n     * overflow (when the input is greater than largest uint144).\n     *\n     * Counterpart to Solidity's `uint144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     */\n    function toUint144(uint256 value) internal pure returns (uint144) {\n        if (value > type(uint144).max) {\n            revert SafeCastOverflowedUintDowncast(144, value);\n        }\n        return uint144(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint136 from uint256, reverting on\n     * overflow (when the input is greater than largest uint136).\n     *\n     * Counterpart to Solidity's `uint136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     */\n    function toUint136(uint256 value) internal pure returns (uint136) {\n        if (value > type(uint136).max) {\n            revert SafeCastOverflowedUintDowncast(136, value);\n        }\n        return uint136(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint128 from uint256, reverting on\n     * overflow (when the input is greater than largest uint128).\n     *\n     * Counterpart to Solidity's `uint128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toUint128(uint256 value) internal pure returns (uint128) {\n        if (value > type(uint128).max) {\n            revert SafeCastOverflowedUintDowncast(128, value);\n        }\n        return uint128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint120 from uint256, reverting on\n     * overflow (when the input is greater than largest uint120).\n     *\n     * Counterpart to Solidity's `uint120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     */\n    function toUint120(uint256 value) internal pure returns (uint120) {\n        if (value > type(uint120).max) {\n            revert SafeCastOverflowedUintDowncast(120, value);\n        }\n        return uint120(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint112 from uint256, reverting on\n     * overflow (when the input is greater than largest uint112).\n     *\n     * Counterpart to Solidity's `uint112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     */\n    function toUint112(uint256 value) internal pure returns (uint112) {\n        if (value > type(uint112).max) {\n            revert SafeCastOverflowedUintDowncast(112, value);\n        }\n        return uint112(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint104 from uint256, reverting on\n     * overflow (when the input is greater than largest uint104).\n     *\n     * Counterpart to Solidity's `uint104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     */\n    function toUint104(uint256 value) internal pure returns (uint104) {\n        if (value > type(uint104).max) {\n            revert SafeCastOverflowedUintDowncast(104, value);\n        }\n        return uint104(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint96 from uint256, reverting on\n     * overflow (when the input is greater than largest uint96).\n     *\n     * Counterpart to Solidity's `uint96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     */\n    function toUint96(uint256 value) internal pure returns (uint96) {\n        if (value > type(uint96).max) {\n            revert SafeCastOverflowedUintDowncast(96, value);\n        }\n        return uint96(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint88 from uint256, reverting on\n     * overflow (when the input is greater than largest uint88).\n     *\n     * Counterpart to Solidity's `uint88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     */\n    function toUint88(uint256 value) internal pure returns (uint88) {\n        if (value > type(uint88).max) {\n            revert SafeCastOverflowedUintDowncast(88, value);\n        }\n        return uint88(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint80 from uint256, reverting on\n     * overflow (when the input is greater than largest uint80).\n     *\n     * Counterpart to Solidity's `uint80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     */\n    function toUint80(uint256 value) internal pure returns (uint80) {\n        if (value > type(uint80).max) {\n            revert SafeCastOverflowedUintDowncast(80, value);\n        }\n        return uint80(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint72 from uint256, reverting on\n     * overflow (when the input is greater than largest uint72).\n     *\n     * Counterpart to Solidity's `uint72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     */\n    function toUint72(uint256 value) internal pure returns (uint72) {\n        if (value > type(uint72).max) {\n            revert SafeCastOverflowedUintDowncast(72, value);\n        }\n        return uint72(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint64 from uint256, reverting on\n     * overflow (when the input is greater than largest uint64).\n     *\n     * Counterpart to Solidity's `uint64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     */\n    function toUint64(uint256 value) internal pure returns (uint64) {\n        if (value > type(uint64).max) {\n            revert SafeCastOverflowedUintDowncast(64, value);\n        }\n        return uint64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint56 from uint256, reverting on\n     * overflow (when the input is greater than largest uint56).\n     *\n     * Counterpart to Solidity's `uint56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     */\n    function toUint56(uint256 value) internal pure returns (uint56) {\n        if (value > type(uint56).max) {\n            revert SafeCastOverflowedUintDowncast(56, value);\n        }\n        return uint56(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint48 from uint256, reverting on\n     * overflow (when the input is greater than largest uint48).\n     *\n     * Counterpart to Solidity's `uint48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     */\n    function toUint48(uint256 value) internal pure returns (uint48) {\n        if (value > type(uint48).max) {\n            revert SafeCastOverflowedUintDowncast(48, value);\n        }\n        return uint48(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint40 from uint256, reverting on\n     * overflow (when the input is greater than largest uint40).\n     *\n     * Counterpart to Solidity's `uint40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     */\n    function toUint40(uint256 value) internal pure returns (uint40) {\n        if (value > type(uint40).max) {\n            revert SafeCastOverflowedUintDowncast(40, value);\n        }\n        return uint40(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint32 from uint256, reverting on\n     * overflow (when the input is greater than largest uint32).\n     *\n     * Counterpart to Solidity's `uint32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     */\n    function toUint32(uint256 value) internal pure returns (uint32) {\n        if (value > type(uint32).max) {\n            revert SafeCastOverflowedUintDowncast(32, value);\n        }\n        return uint32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint24 from uint256, reverting on\n     * overflow (when the input is greater than largest uint24).\n     *\n     * Counterpart to Solidity's `uint24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     */\n    function toUint24(uint256 value) internal pure returns (uint24) {\n        if (value > type(uint24).max) {\n            revert SafeCastOverflowedUintDowncast(24, value);\n        }\n        return uint24(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint16 from uint256, reverting on\n     * overflow (when the input is greater than largest uint16).\n     *\n     * Counterpart to Solidity's `uint16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     */\n    function toUint16(uint256 value) internal pure returns (uint16) {\n        if (value > type(uint16).max) {\n            revert SafeCastOverflowedUintDowncast(16, value);\n        }\n        return uint16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint8 from uint256, reverting on\n     * overflow (when the input is greater than largest uint8).\n     *\n     * Counterpart to Solidity's `uint8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     */\n    function toUint8(uint256 value) internal pure returns (uint8) {\n        if (value > type(uint8).max) {\n            revert SafeCastOverflowedUintDowncast(8, value);\n        }\n        return uint8(value);\n    }\n\n    /**\n     * @dev Converts a signed int256 into an unsigned uint256.\n     *\n     * Requirements:\n     *\n     * - input must be greater than or equal to 0.\n     */\n    function toUint256(int256 value) internal pure returns (uint256) {\n        if (value < 0) {\n            revert SafeCastOverflowedIntToUint(value);\n        }\n        return uint256(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int248 from int256, reverting on\n     * overflow (when the input is less than smallest int248 or\n     * greater than largest int248).\n     *\n     * Counterpart to Solidity's `int248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     */\n    function toInt248(int256 value) internal pure returns (int248 downcasted) {\n        downcasted = int248(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(248, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int240 from int256, reverting on\n     * overflow (when the input is less than smallest int240 or\n     * greater than largest int240).\n     *\n     * Counterpart to Solidity's `int240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     */\n    function toInt240(int256 value) internal pure returns (int240 downcasted) {\n        downcasted = int240(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(240, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int232 from int256, reverting on\n     * overflow (when the input is less than smallest int232 or\n     * greater than largest int232).\n     *\n     * Counterpart to Solidity's `int232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     */\n    function toInt232(int256 value) internal pure returns (int232 downcasted) {\n        downcasted = int232(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(232, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int224 from int256, reverting on\n     * overflow (when the input is less than smallest int224 or\n     * greater than largest int224).\n     *\n     * Counterpart to Solidity's `int224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     */\n    function toInt224(int256 value) internal pure returns (int224 downcasted) {\n        downcasted = int224(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(224, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int216 from int256, reverting on\n     * overflow (when the input is less than smallest int216 or\n     * greater than largest int216).\n     *\n     * Counterpart to Solidity's `int216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     */\n    function toInt216(int256 value) internal pure returns (int216 downcasted) {\n        downcasted = int216(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(216, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int208 from int256, reverting on\n     * overflow (when the input is less than smallest int208 or\n     * greater than largest int208).\n     *\n     * Counterpart to Solidity's `int208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     */\n    function toInt208(int256 value) internal pure returns (int208 downcasted) {\n        downcasted = int208(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(208, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int200 from int256, reverting on\n     * overflow (when the input is less than smallest int200 or\n     * greater than largest int200).\n     *\n     * Counterpart to Solidity's `int200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     */\n    function toInt200(int256 value) internal pure returns (int200 downcasted) {\n        downcasted = int200(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(200, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int192 from int256, reverting on\n     * overflow (when the input is less than smallest int192 or\n     * greater than largest int192).\n     *\n     * Counterpart to Solidity's `int192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     */\n    function toInt192(int256 value) internal pure returns (int192 downcasted) {\n        downcasted = int192(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(192, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int184 from int256, reverting on\n     * overflow (when the input is less than smallest int184 or\n     * greater than largest int184).\n     *\n     * Counterpart to Solidity's `int184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     */\n    function toInt184(int256 value) internal pure returns (int184 downcasted) {\n        downcasted = int184(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(184, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int176 from int256, reverting on\n     * overflow (when the input is less than smallest int176 or\n     * greater than largest int176).\n     *\n     * Counterpart to Solidity's `int176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     */\n    function toInt176(int256 value) internal pure returns (int176 downcasted) {\n        downcasted = int176(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(176, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int168 from int256, reverting on\n     * overflow (when the input is less than smallest int168 or\n     * greater than largest int168).\n     *\n     * Counterpart to Solidity's `int168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     */\n    function toInt168(int256 value) internal pure returns (int168 downcasted) {\n        downcasted = int168(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(168, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int160 from int256, reverting on\n     * overflow (when the input is less than smallest int160 or\n     * greater than largest int160).\n     *\n     * Counterpart to Solidity's `int160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     */\n    function toInt160(int256 value) internal pure returns (int160 downcasted) {\n        downcasted = int160(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(160, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int152 from int256, reverting on\n     * overflow (when the input is less than smallest int152 or\n     * greater than largest int152).\n     *\n     * Counterpart to Solidity's `int152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     */\n    function toInt152(int256 value) internal pure returns (int152 downcasted) {\n        downcasted = int152(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(152, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int144 from int256, reverting on\n     * overflow (when the input is less than smallest int144 or\n     * greater than largest int144).\n     *\n     * Counterpart to Solidity's `int144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     */\n    function toInt144(int256 value) internal pure returns (int144 downcasted) {\n        downcasted = int144(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(144, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int136 from int256, reverting on\n     * overflow (when the input is less than smallest int136 or\n     * greater than largest int136).\n     *\n     * Counterpart to Solidity's `int136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     */\n    function toInt136(int256 value) internal pure returns (int136 downcasted) {\n        downcasted = int136(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(136, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int128 from int256, reverting on\n     * overflow (when the input is less than smallest int128 or\n     * greater than largest int128).\n     *\n     * Counterpart to Solidity's `int128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toInt128(int256 value) internal pure returns (int128 downcasted) {\n        downcasted = int128(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(128, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int120 from int256, reverting on\n     * overflow (when the input is less than smallest int120 or\n     * greater than largest int120).\n     *\n     * Counterpart to Solidity's `int120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     */\n    function toInt120(int256 value) internal pure returns (int120 downcasted) {\n        downcasted = int120(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(120, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int112 from int256, reverting on\n     * overflow (when the input is less than smallest int112 or\n     * greater than largest int112).\n     *\n     * Counterpart to Solidity's `int112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     */\n    function toInt112(int256 value) internal pure returns (int112 downcasted) {\n        downcasted = int112(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(112, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int104 from int256, reverting on\n     * overflow (when the input is less than smallest int104 or\n     * greater than largest int104).\n     *\n     * Counterpart to Solidity's `int104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     */\n    function toInt104(int256 value) internal pure returns (int104 downcasted) {\n        downcasted = int104(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(104, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int96 from int256, reverting on\n     * overflow (when the input is less than smallest int96 or\n     * greater than largest int96).\n     *\n     * Counterpart to Solidity's `int96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     */\n    function toInt96(int256 value) internal pure returns (int96 downcasted) {\n        downcasted = int96(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(96, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int88 from int256, reverting on\n     * overflow (when the input is less than smallest int88 or\n     * greater than largest int88).\n     *\n     * Counterpart to Solidity's `int88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     */\n    function toInt88(int256 value) internal pure returns (int88 downcasted) {\n        downcasted = int88(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(88, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int80 from int256, reverting on\n     * overflow (when the input is less than smallest int80 or\n     * greater than largest int80).\n     *\n     * Counterpart to Solidity's `int80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     */\n    function toInt80(int256 value) internal pure returns (int80 downcasted) {\n        downcasted = int80(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(80, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int72 from int256, reverting on\n     * overflow (when the input is less than smallest int72 or\n     * greater than largest int72).\n     *\n     * Counterpart to Solidity's `int72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     */\n    function toInt72(int256 value) internal pure returns (int72 downcasted) {\n        downcasted = int72(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(72, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int64 from int256, reverting on\n     * overflow (when the input is less than smallest int64 or\n     * greater than largest int64).\n     *\n     * Counterpart to Solidity's `int64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     */\n    function toInt64(int256 value) internal pure returns (int64 downcasted) {\n        downcasted = int64(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(64, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int56 from int256, reverting on\n     * overflow (when the input is less than smallest int56 or\n     * greater than largest int56).\n     *\n     * Counterpart to Solidity's `int56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     */\n    function toInt56(int256 value) internal pure returns (int56 downcasted) {\n        downcasted = int56(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(56, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int48 from int256, reverting on\n     * overflow (when the input is less than smallest int48 or\n     * greater than largest int48).\n     *\n     * Counterpart to Solidity's `int48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     */\n    function toInt48(int256 value) internal pure returns (int48 downcasted) {\n        downcasted = int48(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(48, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int40 from int256, reverting on\n     * overflow (when the input is less than smallest int40 or\n     * greater than largest int40).\n     *\n     * Counterpart to Solidity's `int40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     */\n    function toInt40(int256 value) internal pure returns (int40 downcasted) {\n        downcasted = int40(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(40, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int32 from int256, reverting on\n     * overflow (when the input is less than smallest int32 or\n     * greater than largest int32).\n     *\n     * Counterpart to Solidity's `int32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     */\n    function toInt32(int256 value) internal pure returns (int32 downcasted) {\n        downcasted = int32(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(32, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int24 from int256, reverting on\n     * overflow (when the input is less than smallest int24 or\n     * greater than largest int24).\n     *\n     * Counterpart to Solidity's `int24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     */\n    function toInt24(int256 value) internal pure returns (int24 downcasted) {\n        downcasted = int24(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(24, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int16 from int256, reverting on\n     * overflow (when the input is less than smallest int16 or\n     * greater than largest int16).\n     *\n     * Counterpart to Solidity's `int16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     */\n    function toInt16(int256 value) internal pure returns (int16 downcasted) {\n        downcasted = int16(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(16, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int8 from int256, reverting on\n     * overflow (when the input is less than smallest int8 or\n     * greater than largest int8).\n     *\n     * Counterpart to Solidity's `int8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     */\n    function toInt8(int256 value) internal pure returns (int8 downcasted) {\n        downcasted = int8(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(8, value);\n        }\n    }\n\n    /**\n     * @dev Converts an unsigned uint256 into a signed int256.\n     *\n     * Requirements:\n     *\n     * - input must be less than or equal to maxInt256.\n     */\n    function toInt256(uint256 value) internal pure returns (int256) {\n        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n        if (value > uint256(type(int256).max)) {\n            revert SafeCastOverflowedUintToInt(value);\n        }\n        return int256(value);\n    }\n\n    /**\n     * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.\n     */\n    function toUint(bool b) internal pure returns (uint256 u) {\n        assembly (\"memory-safe\") {\n            u := iszero(iszero(b))\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n    function __ERC165_init() internal onlyInitializing {\n    }\n\n    function __ERC165_init_unchained() internal onlyInitializing {\n    }\n    /// @inheritdoc IERC165\n    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/Errors.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of common custom errors used in multiple contracts\n *\n * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.\n * It is recommended to avoid relying on the error API for critical functionality.\n *\n * _Available since v5.1._\n */\nlibrary Errors {\n    /**\n     * @dev The ETH balance of the account is not enough to perform the operation.\n     */\n    error InsufficientBalance(uint256 balance, uint256 needed);\n\n    /**\n     * @dev A call to an address target failed. The target may have reverted.\n     */\n    error FailedCall();\n\n    /**\n     * @dev The deployment failed.\n     */\n    error FailedDeployment();\n\n    /**\n     * @dev A necessary precompile is missing.\n     */\n    error MissingPrecompile(address);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/proxy/beacon/IBeacon.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (proxy/beacon/IBeacon.sol)\n\npragma solidity >=0.4.16;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n    /**\n     * @dev Must return an address that can be used as a delegate call target.\n     *\n     * {UpgradeableBeacon} will check that this address is a contract.\n     */\n    function implementation() external view returns (address);\n}\n"},{"file_path":"lib/openzeppelin-contracts-upgradeable/contracts/utils/PausableUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)\n\npragma solidity ^0.8.20;\n\nimport {ContextUpgradeable} from \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {\n    /// @custom:storage-location erc7201:openzeppelin.storage.Pausable\n    struct PausableStorage {\n        bool _paused;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Pausable\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;\n\n    function _getPausableStorage() private pure returns (PausableStorage storage $) {\n        assembly {\n            $.slot := PausableStorageLocation\n        }\n    }\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 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    function __Pausable_init() internal onlyInitializing {\n    }\n\n    function __Pausable_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        PausableStorage storage $ = _getPausableStorage();\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        PausableStorage storage $ = _getPausableStorage();\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        PausableStorage storage $ = _getPausableStorage();\n        $._paused = false;\n        emit Unpaused(_msgSender());\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity >=0.6.2;\n\nimport {IERC721} from \"../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"},{"file_path":"src/interfaces/IComplianceRegistry.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\n/// @title IComplianceRegistry\n/// @notice Compliance capability layer (ADR-0011, as amended by the 2026-07-14 directive):\n///         a KYC allowlist consulted ONLY at the mint/redeem primary gate, and a narrow\n///         sanctions blocklist consulted on transfers. The per-token transfer-allowlist\n///         capability was removed — transfers are permissionless (sanctions-only). Policy\n///         (who is eligible/sanctioned) is set by governance/counsel off this interface.\ninterface IComplianceRegistry {\n    /// @notice Emitted when an account's KYC allowlist status changes.\n    event AllowlistUpdated(address indexed account, bool allowed);\n    /// @notice Emitted when an account's sanctions/jurisdiction-block status changes.\n    event JurisdictionBlockUpdated(address indexed account, bool blocked);\n    /// @notice Timelocked governance changed an address's borrower-payout approval.\n    /// @dev This list is deliberately independent of the operational KYC allowlist.\n    event FundingRecipientApprovalUpdated(address indexed account, bool approved);\n\n    /// @notice True if `account` has passed KYC and may use the gated primary paths\n    ///         (USDfr mint/redeem). Holding and transferring are permissionless.\n    function isAllowed(address account) external view returns (bool);\n\n    /// @notice True if `account` is on the sanctions/jurisdiction blocklist.\n    function isJurisdictionBlocked(address account) external view returns (bool);\n\n    /// @notice True only when timelocked governance approved `account` as a borrower-payout\n    ///         destination and the account is not currently jurisdiction-blocked.\n    function isFundingRecipientAllowed(address account) external view returns (bool);\n\n    /// @notice True for a governance-designated internal protocol module.\n    function isProtocolExempt(address module) external view returns (bool);\n\n    /// @notice Transfer gate consulted by protocol tokens on every transfer. Transfers are\n    ///         permissionless except for sanctioned (blocked) parties; burns are always\n    ///         permitted; protocol modules are never treated as blocked.\n    /// @param token Retained for interface stability; no longer affects the result.\n    /// @param from Sender (zero on mint).\n    /// @param to Recipient (zero on burn).\n    /// @return True if the transfer may proceed.\n    function canTransfer(address token, address from, address to) external view returns (bool);\n}\n"},{"file_path":"src/libraries/Roles.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\n// GENERATED by tools/generate-privilege-topology.mjs from config/privilege-topology.json.\n// Do not edit this file directly; the compiler-AST topology gate rejects drift.\n\n/// @title Roles\n/// @notice Canonical role identifiers for the protocol's access-control matrix.\n/// @dev DEFAULT_ADMIN_ROLE is inherited from AccessControl and represented by bytes32(0).\nlibrary Roles {\n    // NOTE: A QUEUE_ROLE existed through Phase H but was never consumed. The vault gates its exit by the configured redemption-queue address, which is the stronger check; it was removed at Phase I cleanup.\n\n    /// @notice May authorize UUPS upgrades. Held only by the governance timelock.\n    bytes32 internal constant UPGRADER_ROLE = keccak256(\"UPGRADER_ROLE\");\n\n    /// @notice Emergency pause/unpause on value-moving paths. Cannot upgrade or move value.\n    bytes32 internal constant GUARDIAN_ROLE = keccak256(\"GUARDIAN_ROLE\");\n\n    /// @notice May mint USDfr. Held only by the MintRedeemController.\n    bytes32 internal constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n\n    /// @notice Reserve custody operations (deposit/release). Held only by the MintRedeemController.\n    bytes32 internal constant CONTROLLER_ROLE = keccak256(\"CONTROLLER_ROLE\");\n\n    /// @notice Principal deployment, atomic payment receipt, and writedown. Held by credit modules.\n    bytes32 internal constant CREDIT_ROLE = keccak256(\"CREDIT_ROLE\");\n\n    /// @notice May burn USDfr to realize an authenticated loss. Held only by DefaultManager and ReserveManager.\n    /// @dev AUDIT R16-M1: burnLoss is deliberately split from CREDIT_ROLE so the repayment engine cannot compose mint and burn authority.\n    bytes32 internal constant LOSS_BURNER_ROLE = keccak256(\"LOSS_BURNER_ROLE\");\n\n    /// @notice May bracket a junior-capacity change so the vault preserves its asset-denominated performance-fee hurdle. Held only by the curator, sGROVE, and DefaultManager modules.\n    bytes32 internal constant FEE_ACCOUNTING_ROLE = keccak256(\"FEE_ACCOUNTING_ROLE\");\n\n    /// @notice Manages KYC allowlist and jurisdiction blocklist entries.\n    bytes32 internal constant COMPLIANCE_ADMIN_ROLE = keccak256(\"COMPLIANCE_ADMIN_ROLE\");\n\n    /// @notice Reserve configuration and conservative USDC custody write-downs.\n    bytes32 internal constant RESERVE_ADMIN_ROLE = keccak256(\"RESERVE_ADMIN_ROLE\");\n\n    /// @notice May originate facilities (Phase D).\n    bytes32 internal constant ORIGINATOR_ROLE = keccak256(\"ORIGINATOR_ROLE\");\n\n    /// @notice Authorized attesters (Phase G, ADR-0007).\n    bytes32 internal constant ATTESTER_ROLE = keccak256(\"ATTESTER_ROLE\");\n\n    /// @notice Servicing operations: facility funding, repayment distribution, default declaration, and loss realization. Held by Forest Road servicing keys until Phase G binds these paths to attested facts; the role then gates who may execute an already-attested action, not what is true.\n    bytes32 internal constant SERVICER_ROLE = keccak256(\"SERVICER_ROLE\");\n\n    /// @notice Drives RedemptionQueue.closeEpoch. Operational, not governance or upgrade authority: it initiates a financially effective settlement and controls when its budget is sampled, but cannot choose recipients, reorder FIFO, set parameters, or exceed the contract-enforced budget and pricing rules.\n    /// @dev AUDIT FIX D7-01: closeEpoch samples the epoch liquidity budget as a spot read and the fill loop re-reads it every chunk. While permissionless, a caller could hold flash liquidity across both reads; measured excess budget was $1.62M from Morpho alone and $4.31M from stacked Aave and Morpho borrowing. A flash loan cannot span two transactions, so the keeper gate closes the vector at its root. This supersedes ADR-0018 section 2's permissionless-settlement design. Grant the role to at least two holders: a hot keeper and a manual ops-multisig backstop. A total keeper outage is bounded only by governance regranting the role. A permissionless grace fallback was rejected because it would restore the flash vector whenever the keeper missed the window.\n    bytes32 internal constant SETTLEMENT_KEEPER_ROLE = keccak256(\"SETTLEMENT_KEEPER_ROLE\");\n}\n"},{"file_path":"src/libraries/LossEventIds.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.30;\n\n/// @title LossEventIds — disjoint namespaces for facility and custody-loss events\n/// @notice Facility NFTs use the lower half of uint256. Governance-assigned custody incidents\n///         use the upper half, so both kinds can safely share SGrove's event-coverage mappings.\nlibrary LossEventIds {\n    uint256 internal constant CUSTODY_EVENT_NAMESPACE_START = 1 << 255;\n\n    error LossEventIds_InvalidCustodyArm(uint256 armId);\n\n    function isFacilityEvent(uint256 eventId) internal pure returns (bool) {\n        return eventId < CUSTODY_EVENT_NAMESPACE_START;\n    }\n\n    function isCustodyEvent(uint256 eventId) internal pure returns (bool) {\n        return eventId >= CUSTODY_EVENT_NAMESPACE_START;\n    }\n\n    /// @dev Arm ids are generated internally, start at one and stay in the lower namespace.\n    ///      The explicit post-condition keeps the facility/custody partition executable rather\n    ///      than relying on a comment at each call site.\n    function custodyEventId(uint256 armId) internal pure returns (uint256 eventId) {\n        if (armId == 0 || armId >= CUSTODY_EVENT_NAMESPACE_START) {\n            revert LossEventIds_InvalidCustodyArm(armId);\n        }\n        eventId = type(uint256).max - armId;\n        assert(eventId >= CUSTODY_EVENT_NAMESPACE_START);\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/IERC721.sol)\n\npragma solidity >=0.6.2;\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"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC-1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.\n *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n *     function _getImplementation() internal view returns (address) {\n *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n *     }\n *\n *     function _setImplementation(address newImplementation) internal {\n *         require(newImplementation.code.length > 0);\n *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n *     }\n * }\n * ```\n *\n * TIP: Consider using this library along with {SlotDerivation}.\n */\nlibrary StorageSlot {\n    struct AddressSlot {\n        address value;\n    }\n\n    struct BooleanSlot {\n        bool value;\n    }\n\n    struct Bytes32Slot {\n        bytes32 value;\n    }\n\n    struct Uint256Slot {\n        uint256 value;\n    }\n\n    struct Int256Slot {\n        int256 value;\n    }\n\n    struct StringSlot {\n        string value;\n    }\n\n    struct BytesSlot {\n        bytes value;\n    }\n\n    /**\n     * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n     */\n    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `BooleanSlot` with member `value` located at `slot`.\n     */\n    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `Bytes32Slot` with member `value` located at `slot`.\n     */\n    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `Uint256Slot` with member `value` located at `slot`.\n     */\n    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `Int256Slot` with member `value` located at `slot`.\n     */\n    function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `StringSlot` with member `value` located at `slot`.\n     */\n    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n     */\n    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := store.slot\n        }\n    }\n\n    /**\n     * @dev Returns a `BytesSlot` with member `value` located at `slot`.\n     */\n    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n     */\n    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := store.slot\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/interfaces/draft-IERC6093.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC6093.sol)\npragma solidity >=0.8.4;\n\n/**\n * @dev Standard ERC-20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.\n */\ninterface IERC20Errors {\n    /**\n     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     * @param balance Current balance for the interacting account.\n     * @param needed Minimum amount required to perform a transfer.\n     */\n    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n    /**\n     * @dev Indicates a failure with the token `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     */\n    error ERC20InvalidSender(address sender);\n\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC20InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n     * @param spender Address that may be allowed to operate on tokens without being their owner.\n     * @param allowance Amount of tokens a `spender` is allowed to operate with.\n     * @param needed Minimum amount required to perform a transfer.\n     */\n    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n    /**\n     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n     * @param approver Address initiating an approval operation.\n     */\n    error ERC20InvalidApprover(address approver);\n\n    /**\n     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n     * @param spender Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC-721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.\n */\ninterface IERC721Errors {\n    /**\n     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.\n     * Used in balance queries.\n     * @param owner Address of the current owner of a token.\n     */\n    error ERC721InvalidOwner(address owner);\n\n    /**\n     * @dev Indicates a `tokenId` whose `owner` is the zero address.\n     * @param tokenId Identifier number of a token.\n     */\n    error ERC721NonexistentToken(uint256 tokenId);\n\n    /**\n     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     * @param tokenId Identifier number of a token.\n     * @param owner Address of the current owner of a token.\n     */\n    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n    /**\n     * @dev Indicates a failure with the token `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     */\n    error ERC721InvalidSender(address sender);\n\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC721InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     * @param tokenId Identifier number of a token.\n     */\n    error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n    /**\n     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n     * @param approver Address initiating an approval operation.\n     */\n    error ERC721InvalidApprover(address approver);\n\n    /**\n     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC-1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.\n */\ninterface IERC1155Errors {\n    /**\n     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     * @param balance Current balance for the interacting account.\n     * @param needed Minimum amount required to perform a transfer.\n     * @param tokenId Identifier number of a token.\n     */\n    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n    /**\n     * @dev Indicates a failure with the token `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     */\n    error ERC1155InvalidSender(address sender);\n\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC1155InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     * @param owner Address of the current owner of a token.\n     */\n    error ERC1155MissingApprovalForAll(address operator, address owner);\n\n    /**\n     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n     * @param approver Address initiating an approval operation.\n     */\n    error ERC1155InvalidApprover(address approver);\n\n    /**\n     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC1155InvalidOperator(address operator);\n\n    /**\n     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n     * Used in batch transfers.\n     * @param idsLength Length of the array of token identifiers\n     * @param valuesLength Length of the array of token amounts\n     */\n    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n"},{"file_path":"lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/ERC721Upgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {IERC721Metadata} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\nimport {ERC721Utils} from \"@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol\";\nimport {ContextUpgradeable} from \"../../utils/ContextUpgradeable.sol\";\nimport {Strings} from \"@openzeppelin/contracts/utils/Strings.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport {ERC165Upgradeable} from \"../../utils/introspection/ERC165Upgradeable.sol\";\nimport {IERC721Errors} from \"@openzeppelin/contracts/interfaces/draft-IERC6093.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC-721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\nabstract contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721, IERC721Metadata, IERC721Errors {\n    using Strings for uint256;\n\n    /// @custom:storage-location erc7201:openzeppelin.storage.ERC721\n    struct ERC721Storage {\n        // Token name\n        string _name;\n\n        // Token symbol\n        string _symbol;\n\n        mapping(uint256 tokenId => address) _owners;\n\n        mapping(address owner => uint256) _balances;\n\n        mapping(uint256 tokenId => address) _tokenApprovals;\n\n        mapping(address owner => mapping(address operator => bool)) _operatorApprovals;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.ERC721\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant ERC721StorageLocation = 0x80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300;\n\n    function _getERC721Storage() private pure returns (ERC721Storage storage $) {\n        assembly {\n            $.slot := ERC721StorageLocation\n        }\n    }\n\n    /**\n     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n     */\n    function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\n        __ERC721_init_unchained(name_, symbol_);\n    }\n\n    function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n        ERC721Storage storage $ = _getERC721Storage();\n        $._name = name_;\n        $._symbol = symbol_;\n    }\n\n    /// @inheritdoc IERC165\n    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165) returns (bool) {\n        return\n            interfaceId == type(IERC721).interfaceId ||\n            interfaceId == type(IERC721Metadata).interfaceId ||\n            super.supportsInterface(interfaceId);\n    }\n\n    /// @inheritdoc IERC721\n    function balanceOf(address owner) public view virtual returns (uint256) {\n        ERC721Storage storage $ = _getERC721Storage();\n        if (owner == address(0)) {\n            revert ERC721InvalidOwner(address(0));\n        }\n        return $._balances[owner];\n    }\n\n    /// @inheritdoc IERC721\n    function ownerOf(uint256 tokenId) public view virtual returns (address) {\n        return _requireOwned(tokenId);\n    }\n\n    /// @inheritdoc IERC721Metadata\n    function name() public view virtual returns (string memory) {\n        ERC721Storage storage $ = _getERC721Storage();\n        return $._name;\n    }\n\n    /// @inheritdoc IERC721Metadata\n    function symbol() public view virtual returns (string memory) {\n        ERC721Storage storage $ = _getERC721Storage();\n        return $._symbol;\n    }\n\n    /// @inheritdoc IERC721Metadata\n    function tokenURI(uint256 tokenId) public view virtual returns (string memory) {\n        _requireOwned(tokenId);\n\n        string memory baseURI = _baseURI();\n        return bytes(baseURI).length > 0 ? string.concat(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    /// @inheritdoc IERC721\n    function approve(address to, uint256 tokenId) public virtual {\n        _approve(to, tokenId, _msgSender());\n    }\n\n    /// @inheritdoc IERC721\n    function getApproved(uint256 tokenId) public view virtual returns (address) {\n        _requireOwned(tokenId);\n\n        return _getApproved(tokenId);\n    }\n\n    /// @inheritdoc IERC721\n    function setApprovalForAll(address operator, bool approved) public virtual {\n        _setApprovalForAll(_msgSender(), operator, approved);\n    }\n\n    /// @inheritdoc IERC721\n    function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {\n        ERC721Storage storage $ = _getERC721Storage();\n        return $._operatorApprovals[owner][operator];\n    }\n\n    /// @inheritdoc IERC721\n    function transferFrom(address from, address to, uint256 tokenId) public virtual {\n        if (to == address(0)) {\n            revert ERC721InvalidReceiver(address(0));\n        }\n        // Setting an \"auth\" arguments enables the `_isAuthorized` check which verifies that the token exists\n        // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.\n        address previousOwner = _update(to, tokenId, _msgSender());\n        if (previousOwner != from) {\n            revert ERC721IncorrectOwner(from, tokenId, previousOwner);\n        }\n    }\n\n    /// @inheritdoc IERC721\n    function safeTransferFrom(address from, address to, uint256 tokenId) public {\n        safeTransferFrom(from, to, tokenId, \"\");\n    }\n\n    /// @inheritdoc IERC721\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {\n        transferFrom(from, to, tokenId);\n        ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data);\n    }\n\n    /**\n     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n     *\n     * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the\n     * core ERC-721 logic MUST be matched with the use of {_increaseBalance} to keep balances\n     * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by\n     * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`.\n     */\n    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n        ERC721Storage storage $ = _getERC721Storage();\n        return $._owners[tokenId];\n    }\n\n    /**\n     * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.\n     */\n    function _getApproved(uint256 tokenId) internal view virtual returns (address) {\n        ERC721Storage storage $ = _getERC721Storage();\n        return $._tokenApprovals[tokenId];\n    }\n\n    /**\n     * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in\n     * particular (ignoring whether it is owned by `owner`).\n     *\n     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this\n     * assumption.\n     */\n    function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {\n        return\n            spender != address(0) &&\n            (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);\n    }\n\n    /**\n     * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.\n     * Reverts if:\n     * - `spender` does not have approval from `owner` for `tokenId`.\n     * - `spender` does not have approval to manage all of `owner`'s assets.\n     *\n     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this\n     * assumption.\n     */\n    function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {\n        if (!_isAuthorized(owner, spender, tokenId)) {\n            if (owner == address(0)) {\n                revert ERC721NonexistentToken(tokenId);\n            } else {\n                revert ERC721InsufficientApproval(spender, tokenId);\n            }\n        }\n    }\n\n    /**\n     * @dev Unsafe write access to the balances, used by extensions that \"mint\" tokens using an {ownerOf} override.\n     *\n     * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that\n     * a uint256 would ever overflow from increments when these increments are bounded to uint128 values.\n     *\n     * WARNING: Increasing an account's balance using this function tends to be paired with an override of the\n     * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership\n     * remain consistent with one another.\n     */\n    function _increaseBalance(address account, uint128 value) internal virtual {\n        ERC721Storage storage $ = _getERC721Storage();\n        unchecked {\n            $._balances[account] += value;\n        }\n    }\n\n    /**\n     * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner\n     * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.\n     *\n     * The `auth` argument is optional. If the value passed is non 0, then this function will check that\n     * `auth` is either the owner of the token, or approved to operate on the token (by the owner).\n     *\n     * Emits a {Transfer} event.\n     *\n     * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.\n     */\n    function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {\n        ERC721Storage storage $ = _getERC721Storage();\n        address from = _ownerOf(tokenId);\n\n        // Perform (optional) operator check\n        if (auth != address(0)) {\n            _checkAuthorized(from, auth, tokenId);\n        }\n\n        // Execute the update\n        if (from != address(0)) {\n            // Clear approval. No need to re-authorize or emit the Approval event\n            _approve(address(0), tokenId, address(0), false);\n\n            unchecked {\n                $._balances[from] -= 1;\n            }\n        }\n\n        if (to != address(0)) {\n            unchecked {\n                $._balances[to] += 1;\n            }\n        }\n\n        $._owners[tokenId] = to;\n\n        emit Transfer(from, to, tokenId);\n\n        return from;\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 {\n        if (to == address(0)) {\n            revert ERC721InvalidReceiver(address(0));\n        }\n        address previousOwner = _update(to, tokenId, address(0));\n        if (previousOwner != address(0)) {\n            revert ERC721InvalidSender(address(0));\n        }\n    }\n\n    /**\n     * @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance.\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 {\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(address to, uint256 tokenId, bytes memory data) internal virtual {\n        _mint(to, tokenId);\n        ERC721Utils.checkOnERC721Received(_msgSender(), address(0), to, tokenId, data);\n    }\n\n    /**\n     * @dev Destroys `tokenId`.\n     * The approval is cleared when the token is burned.\n     * This is an internal function that does not check if the sender is authorized to operate on the token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _burn(uint256 tokenId) internal {\n        address previousOwner = _update(address(0), tokenId, address(0));\n        if (previousOwner == address(0)) {\n            revert ERC721NonexistentToken(tokenId);\n        }\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(address from, address to, uint256 tokenId) internal {\n        if (to == address(0)) {\n            revert ERC721InvalidReceiver(address(0));\n        }\n        address previousOwner = _update(to, tokenId, address(0));\n        if (previousOwner == address(0)) {\n            revert ERC721NonexistentToken(tokenId);\n        } else if (previousOwner != from) {\n            revert ERC721IncorrectOwner(from, tokenId, previousOwner);\n        }\n    }\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients\n     * are aware of the ERC-721 standard 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 like {safeTransferFrom} in the sense that it invokes\n     * {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.\n     * implement alternative mechanisms to perform token transfer, such as signature-based.\n     *\n     * Requirements:\n     *\n     * - `tokenId` token must exist and be owned by `from`.\n     * - `to` cannot be the zero address.\n     * - `from` cannot be the zero address.\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(address from, address to, uint256 tokenId) internal {\n        _safeTransfer(from, to, tokenId, \"\");\n    }\n\n    /**\n     * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is\n     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n     */\n    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {\n        _transfer(from, to, tokenId);\n        ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data);\n    }\n\n    /**\n     * @dev Approve `to` to operate on `tokenId`\n     *\n     * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is\n     * either the owner of the token, or approved to operate on all tokens held by this owner.\n     *\n     * Emits an {Approval} event.\n     *\n     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n     */\n    function _approve(address to, uint256 tokenId, address auth) internal {\n        _approve(to, tokenId, auth, true);\n    }\n\n    /**\n     * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not\n     * emitted in the context of transfers.\n     */\n    function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {\n        ERC721Storage storage $ = _getERC721Storage();\n        // Avoid reading the owner unless necessary\n        if (emitEvent || auth != address(0)) {\n            address owner = _requireOwned(tokenId);\n\n            // We do not use _isAuthorized because single-token approvals should not be able to call approve\n            if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {\n                revert ERC721InvalidApprover(auth);\n            }\n\n            if (emitEvent) {\n                emit Approval(owner, to, tokenId);\n            }\n        }\n\n        $._tokenApprovals[tokenId] = to;\n    }\n\n    /**\n     * @dev Approve `operator` to operate on all of `owner` tokens\n     *\n     * Requirements:\n     * - operator can't be the address zero.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {\n        ERC721Storage storage $ = _getERC721Storage();\n        if (operator == address(0)) {\n            revert ERC721InvalidOperator(operator);\n        }\n        $._operatorApprovals[owner][operator] = approved;\n        emit ApprovalForAll(owner, operator, approved);\n    }\n\n    /**\n     * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).\n     * Returns the owner.\n     *\n     * Overrides to ownership logic should be done to {_ownerOf}.\n     */\n    function _requireOwned(uint256 tokenId) internal view returns (address) {\n        address owner = _ownerOf(tokenId);\n        if (owner == address(0)) {\n            revert ERC721NonexistentToken(tokenId);\n        }\n        return owner;\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Storage of the initializable contract.\n     *\n     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n     * when using with upgradeable contracts.\n     *\n     * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n     */\n    struct InitializableStorage {\n        /**\n         * @dev Indicates that the contract has been initialized.\n         */\n        uint64 _initialized;\n        /**\n         * @dev Indicates that the contract is in the process of being initialized.\n         */\n        bool _initializing;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n    /**\n     * @dev The contract is already initialized.\n     */\n    error InvalidInitialization();\n\n    /**\n     * @dev The contract is not initializing.\n     */\n    error NotInitializing();\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint64 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts.\n     *\n     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n     * production.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        // Cache values to avoid duplicated sloads\n        bool isTopLevelCall = !$._initializing;\n        uint64 initialized = $._initialized;\n\n        // Allowed calls:\n        // - initialSetup: the contract is not in the initializing state and no previous version was\n        //                 initialized\n        // - construction: the contract is initialized at version 1 (no reinitialization) and the\n        //                 current contract is just being deployed\n        bool initialSetup = initialized == 0 && isTopLevelCall;\n        bool construction = initialized == 1 && address(this).code.length == 0;\n\n        if (!initialSetup && !construction) {\n            revert InvalidInitialization();\n        }\n        $._initialized = 1;\n        if (isTopLevelCall) {\n            $._initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            $._initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     *\n     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint64 version) {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        if ($._initializing || $._initialized >= version) {\n            revert InvalidInitialization();\n        }\n        $._initialized = version;\n        $._initializing = true;\n        _;\n        $._initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        _checkInitializing();\n        _;\n    }\n\n    /**\n     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n     */\n    function _checkInitializing() internal view virtual {\n        if (!_isInitializing()) {\n            revert NotInitializing();\n        }\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     *\n     * Emits an {Initialized} event the first time it is successfully executed.\n     */\n    function _disableInitializers() internal virtual {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        if ($._initializing) {\n            revert InvalidInitialization();\n        }\n        if ($._initialized != type(uint64).max) {\n            $._initialized = type(uint64).max;\n            emit Initialized(type(uint64).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint64) {\n        return _getInitializableStorage()._initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _getInitializableStorage()._initializing;\n    }\n\n    /**\n     * @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.\n     *\n     * NOTE: Consider following the ERC-7201 formula to derive storage locations.\n     */\n    function _initializableStorageSlot() internal pure virtual returns (bytes32) {\n        return INITIALIZABLE_STORAGE;\n    }\n\n    /**\n     * @dev Returns a pointer to the storage namespace.\n     */\n    // solhint-disable-next-line var-name-mixedcase\n    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n        bytes32 slot = _initializableStorageSlot();\n        assembly {\n            $.slot := slot\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/Address.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\nimport {Errors} from \"./Errors.sol\";\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev There's no code at `target` (it is not a contract).\n     */\n    error AddressEmptyCode(address target);\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        if (address(this).balance < amount) {\n            revert Errors.InsufficientBalance(address(this).balance, amount);\n        }\n\n        (bool success, bytes memory returndata) = recipient.call{value: amount}(\"\");\n        if (!success) {\n            _revert(returndata);\n        }\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason or custom error, it is bubbled\n     * up by this function (like regular Solidity function calls). However, if\n     * the call reverted with no returned reason, this function reverts with a\n     * {Errors.FailedCall} error.\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        if (address(this).balance < value) {\n            revert Errors.InsufficientBalance(address(this).balance, value);\n        }\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n     * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case\n     * of an unsuccessful call.\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata\n    ) internal view returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            // only check if target is a contract if the call was successful and the return data is empty\n            // otherwise we already know that it was a contract\n            if (returndata.length == 0 && target.code.length == 0) {\n                revert AddressEmptyCode(target);\n            }\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n     * revert reason or with a default {Errors.FailedCall} error.\n     */\n    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.\n     */\n    function _revert(bytes memory returndata) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            assembly (\"memory-safe\") {\n                revert(add(returndata, 0x20), mload(returndata))\n            }\n        } else {\n            revert Errors.FailedCall();\n        }\n    }\n}\n"}],"certified":false,"conflicting_implementations":null,"abi":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[],"name":"Bridge_AccrualAlreadyBound","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Bridge_AccrualDueManaged","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"Bridge_AccrualReserveOnly","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Bridge_AccrualUnsupportedTerms","type":"error"},{"inputs":[{"internalType":"uint256","name":"classId","type":"uint256"},{"internalType":"enum IAttestationOracle.AttestationKind","name":"kind","type":"uint8"}],"name":"Bridge_AttestationMissing","type":"error"},{"inputs":[{"internalType":"uint256","name":"classId","type":"uint256"},{"internalType":"enum IAttestationOracle.AttestationKind","name":"kind","type":"uint8"},{"internalType":"bytes32","name":"expected","type":"bytes32"},{"internalType":"bytes32","name":"attested","type":"bytes32"}],"name":"Bridge_AttestationNotBoundToDeal","type":"error"},{"inputs":[{"internalType":"uint256","name":"kindsMask","type":"uint256"}],"name":"Bridge_BadAttestationMask","type":"error"},{"inputs":[],"name":"Bridge_BadFacility","type":"error"},{"inputs":[{"internalType":"uint256","name":"classId","type":"uint256"}],"name":"Bridge_ClassInactive","type":"error"},{"inputs":[{"internalType":"uint256","name":"nextId","type":"uint256"}],"name":"Bridge_FacilityEventNamespaceExhausted","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Bridge_FacilityMatured","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"enum ClaimBridge.LoanState","name":"from","type":"uint8"},{"internalType":"enum ClaimBridge.LoanState","name":"to","type":"uint8"}],"name":"Bridge_InvalidTransition","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Bridge_LegacyPikScheduleRequiresMigration","type":"error"},{"inputs":[{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"maxByValue","type":"uint256"}],"name":"Bridge_LtvExceedsValue","type":"error"},{"inputs":[],"name":"Bridge_MixedInterestUnavailable","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Bridge_MixedLifecycleRequired","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Bridge_NotPending","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Bridge_PositionFrozen","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Bridge_TermsAmendmentNotAttested","type":"error"},{"inputs":[{"internalType":"uint256","name":"facilityId","type":"uint256"},{"internalType":"bytes32","name":"expected","type":"bytes32"},{"internalType":"bytes32","name":"attested","type":"bytes32"}],"name":"Bridge_TermsNotAttested","type":"error"},{"inputs":[],"name":"Bridge_TransferRestricted","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Bridge_UnknownToken","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenIdOrZero","type":"uint256"},{"internalType":"uint64","name":"asOf","type":"uint64"},{"internalType":"uint64","name":"maxAge","type":"uint64"}],"name":"Bridge_ValuationStale","type":"error"},{"inputs":[],"name":"Bridge_ZeroAddress","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721IncorrectOwner","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721InsufficientApproval","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC721InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC721InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721InvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC721InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC721InvalidSender","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721NonexistentToken","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"reserve","type":"address"}],"name":"AccrualReserveSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"registry","type":"address"}],"name":"BorrowerPayoutRegistrySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"amendmentId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"termsHash","type":"bytes32"}],"name":"MixedInterestAmendmentPrepared","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"MixedInterestOriginationCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"termsHash","type":"bytes32"}],"name":"MixedInterestOriginationPrepared","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"facilityId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"actionId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"termsHash","type":"bytes32"},{"indexed":false,"internalType":"uint16","name":"cashRateBps","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"pikRateBps","type":"uint16"},{"indexed":false,"internalType":"uint64","name":"cashPaymentInterval","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"nextCashPaymentDue","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"pikCapitalizationInterval","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"nextPikCapitalization","type":"uint64"}],"name":"MixedInterestTermsStaged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"previousDue","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"nextDue","type":"uint64"}],"name":"NextPaymentDueSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"classId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"borrowerId","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"termsHash","type":"bytes32"}],"name":"Originated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"classId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"kindsMask","type":"uint256"}],"name":"RequiredAttestationsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"enum ClaimBridge.LoanState","name":"from","type":"uint8"},{"indexed":false,"internalType":"enum ClaimBridge.LoanState","name":"to","type":"uint8"}],"name":"StateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"amendmentId","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"termsHash","type":"bytes32"}],"name":"TermsAmended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_INTEREST_RATE_BPS","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accrualReserve","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes32","name":"amendmentId","type":"bytes32"},{"components":[{"internalType":"uint16","name":"interestRateBps","type":"uint16"},{"internalType":"uint64","name":"maturity","type":"uint64"},{"internalType":"uint64","name":"paymentInterval","type":"uint64"},{"internalType":"uint64","name":"nextPaymentDue","type":"uint64"},{"internalType":"enum ClaimBridge.RateType","name":"rateType","type":"uint8"},{"internalType":"enum ClaimBridge.DayCountConvention","name":"dayCountConvention","type":"uint8"},{"internalType":"bool","name":"renewable","type":"bool"},{"internalType":"bytes32","name":"paymentScheduleHash","type":"bytes32"},{"internalType":"bytes32","name":"rateIndexRef","type":"bytes32"},{"internalType":"bytes32","name":"renewalTermsHash","type":"bytes32"}],"internalType":"struct ClaimBridge.Amendment","name":"a","type":"tuple"}],"name":"amendTerms","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"cancelPending","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelPreparedMixedOrigination","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"checkFundable","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creditOperationIdle","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"classId","type":"uint256"},{"internalType":"bytes32","name":"borrowerId","type":"bytes32"},{"internalType":"bytes32","name":"stateId","type":"bytes32"},{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint16","name":"ltvBps","type":"uint16"},{"internalType":"uint16","name":"interestRateBps","type":"uint16"},{"internalType":"uint64","name":"maturity","type":"uint64"},{"internalType":"address","name":"fundingRecipient","type":"address"},{"internalType":"uint64","name":"paymentInterval","type":"uint64"},{"internalType":"uint64","name":"nextPaymentDue","type":"uint64"},{"internalType":"enum ClaimBridge.RateType","name":"rateType","type":"uint8"},{"internalType":"enum ClaimBridge.DayCountConvention","name":"dayCountConvention","type":"uint8"},{"internalType":"bool","name":"renewable","type":"bool"},{"internalType":"bytes32","name":"paymentScheduleHash","type":"bytes32"},{"internalType":"bytes32","name":"rateIndexRef","type":"bytes32"},{"internalType":"bytes32","name":"renewalTermsHash","type":"bytes32"},{"internalType":"bytes32","name":"offchainRef","type":"bytes32"},{"internalType":"bool","name":"pik","type":"bool"}],"internalType":"struct ClaimBridge.OriginationTerms","name":"terms","type":"tuple"}],"name":"creditTermsHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"enableMixedInterest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"facility","outputs":[{"components":[{"internalType":"uint256","name":"classId","type":"uint256"},{"internalType":"bytes32","name":"borrowerId","type":"bytes32"},{"internalType":"bytes32","name":"stateId","type":"bytes32"},{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint16","name":"ltvBps","type":"uint16"},{"internalType":"uint16","name":"interestRateBps","type":"uint16"},{"internalType":"uint64","name":"maturity","type":"uint64"},{"internalType":"address","name":"fundingRecipient","type":"address"},{"internalType":"uint64","name":"paymentInterval","type":"uint64"},{"internalType":"uint64","name":"nextPaymentDue","type":"uint64"},{"internalType":"enum ClaimBridge.RateType","name":"rateType","type":"uint8"},{"internalType":"enum ClaimBridge.DayCountConvention","name":"dayCountConvention","type":"uint8"},{"internalType":"bool","name":"renewable","type":"bool"},{"internalType":"bytes32","name":"paymentScheduleHash","type":"bytes32"},{"internalType":"bytes32","name":"rateIndexRef","type":"bytes32"},{"internalType":"bytes32","name":"renewalTermsHash","type":"bytes32"},{"internalType":"bytes32","name":"offchainRef","type":"bytes32"},{"internalType":"enum ClaimBridge.LoanState","name":"state","type":"uint8"},{"internalType":"bool","name":"pik","type":"bool"}],"internalType":"struct ClaimBridge.Facility","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"guardian","type":"address"},{"internalType":"address","name":"upgrader","type":"address"},{"internalType":"address","name":"registry","type":"address"},{"internalType":"address","name":"oracle","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isMixedInterest","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mixedInterestEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"mixedInterestTerms","outputs":[{"components":[{"internalType":"uint16","name":"cashRateBps","type":"uint16"},{"internalType":"uint16","name":"pikRateBps","type":"uint16"},{"internalType":"uint64","name":"cashPaymentInterval","type":"uint64"},{"internalType":"uint64","name":"nextCashPaymentDue","type":"uint64"},{"internalType":"uint64","name":"pikCapitalizationInterval","type":"uint64"},{"internalType":"uint64","name":"nextPikCapitalization","type":"uint64"}],"internalType":"struct BridgeMixedInterestLib.InterestLegTerms","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mixedInterestVersion","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"modules","outputs":[{"internalType":"address","name":"registry","type":"address"},{"internalType":"address","name":"oracle","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"},{"components":[{"internalType":"uint256","name":"classId","type":"uint256"},{"internalType":"bytes32","name":"borrowerId","type":"bytes32"},{"internalType":"bytes32","name":"stateId","type":"bytes32"},{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint16","name":"ltvBps","type":"uint16"},{"internalType":"uint16","name":"interestRateBps","type":"uint16"},{"internalType":"uint64","name":"maturity","type":"uint64"},{"internalType":"address","name":"fundingRecipient","type":"address"},{"internalType":"uint64","name":"paymentInterval","type":"uint64"},{"internalType":"uint64","name":"nextPaymentDue","type":"uint64"},{"internalType":"enum ClaimBridge.RateType","name":"rateType","type":"uint8"},{"internalType":"enum ClaimBridge.DayCountConvention","name":"dayCountConvention","type":"uint8"},{"internalType":"bool","name":"renewable","type":"bool"},{"internalType":"bytes32","name":"paymentScheduleHash","type":"bytes32"},{"internalType":"bytes32","name":"rateIndexRef","type":"bytes32"},{"internalType":"bytes32","name":"renewalTermsHash","type":"bytes32"},{"internalType":"bytes32","name":"offchainRef","type":"bytes32"},{"internalType":"bool","name":"pik","type":"bool"}],"internalType":"struct ClaimBridge.OriginationTerms","name":"terms","type":"tuple"}],"name":"originate","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes32","name":"amendmentId","type":"bytes32"},{"internalType":"bytes","name":"encoded","type":"bytes"}],"name":"prepareMixedAmendment","outputs":[{"internalType":"bytes32","name":"termsHash","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"encoded","type":"bytes"}],"name":"prepareMixedOrigination","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes32","name":"termsHash","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"classId","type":"uint256"}],"name":"requiredMintAttestations","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"reserve","type":"address"}],"name":"setAccrualReserve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint64","name":"nextDue","type":"uint64"}],"name":"setAccruedPaymentDue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"registry","type":"address"}],"name":"setBorrowerPayoutRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint64","name":"nextDue","type":"uint64"}],"name":"setNextPaymentDue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"classId","type":"uint256"},{"internalType":"uint256","name":"kindsMask","type":"uint256"}],"name":"setRequiredMintAttestations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalOriginated","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"enum ClaimBridge.LoanState","name":"to","type":"uint8"}],"name":"transitionState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}],"is_changed_bytecode":false,"is_partially_verified":true,"constructor_args":null}