Skip to content
Verified contractExactMIT

AcquisitionEscrow

Address0x2b80b2e01fabbbe09d90db448e4a26c09bae3733
Balance

0 ETH

 

Transactions

2

 

Compiler

solc 0.8.17

 

Same code

2 more contracts

 

Details

Compiler
solc 0.8.17+commit.8df45f5f
Language
solidity
Optimization
Yes, 200 runs
EVM version
london
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,192,347
Creation transaction
0x2cd85e05a5…782f59b33d

trex-src/AcquisitionEscrow.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";

interface IERC20Push {
    function balanceOf(address account) external view returns (uint256);
    function transfer(address to, uint256 amount) external returns (bool);
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

/// @notice Dedicated acquisition escrow from Derek's 2026-08-19 Phase 1 spec.
/// @dev Owner is the company Safe. No upgrade proxy.
///      On Ethereum mainnet the constructor takes an immutable USDT cap no
///      higher than MAINNET_PRE_AUDIT_MAX_USDT, and `open` refuses a deal above
///      it. That is the small-money test Derek asked for before the audit
///      (iMessage 6c865d80: small money, then an independent audit, then the
///      real deal). The audited contract is a fresh deployment with a
///      higher cap, never an upgrade of this one.
///      $MANTRA arrives from one treasury address (G, 2026-08-25) and leaves to
///      the investor on settle, or returns to that treasury on refund.
///
///      Operator recovery (G and Derek, 2026-09-23). A second address,
///      `recovery`, set at construction to the deployer that owns the
///      DaoOperator, may `pause`, `unpause` a pause it set itself, and
///      `cancel`, and nothing else. Derek (voice note 2026-09-20, iMessage
///      6c865d80): the operator controller must be able to "retrieve if they
///      fuck shit up", and "it can be voted out or whatever after the fact".
///      The owner does that with `setRecovery`: a board vote replaces the
///      recovery address or removes it (zero). Recovery cannot change itself.
///      `cancel` only ever runs the refund: USDT back to the investor who paid
///      it, MANTRA back to the treasury that funded it. So recovery can
///      unstick a deal and cannot redirect one: it cannot open, attest, fund,
///      settle, or rescue, and no path it reaches sends either token anywhere
///      but where it came from.
///
///      Accounting is internal. The deal's USDT is `usdtAmount` from `deposit`
///      until settle or refund, and the deal's MANTRA is `tokensFunded`, the
///      sum `fundTokens` pulled. `balanceOf` decides nothing, so a token sent
///      straight to the escrow cannot block settle or refund; it is residue,
///      and only `rescue` moves it, after the deal is over.
///
///      No payout blocks another. Refund pays the investor's USDT and the
///      treasury's MANTRA as two independent legs, and settle pays each
///      seller independently. A leg the token refuses (MANTRA paused, a holder
///      frozen or unverified, a USDT blacklist or pause) does not revert the
///      call: the amount is recorded in `owed` for that recipient and `claim`
///      pays it later, to that recipient only. So a paused MANTRA cannot trap
///      the investor's USDT and one blacklisted seller cannot hold up the
///      others. The investor's MANTRA on settle is the one leg that must
///      succeed: settle reverts rather than pay sellers without delivering
///      the shares.
contract AcquisitionEscrow is ReentrancyGuard {
    uint256 public constant MAX_SELLERS = 16;

    /// @notice Longest a deal may stay open: `expiresAt` is at most this far
    ///         past `open`. It bounds how long an investor's USDT can wait for
    ///         the self-refund. 180 days covers a closing window measured in
    ///         weeks (Derek named 1 October 2026 on the 2026-07-13 call, 80
    ///         days out) with room to spare.
    uint256 public constant MAX_DEAL_DURATION = 180 days;

    /// @notice `ownershipBps` is a share of the company: at most 100%.
    uint32 public constant MAX_OWNERSHIP_BPS = 10_000;

    /// @notice Highest `maxUsdtAmount` a chain-1 deployment accepts before the
    ///         independent audit: 1,000 USDT (6 decimals).
    /// @dev USDT is the one asset here nobody can claw back: $MANTRA is ERC-3643
    ///      and its agents can forcedTransfer it out of a broken escrow, USDT
    ///      has no such door. So the pre-audit exposure is the USDT one deal
    ///      can lock. 1,000 USDT is ten times the largest planned test ($10 to
    ///      $100), leaving room to repeat a test at a new price, and 0.02% of the
    ///      $4,684,000 Phase 1 deal, so the real deal cannot run through an
    ///      unaudited deployment by mistake.
    uint256 public constant MAINNET_PRE_AUDIT_MAX_USDT = 1_000e6;

    enum State {
        None,
        Open,
        Funded,
        Settled,
        Refunded
    }

    struct Seller {
        address wallet;
        uint256 usdtAmount;
    }

    struct Deal {
        address investor;
        uint256 usdtAmount;
        uint256 tokenAmount;
        uint32 ownershipBps;
        uint64 expiresAt;
        address tokenSource;
        uint8 sellerCount;
    }

    // After-funding attests the Safe sets (Derek §10 items 6, 7, 8, 10, 12).
    uint8 public constant ATTEST_INVESTOR = 1 << 0;
    uint8 public constant ATTEST_FOUNDER = 1 << 1;
    uint8 public constant ATTEST_BOARD_SEAT = 1 << 2;
    uint8 public constant ATTEST_SHARE_TRANSFER = 1 << 3;
    uint8 public constant ATTEST_CLOSING_DOCS = 1 << 4;
    uint8 public constant ATTEST_ALL =
        ATTEST_INVESTOR | ATTEST_FOUNDER | ATTEST_BOARD_SEAT | ATTEST_SHARE_TRANSFER | ATTEST_CLOSING_DOCS;

    address public immutable owner;
    IERC20Push public immutable usdt;
    IERC20Push public immutable mantra;
    /// @notice Largest `usdtAmount` `open` accepts. Fixed at construction.
    uint256 public immutable maxUsdtAmount;

    /// @notice The operator's key: pause, unpause its own pause, cancel. The
    ///         owner replaces or removes it with `setRecovery`. Zero means
    ///         removed.
    address public recovery;

    State public state;
    bool public paused;
    /// @notice Who set the current pause. The owner lifts any pause; the
    ///         recovery address lifts only a pause it set itself.
    address public pausedBy;
    bool public legalDocsComplete;
    uint8 public attests;
    Deal public deal;
    mapping(uint256 => Seller) public sellers;

    /// @notice The deal's MANTRA received through `fundTokens`. Settle
    ///         delivers exactly this and refund returns exactly this.
    uint256 public tokensFunded;

    /// @notice token => recipient => amount a settle or refund leg could not
    ///         transfer. Only `claim` pays it, and only to that recipient.
    mapping(address => mapping(address => uint256)) public owed;
    /// @notice token => sum of `owed` across recipients. `rescue` cannot
    ///         touch it.
    mapping(address => uint256) public totalOwed;

    event Opened(
        address indexed investor,
        uint256 usdtAmount,
        uint256 tokenAmount,
        uint32 ownershipBps,
        uint64 expiresAt,
        uint8 sellerCount
    );
    event LegalDocsAttested();
    event Funded(address indexed investor, uint256 usdtAmount);
    event TokensFunded(address indexed source, uint256 tokenAmount);
    event Attested(uint8 flag, uint8 attests);
    event Paused(address indexed by);
    event Unpaused(address indexed by);
    event Settled(address indexed investor, uint256 tokenAmount, uint256 usdtAmount);
    /// @notice The refund's amounts. A leg the token refused is also in
    ///         `PaymentDeferred` and waits for `claim`.
    event Refunded(address indexed investor, uint256 usdtAmount, address tokenSource, uint256 tokenAmount);
    /// @notice `cancel` ran; `by` is the owner or the recovery address.
    event Cancelled(address indexed by);
    /// @notice A settle or refund leg the token refused; now in `owed`.
    event PaymentDeferred(address indexed token, address indexed to, uint256 amount);
    /// @notice An `owed` amount reached its recipient.
    event Claimed(address indexed token, address indexed to, uint256 amount);
    /// @notice The owner moved residue after the deal ended.
    event Rescued(address indexed token, address indexed to, uint256 amount);
    /// @notice The owner replaced or removed (`current` zero) the recovery address.
    event RecoveryChanged(address indexed previous, address indexed current);

    error CapOutOfRange(uint256 usdtCap, uint256 ceiling);
    error AboveCap(uint256 usdtAmount, uint256 maxUsdtAmount);
    error InvalidOwner();
    error InvalidRecovery();
    error InvalidToken();
    error NotOwner();
    error InvalidInvestor();
    error InvalidSeller();
    error InvalidAmount();
    error InvalidExpiry();
    error TooManySellers();
    error SellerSumMismatch();
    error DuplicateSeller();
    error WrongState(State have, State want);
    error LegalDocsIncomplete();
    error WrongWallet();
    error WrongAmount();
    error PausedDeal();
    error AlreadyPaused(address pausedBy);
    error NotPaused();
    error NotPauser(address pausedBy);
    error Expired();
    error NotExpired();
    error ChecksIncomplete(uint8 have);
    error TokensMissing();
    error TransferFailed(address token, address to, uint256 amount);
    error NothingToRescue();
    error NothingOwed(address token, address to);
    error InsufficientGas();

    modifier onlyOwner() {
        if (msg.sender != owner) revert NotOwner();
        _;
    }

    modifier onlyOwnerOrRecovery() {
        if (msg.sender != owner && msg.sender != recovery) revert NotOwner();
        _;
    }

    /// @param recoveryAddress The operator key that may pause, unpause its own
    ///        pause, and cancel. Never zero at construction and never the
    ///        owner. On Ethereum it is the deployer that owns the DaoOperator
    ///        (DeployAcquisitionEscrow enforces that).
    /// @param usdtCap Largest deal this escrow will open, in USDT base units.
    ///        Chain 1: 1 to MAINNET_PRE_AUDIT_MAX_USDT. Elsewhere: any nonzero
    ///        value, type(uint256).max for no cap.
    constructor(address safe, address recoveryAddress, address usdtToken, address mantraToken, uint256 usdtCap) {
        if (usdtCap == 0 || (block.chainid == 1 && usdtCap > MAINNET_PRE_AUDIT_MAX_USDT)) {
            revert CapOutOfRange(usdtCap, block.chainid == 1 ? MAINNET_PRE_AUDIT_MAX_USDT : type(uint256).max);
        }
        if (safe == address(0)) revert InvalidOwner();
        if (recoveryAddress == address(0) || recoveryAddress == safe) revert InvalidRecovery();
        if (usdtToken == address(0) || mantraToken == address(0) || usdtToken == mantraToken) {
            revert InvalidToken();
        }
        owner = safe;
        recovery = recoveryAddress;
        usdt = IERC20Push(usdtToken);
        mantra = IERC20Push(mantraToken);
        maxUsdtAmount = usdtCap;
    }

    function open(
        address investor,
        uint256 usdtAmount,
        uint256 tokenAmount,
        uint32 ownershipBps,
        uint64 expiresAt,
        address[] calldata sellerWallets,
        uint256[] calldata sellerAmounts
    ) external onlyOwner {
        if (state != State.None) revert WrongState(state, State.None);
        // An investor holding the recovery key could cancel and take the USDT
        // back before expiry, which the deal otherwise refuses them.
        if (investor == address(0) || investor == owner || investor == recovery) revert InvalidInvestor();
        if (usdtAmount == 0 || tokenAmount == 0 || ownershipBps == 0 || ownershipBps > MAX_OWNERSHIP_BPS) {
            revert InvalidAmount();
        }
        if (usdtAmount > maxUsdtAmount) revert AboveCap(usdtAmount, maxUsdtAmount);
        if (expiresAt <= block.timestamp || expiresAt > block.timestamp + MAX_DEAL_DURATION) revert InvalidExpiry();
        if (sellerWallets.length == 0 || sellerWallets.length > MAX_SELLERS) revert TooManySellers();
        if (sellerWallets.length != sellerAmounts.length) revert InvalidSeller();

        uint256 sum = 0;
        for (uint256 i; i < sellerWallets.length; ++i) {
            address wallet = sellerWallets[i];
            uint256 amount = sellerAmounts[i];
            // A seller that is the escrow or one of its tokens would be paid
            // into a contract that cannot spend it.
            if (
                wallet == address(0) || wallet == investor || wallet == address(this) || wallet == address(usdt)
                    || wallet == address(mantra) || amount == 0
            ) revert InvalidSeller();
            for (uint256 j; j < i; ++j) {
                if (sellerWallets[j] == wallet) revert DuplicateSeller();
            }
            sellers[i] = Seller({wallet: wallet, usdtAmount: amount});
            sum += amount;
        }
        if (sum != usdtAmount) revert SellerSumMismatch();

        deal = Deal({
            investor: investor,
            usdtAmount: usdtAmount,
            tokenAmount: tokenAmount,
            ownershipBps: ownershipBps,
            expiresAt: expiresAt,
            tokenSource: address(0),
            sellerCount: uint8(sellerWallets.length)
        });
        state = State.Open;
        emit Opened(investor, usdtAmount, tokenAmount, ownershipBps, expiresAt, uint8(sellerWallets.length));
    }

    function attestLegalDocs() external onlyOwner {
        if (state != State.Open && state != State.Funded) revert WrongState(state, State.Open);
        legalDocsComplete = true;
        emit LegalDocsAttested();
    }

    function deposit() external nonReentrant {
        if (state != State.Open) revert WrongState(state, State.Open);
        if (paused) revert PausedDeal();
        if (!legalDocsComplete) revert LegalDocsIncomplete();
        if (msg.sender != deal.investor) revert WrongWallet();
        if (block.timestamp > deal.expiresAt) revert Expired();

        state = State.Funded;
        uint256 before = usdt.balanceOf(address(this));
        _pull(address(usdt), msg.sender, deal.usdtAmount);
        // Refuses a fee-on-transfer USDT: Funded must mean usdtAmount held.
        if (usdt.balanceOf(address(this)) - before != deal.usdtAmount) revert WrongAmount();
        emit Funded(msg.sender, deal.usdtAmount);
    }

    function fundTokens(address source, uint256 amount) external nonReentrant onlyOwner {
        if (state != State.Open && state != State.Funded) revert WrongState(state, State.Funded);
        if (source == address(0) || source == deal.investor || source == address(this)) revert InvalidSeller();
        if (amount == 0) revert InvalidAmount();
        if (tokensFunded + amount > deal.tokenAmount) revert WrongAmount();
        if (deal.tokenSource == address(0)) {
            deal.tokenSource = source;
        } else if (deal.tokenSource != source) {
            revert InvalidSeller();
        }

        tokensFunded += amount;
        uint256 before = mantra.balanceOf(address(this));
        _pull(address(mantra), source, amount);
        if (mantra.balanceOf(address(this)) - before != amount) revert WrongAmount();
        emit TokensFunded(source, amount);
    }

    function attest(uint8 flag) external onlyOwner {
        if (state != State.Funded) revert WrongState(state, State.Funded);
        if (flag == 0 || (flag & ATTEST_ALL) != flag || (flag & (flag - 1)) != 0) revert InvalidAmount();
        attests = attests | flag;
        emit Attested(flag, attests);
    }

    /// @notice Stops deposit and settle. The owner may take over a pause the
    ///         recovery address set, so only the board can lift it; recovery
    ///         cannot re-pause over the board's pause to make it its own.
    function pause() external onlyOwnerOrRecovery {
        if (state == State.Settled || state == State.Refunded) revert WrongState(state, State.Funded);
        if (paused && (msg.sender != owner || pausedBy == owner)) revert AlreadyPaused(pausedBy);
        paused = true;
        pausedBy = msg.sender;
        emit Paused(msg.sender);
    }

    /// @notice The owner lifts any pause. The recovery address lifts only a
    ///         pause it set itself: a board pause needs the board.
    function unpause() external onlyOwnerOrRecovery {
        if (!paused) revert NotPaused();
        if (msg.sender != owner && msg.sender != pausedBy) revert NotPauser(pausedBy);
        paused = false;
        pausedBy = address(0);
        emit Unpaused(msg.sender);
    }

    /// @notice Replace the recovery address, or remove it with zero. A board
    ///         vote, since the owner is the board Safe. Recovery cannot call
    ///         this, so it cannot keep or pass on its own power.
    function setRecovery(address newRecovery) external onlyOwner {
        if (newRecovery == owner || (newRecovery != address(0) && newRecovery == deal.investor)) {
            revert InvalidRecovery();
        }
        emit RecoveryChanged(recovery, newRecovery);
        recovery = newRecovery;
    }

    function settle() external nonReentrant onlyOwner {
        if (state != State.Funded) revert WrongState(state, State.Funded);
        if (paused) revert PausedDeal();
        if (block.timestamp > deal.expiresAt) revert Expired();
        if (!legalDocsComplete) revert LegalDocsIncomplete();
        if (attests != ATTEST_ALL) revert ChecksIncomplete(attests);
        if (tokensFunded != deal.tokenAmount) revert TokensMissing();

        state = State.Settled;
        // The shares must arrive: a settle that pays the sellers without
        // delivering the MANTRA is the one outcome this contract refuses.
        _push(address(mantra), deal.investor, deal.tokenAmount);

        uint8 count = deal.sellerCount;
        for (uint256 i; i < count; ++i) {
            Seller memory seller = sellers[i];
            _pay(address(usdt), seller.wallet, seller.usdtAmount);
        }

        emit Settled(deal.investor, deal.tokenAmount, deal.usdtAmount);
    }

    /// @notice Unwind the deal to where each token came from. The owner or
    ///         the recovery address, any time before settle.
    function cancel() external nonReentrant onlyOwnerOrRecovery {
        _refund();
        emit Cancelled(msg.sender);
    }

    /// @notice The investor's exit: after expiry, or at once while the deal
    ///         is paused, so a dark Safe cannot trap the USDT. The owner may
    ///         call it too.
    function refund() external nonReentrant {
        if (msg.sender != owner && msg.sender != deal.investor) revert NotOwner();
        if (msg.sender == deal.investor && block.timestamp <= deal.expiresAt && !paused) {
            revert NotExpired();
        }
        _refund();
    }

    /// @notice Pays an amount a settle or refund leg could not, once the token
    ///         allows it. Anyone may call: it only ever pays `to`, the
    ///         recipient the leg was owed to, and reverts (owing it still)
    ///         while the token still refuses.
    function claim(address token, address to) external nonReentrant {
        uint256 amount = owed[token][to];
        if (amount == 0) revert NothingOwed(token, to);
        owed[token][to] = 0;
        totalOwed[token] -= amount;
        _push(token, to, amount);
        emit Claimed(token, to, amount);
    }

    function readyToClose() public view returns (bool) {
        return state == State.Funded && !paused && legalDocsComplete && attests == ATTEST_ALL
            && block.timestamp <= deal.expiresAt && tokensFunded == deal.tokenAmount;
    }

    function afterFundingChecks() external view returns (bool[14] memory checks) {
        Deal memory d = deal;
        bool settled = state == State.Settled;
        checks[0] = state == State.Funded || settled;
        // Funded means `deposit` pulled exactly usdtAmount.
        checks[1] = state == State.Funded || settled;
        checks[2] = address(usdt) != address(0);
        checks[3] = state == State.Funded;
        checks[4] = state != State.None;
        checks[5] = (attests & ATTEST_INVESTOR) != 0;
        checks[6] = (attests & ATTEST_FOUNDER) != 0;
        checks[7] = (attests & ATTEST_BOARD_SEAT) != 0;
        checks[8] = d.sellerCount > 0;
        checks[9] = (attests & ATTEST_SHARE_TRANSFER) != 0;
        checks[10] = tokensFunded == d.tokenAmount;
        checks[11] = (attests & ATTEST_CLOSING_DOCS) != 0;
        checks[12] = state != State.Refunded;
        checks[13] = block.timestamp <= d.expiresAt;
    }

    /// @notice Residue after the deal is terminal: a token sent straight to
    ///         the escrow, or any wrong token. Owner only.
    /// @dev It cannot reach the deal's own funds. While the deal is Open or
    ///      Funded it reverts. A terminal deal has paid out every deal token
    ///      or recorded it in `owed`, and `rescue` leaves `totalOwed` alone.
    function rescue(address token, address to, uint256 amount) external nonReentrant onlyOwner {
        if (state != State.Settled && state != State.Refunded) revert WrongState(state, State.Settled);
        if (to == address(0) || amount == 0) revert InvalidAmount();
        if (IERC20Push(token).balanceOf(address(this)) < totalOwed[token] + amount) revert NothingToRescue();
        _push(token, to, amount);
        emit Rescued(token, to, amount);
    }

    function _refund() internal {
        if (state != State.Open && state != State.Funded) revert WrongState(state, State.Funded);
        // Recorded amounts only. MANTRA with no recorded treasury never came
        // through fundTokens, so tokensFunded is zero and it stays for
        // rescue; so does USDT sent before the deposit.
        uint256 usdtBack = state == State.Funded ? deal.usdtAmount : 0;
        uint256 tokensBack = tokensFunded;
        address investor = deal.investor;
        address source = deal.tokenSource;

        state = State.Refunded;

        // Two independent legs: a MANTRA leg the token refuses (paused,
        // frozen, unverified treasury) must not keep the investor's USDT.
        if (usdtBack > 0) {
            _pay(address(usdt), investor, usdtBack);
        }
        if (tokensBack > 0) {
            _pay(address(mantra), source, tokensBack);
        }
        emit Refunded(investor, usdtBack, source, tokensBack);
    }

    /// @dev Transfers, or records the amount in `owed` when the token refuses.
    function _pay(address token, address to, uint256 amount) internal {
        if (_tryPush(token, to, amount)) return;
        owed[token][to] += amount;
        totalOwed[token] += amount;
        emit PaymentDeferred(token, to, amount);
    }

    function _pull(address token, address from, uint256 amount) internal {
        (bool ok, bytes memory data) =
            token.call(abi.encodeWithSelector(IERC20Push.transferFrom.selector, from, address(this), amount));
        if (!ok || (data.length != 0 && !_asBool(data))) {
            revert TransferFailed(token, address(this), amount);
        }
    }

    function _push(address token, address to, uint256 amount) internal {
        if (!_tryPush(token, to, amount)) revert TransferFailed(token, to, amount);
    }

    function _tryPush(address token, address to, uint256 amount) internal returns (bool) {
        uint256 gasBefore = gasleft();
        (bool ok, bytes memory data) = token.call(abi.encodeWithSelector(IERC20Push.transfer.selector, to, amount));
        if (ok && (data.length == 0 || _asBool(data))) return true;
        // EIP-150 keeps back 1/64 of the gas, so a transfer that ran out of
        // gas also lands here. Without this check a caller could pick a gas
        // limit that fails a leg on purpose and defers a payment the token
        // would have made. A refusal returns with almost all the gas left.
        if (gasleft() < gasBefore / 63) revert InsufficientGas();
        return false;
    }

    function _asBool(bytes memory data) private pure returns (bool) {
        if (data.length != 32) return false;
        return abi.decode(data, (bool));
    }
}

lib/openzeppelin-contracts-4/contracts/security/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "london",
  "remappings": [
    "forge-std/=lib/forge-std/src/",
    "@onchain-id/solidity/=lib/onchain-id/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts-4/contracts/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable-4/contracts/",
    "erc-3643/=lib/erc-3643/contracts/",
    "onchain-id/=lib/onchain-id/contracts/",
    "openzeppelin-contracts-4/=lib/openzeppelin-contracts-4/",
    "openzeppelin-contracts-upgradeable-4/=lib/openzeppelin-contracts-upgradeable-4/",
    "openzeppelin/=lib/openzeppelin-contracts-4/contracts/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.