Authorization
Only the original seller (msg.sender at createOffer time) may cancel an offer. Any other address calling cancel with your offerId will revert with NotSeller(). There is no admin override — collateral recovery is strictly permissioned to the seller.
Function Signature
Parameters
The sequential identifier of the offer to cancel. This is the
uint256 value returned by createOffer and emitted in the OfferCreated event. Calling cancel with an offerId that belongs to a different seller, is already inactive, or has no remaining assets will revert.Effects
Whencancel succeeds, the following state changes occur atomically:
- The offer’s
assetRemainingis set to0andactiveis set tofalse— no further calls tofillon thisofferIdwill succeed. - The remaining unfilled escrowed asset balance is transferred back to the seller’s wallet.
- An
OfferCancelledevent is emitted.
Revert Conditions
| Condition | Error |
|---|---|
offerId >= nextOfferId | OfferNotFound() |
msg.sender != offer.seller | NotSeller() |
offer.active == false | OfferInactive() |
offer.assetRemaining == 0 | NothingToCancel() |
Events
assetDebited is the amount removed from escrow (the full assetRemaining). assetReceived is the net amount the seller actually receives — for fee-on-transfer asset tokens this may be slightly less than assetDebited due to transfer fees applied on the return transfer.
Partial Fill, Then Cancel
Cancellation returns whatever collateral remains after all fills. For example, if you created an offer with 500,000 tokens and 200,000 tokens were filled across one or morefill calls, cancellation returns the remaining 300,000 tokens to your wallet.
Example: Cancelling an Offer
For deferred forward offers, cancelling the offer does not invalidate already-issued claim tokens. Any buyers who received claim tokens before the cancellation retain valid, redeemable positions. They will still be able to call
redeem after the unlock time to receive their share of the collateral that was committed to their fills.