Repository navigation
Conversation
The comment over this code already describes the intended behaviour -- the order is adjusted by "the minimum of the amount to fill and the remaining order left to be fulfilled" -- but no minimum is ever taken. unitsToFill goes into mapOrderAmountsFromUnitsToFill and getAdvancedOrderNumeratorDenominator exactly as passed. Seaport caps the fill itself. On an order with 4 of 10 units left, asking for 8 transfers 4 and closes the order. The SDK instead sizes the offer side for 8 units the offerer no longer holds, so its own balance check rejects the fill: The offerer does not have the amount needed to create or fulfill. The message points at the offerer, who is fine; the request simply ran past the remainder. The same call placed directly against the contract settles. Take the minimum the comment calls for, in both the single and batch paths. Amounts, tips and numerator/denominator are then derived from a fill that will actually happen, and the value attached to the transaction covers the units that really transfer. Only applies once an order is partially filled. Asking for more units than the order was ever divisible into is a caller error rather than a race, and getAdvancedOrderNumeratorDenominator still rejects that with its own message.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #977 +/- ##
==========================================
+ Coverage 98.27% 98.95% +0.67%
==========================================
Files 35 51 +16
Lines 14526 18603 +4077
Branches 660 992 +332
==========================================
+ Hits 14276 18408 +4132
+ Misses 245 188 -57
- Partials 5 7 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks, and yes to capping rather than raising. Matching what the contract does, and staying consistent with fulfillOrder with no unitsToFill at all, is the right call. One note on the tests. Reverting the whole source hunk removes the exported clampUnitsToRemaining, so fulfill-units.spec.ts fails at module load rather than on an assertion. Narrowing the revert to just the two call sites gives the honest answer: your four unit cases still pass, because they call the helper directly and never touch the wiring, and it is the two integration cases in fulfill-remaining-units.spec.ts that catch a regression, both failing on "The offerer does not have the amount needed to create or fulfill" exactly as you described. The unit cases are still worth having, they just cover the helper rather than the fix. This has landed in #985 with seven other contributions from the same day. Closing in favour of that one. |
The comment sitting over this code already says what should happen — the order is adjusted by "the minimum of the amount to fill and the remaining order left to be fulfilled". No minimum is ever taken.
unitsToFillreachesmapOrderAmountsFromUnitsToFillandgetAdvancedOrderNumeratorDenominatorexactly as the caller passed it.Seaport does take that minimum. On an order with 4 of 10 units left, a request for 8 transfers 4 and closes the order out. The SDK meanwhile sizes the offer side for 8 units the offerer no longer holds, and its own balance check stops the fill:
Which reads as the offerer's problem. The offerer is fine — the request just ran past the remainder. Send the same fill straight to the contract and it settles.
Repro — mint 10 units, let someone fill 6, then ask for 8:
fulfillAdvancedOrder8/10unitsToFill: 8Patch — take the minimum, in the single and batch paths both. Amounts, tips and numerator/denominator then describe a fill that will really happen, and
valuecovers the units that actually move.I went with capping rather than a new error because the contract caps, and because
fulfillOrderwith nounitsToFillat all already fills whatever is left — capping keeps an explicit request consistent with that. Worth a second opinion if you'd rather it raised.This only kicks in once an order is partially filled. Asking for more units than the order was ever divisible into is a caller mistake rather than a race, and
getAdvancedOrderNumeratorDenominatorstill rejects that with the message it has today — there's a test pinning it.Tests — four unit cases on the cap in
fulfill-units.spec.ts, andfulfill-remaining-units.spec.tsdrives the real thing end to end on both paths, assertingvalueis 4 ETH rather than 8 and that the fulfiller ends up holding all 10 units. Both integration cases fail onmainwith the error above. Suite 215.