Fix auction outbid refunds with pull credits#58
Conversation
There was a problem hiding this comment.
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.
Once credits are available, push a new commit or reopen this pull request to trigger a review.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughPR Auction Bid-Credit Accounting
Sequence DiagramsequenceDiagram
participant Bidder1
participant Bidder2
participant participateToAuction
participant auctionBidderCredits
participant claimAuction
Bidder1->>participateToAuction: bid 1.0 ETH (first bid)
participateToAuction->>participateToAuction: highest = 1.0, highestBidder = Bidder1
Bidder2->>participateToAuction: bid 2.0 ETH (outbid)
participateToAuction->>auctionBidderCredits: credits[Bidder1] = 1.0
participateToAuction->>participateToAuction: highest = 2.0, highestBidder = Bidder2
participateToAuction->>participateToAuction: emit OutbidCreditCreated(Bidder1, tokenid, 1.0)
claimAuction->>participateToAuction: settle highest bid
claimAuction->>participateToAuction: pay poster, protocol, curators
claimAuction->>participateToAuction: transfer NFT to Bidder2
Bidder1->>participateToAuction: withdrawBidderCredit()
participateToAuction->>auctionBidderCredits: credits[Bidder1] = 0
participateToAuction->>Bidder1: transfer 1.0 ETH
participateToAuction->>participateToAuction: emit BidderCreditWithdrawn(Bidder1, Bidder1, 1.0)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@claude please review this PR. Focus areas:
|
|
@coderabbitai review The head moved from |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find key files
fd -e sol | head -30
fd -e sol -e md | grep -i auction | head -20Length of output: 1230 🏁 Script executed: #!/bin/bash
# Find the auction contract and test file
fd "AuctionContract.sol" --type f
fd "StreamAuctionPayments" --type f
fd "StreamAuctions" --type fLength of output: 266 🏁 Script executed: #!/bin/bash
cat smart-contracts/AuctionContract.solLength of output: 9366 🏁 Script executed: #!/bin/bash
cat test/StreamAuctionPayments.t.solLength of output: 15662
1 — No ETH call in the outbid path ✅
auctionBidderCredits[previousBidder] += previousBid;
totalBidderOwed += previousBid;A reverting 2 — Accounting consistency across all paths ✅Tracing the five paths with two bids V1 (first) and V2 (outbid):
Minor precision note (no funds at risk): In 3 —
|
| Scenario | Test |
|---|---|
| Rejecting previous bidder cannot block bid | testRejectingPreviousBidderCannotBlockHigherBid |
| Failed withdrawal preserves credit | testCreditWithdrawalFailurePreservesCredit |
| Reentrant withdrawal is blocked | testReentrantCreditWithdrawalCannotDrainMoreThanCredit |
| 1-wei underbid rejects + no credit created | testBidOneWeiBelowMinimumFailsWithoutCreditingPreviousBidder |
| Exact-minimum bid passes + credits previous | testBidExactlyAtMinimumPassesAndCreditsPreviousBidder |
| Zero and 200% increment rules | testZeroAndHighIncrementRulesAreApplied |
| Emergency cannot drain credits/escrow | testEmergencyWithdrawCannotDrainBidCreditsOrActiveBidEscrow |
| Emergency only drains surplus | testEmergencyWithdrawOnlyWithdrawsAuctionLocalSurplus |
| Settlement replay blocked + escrow released | testWithBidSettlementIsIdempotentAndReleasesActiveEscrow |
| Withdraw-to-recipient with event check | testPreviousBidderWithdrawsCreditToChosenRecipient |
All 10 tests map directly to the specified focus scenarios. One minor gap: there is no test for the zero-bid auction settlement path (the if (highestBid == 0) branch in claimAuction that transfers the NFT to retrieveExecutionAddress). Not a blocker for P0-AUCT-002 since that path has no ETH movement, but worth adding in a follow-up.
Overall: The implementation correctly eliminates the push-refund reentrancy/blocking vector, accounting invariants hold across all five paths, withdrawal is properly guarded, and emergency withdrawal cannot access protected funds. No material issues found within the stated P0-AUCT-002 scope.
|
Thanks. On the zero-bid settlement note: that path is already covered by |
|
Autonomous merge evidence for PR #58:
CodeRabbit's commit status remains pending despite the completed clean review comment and release-note update, matching the stale-status behavior already observed on PR #57. Proceeding with squash merge under the documented autonomous stale-status exception. |
Implement ADR 0002 auction custody/state-machine behavior. - mint auction drops into auction-contract escrow and register explicit auction records - add canonical auction status views, no-bid pending claims, settlement, cancellation, and auction-local proceeds credits - preserve outbid pull-credit behavior from PR #58 and add custody/payment regression tests - document state-machine, accounting, and review-fix decisions
Summary
StreamAuctionswith bidder pull credits.Closes #12.
Validation
forge test --match-contract StreamAuctionPaymentsTest -vvvpassed with 10 tests.forge test --match-contract StreamDropsIntegrationCharacterizationTest -vvvpassed with 10 tests.make checkpassed with 69 tests.powershell -NoProfile -ExecutionPolicy Bypass -File scripts\check.ps1passed with 69 tests.forge fmt --check smart-contracts\AuctionContract.sol test\StreamAuctionPayments.t.solpassed.git diff --checkpassed.slither . --config-file slither.config.json --foundry-compile-all --json <temp-file>returned expected non-zero exit because unrelated baseline findings remain; JSON showedREENTRANCY_ETH_TOTAL=0,TARGET_PARTICIPATE_TO_AUCTION=0, andAUCTION_ARBITRARY_SEND_ETH=0.Notes
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Tests
Documentation