# `reserve()` doesn't deletes the `_isLiquidation` mapping, causing tax loss for owner in future

Flayer's reserve() fails to clear the _isLiquidation flag, so a re-listed token never refunds prepaid tax to its owner.

- Payout: Audit contest
- Severity: high
- Program: Flayer
- Found by: 0x37
- Disclosed: 2024-08-06
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/698
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-flayer%3AH-22
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:solidity vuln:accounting-error vuln:business-logic

**Target:** Listings.sol reserve()/_fillListing() liquidation flag handling
**Root cause:** reserve() does not delete _isLiquidation[_collection][_tokenId], so the flag persists after the liquidated token is reserved and re-listed, causing _fillListing to skip _resolveListingTax and forfeit the owner's tax refund.
**Steps:**
1. Liquidate a tokenId, setting _isLiquidation[collection][tokenId] = true in Listings.sol
2. Call reserve() on that tokenId and withdraw it from ProtectedListings; the flag is not cleared
3. Re-list the tokenId in Listings.sol, paying prepaid tax
4. Fill the listing via _fillListing; the `if (!_isLiquidation[...])` guard is false, so _resolveListingTax is skipped and no refund is issued
**How found:** Code reading of reserve() and _fillListing() revealed the _isLiquidation mapping is set on liquidation but never reset on reserve, so the guard permanently suppresses tax refunds for that tokenId.
**Insight:** When a boolean flag gates fee/refund logic, trace every state transition that should reset it; liquidation flags set on one path and consumed on another are a common source of stale-state accounting bugs.

## Proof of concept (copied exactly from the original report)

**reserve() missing _isLiquidation delete**

```
function reserve(address _collection, uint _tokenId, uint _collateral) public nonReentrant lockerNotPaused {
//
        // Check if the listing is a floor item and process additional logic if there
        // was an owner (meaning it was not floor, so liquid or dutch).
        if (oldListing.owner != address(0)) {
            // We can process a tax refund for the existing listing if it isn't a liquidation
            if (!_isLiquidation[_collection][_tokenId]) {
                (uint _fees,) = _resolveListingTax(oldListing, _collection, true);
                if (_fees != 0) {
                    emit ListingFeeCaptured(_collection, _tokenId, _fees);
                }
            }

            // If the floor multiple of the original listings is different, then this needs
            // to be paid to the original owner of the listing.
            uint listingFloorPrice = 1 ether * 10 ** collectionToken.denomination();
            if (listingPrice > listingFloorPrice) {
                unchecked {
                    collectionToken.transferFrom(msg.sender, oldListing.owner, listingPrice - listingFloorPrice);
                }
            }

            // Reduce the amount of listings
            unchecked { listingCount[_collection] -= 1; }
        }
//
    }
```

**_fillListing skips tax refund on liquidation flag**

```
function _fillListing(address _collection, address _collectionToken, uint _tokenId) private {
//
        if (_listings[_collection][_tokenId].owner != address(0)) {
            // Check if there is collateral on the listing, as this we bypass fees and refunds
            if (!_isLiquidation[_collection][_tokenId]) {
                // Find the amount of prepaid tax from current timestamp to prepaid timestamp
                // and refund unused gas to the user.
>                (uint fee, uint refund) = _resolveListingTax(_listings[_collection][_tokenId], _collection, false);
                emit ListingFeeCaptured(_collection, _tokenId, fee);
//
    }
```

