Function: reduce(byte[32] asset, address account, CLOBReduceArgs args)
This function reduces the amount of an existing open limit order (or fully cancels it). This function allows the user to lower the unfilled portion of an order without changing its price, side, or leverage.
When the order is reduced, the protocol updates the order’s amount, refunds the collateral associated with the removed amount, and keeps the order live in the order book (or cancels it if the amount becomes zero).
Branches and code coverage
Intended branches
Updates
orderAmountby correct delta.Refunds the correct collateral amount (
quoteAmount* price / leverage).orderbookCollateralin the GTL contract is updated correctly.Order is fully canceled when
block.timestamp > cancelTimestampeven ifamountInBase < orderAmount.Order is fully canceled when
args.amountInBase >= orderAmount.Order is fully canceled when
orderAmount - args.amountInBase < ds.settings.minLimitOrderAmountInBase.quoteTokenOpenInterestis updated properly whenside == Side.BUY.baseTokenOpenInterestis updated properly whenside == Side.SELL.
Negative behavior
Order does not exist.
Tries to cancel again.
Account is not an order owner.
Reverts if provided
amountInBaseis greater thanorderAmount.Reverts if provided
amountInBaseis zero.