Bid Beasts

First Flight #49
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Valid

Wrong AuctionSettled Event in placeBid

The normal behavior is that AuctionSettled should only be emitted once the auction ends successfully, after the NFT is transferred and payment is distributed.

In the current code, AuctionSettled is incorrectly emitted inside the placeBid function before the bid is validated and before the auction is settled. This creates misleading logs and breaks off-chain tracking systems (indexers, frontends, analytics)

function placeBid(uint256 tokenId) external payable isListed(tokenId) {
...
require(msg.sender != previousBidder, "Already highest bidder");
emit AuctionSettled(tokenId, msg.sender, listing.seller, msg.value); //@> Wrongly emitted here
...
}

so call this event properly

if (listing.buyNowPrice > 0 && msg.value >= listing.buyNowPrice) {
uint256 salePrice = listing.buyNowPrice;
uint256 overpay = msg.value - salePrice;
// EFFECT: set winner bid to exact sale price (keep consistent)
bids[tokenId] = Bid(msg.sender, salePrice);
listing.listed = false;
if (previousBidder != address(0)) {
_payout(previousBidder, previousBidAmount);
}
// NOTE: using internal finalize to do transfer/payouts. _executeSale will assume bids[tokenId] is the final winner.
_executeSale(tokenId);
// Refund overpay (if any) to buyer
if (overpay > 0) {
_payout(msg.sender, overpay);
}
emit AuctionSettled(tokenId, msg.sender, listing.seller, msg.value);
return;
}

Updates

Lead Judging Commences

cryptoghost Lead Judge about 1 month ago
Submission Judgement Published
Validated
Assigned finding tags:

BidBeasts Marketplace: Incorrect Event Emission

placeBid emits AuctionSettled even though the auction hasn’t ended, causing misleading event logs.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.