Repository navigation
fix: do not credit a forwarded offer to the batch balance check - #986
Merged
Merged
Conversation
#978 stopped the per-order check crediting the fulfiller with offer items that recipientAddress sends elsewhere. #984 added a batch-wide check in the same release, and it credits the batch's whole offer unconditionally, so the same class of shortfall is still accepted on the batch path. A fulfiller holding 0.3 ERC20 who accepts two bids with a 250bp fee each owes 0.5 with the proceeds forwarded away. Each order passes the per-order check alone, and the batch check clears the total against a credit for 20 ERC20 the fulfiller never receives. It reverts on transfer.
This was referenced Aug 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while verifying
mainafter #984 and #985 merged, 18 seconds apart. Both are correct on their own; this is the gap between them.What is wrong
#978 (in #985) stopped
validateStandardFulfillBalancesAndApprovalscrediting the fulfiller with offer items thatrecipientAddressforwards to someone else. When the offer lands elsewhere, every consideration item has to come out of what the fulfiller already holds.#984 added
validateCumulativeFulfillerBalancesso a batch is checked against its total rather than order by order. It buildscumulativeReceivedAmountsfrom each order's offer unconditionally, with no knowledge ofrecipientAddress, so the batch path still credits an offer the fulfiller never receives.The two branches of the same function now disagree about whether a forwarded offer funds the fulfiller.
It is reachable
A fulfiller holding 0.3 ERC20 accepts two bids of 10 ERC20, each carrying a 250 bp fee. Each fee is 0.25, so the batch costs them 0.5.
The per-order check passes each order because 0.25 fits inside 0.3, so it never fires. The batch check then clears 0.5 against a credit of 20 ERC20 that goes to the recipient rather than the fulfiller. Measured on
mainat 4fdd176 before this change:This is not a regression from #985. Before #978 the single-order path had the same hole, and #984's batch credit is right for the ordinary case where proceeds are kept. Nothing on
mainis broken today: lint, tests and coverage are all green, and this is a fulfillment the SDK accepts that the chain will reject.Change
Hoist
offerItemsLandWithFulfiller(recipientAddress, fulfillerAddress)to the top offulfillAvailableOrdersand accumulatecumulativeReceivedAmountsonly when it holds. The per-order call site reuses the same value rather than recomputing it, so the two checks cannot drift apart again.The credit stays batch-wide when the proceeds are kept, so #984's reasoning about offer-fulfillment batches is untouched.
Tests
test/fulfill-orders-forwarded-offer.spec.ts, three cases. Reverting onlysrc/utils/fulfill.tsfails one of them, on its own assertion:The other two are controls and pass either way: a kept-proceeds batch still funds its own fees and settles at 19.8, and a single forwarded order the fulfiller can cover alone is still accepted.
npm run lintclean,npm test242 passing 0 failing, up from 239 onmain.