Skip to content

feat: partial fill support for large market orders against limited pool depth #273

Description

@abayomicornelius

Summary

When a large market order would exceed the pool's available OI capacity (due to max_open_interest cap), the entire order currently reverts. A partial fill model would allow the order to execute up to the OI cap and queue the remainder.

Proposed Design

Add allow_partial_fill: bool to CreateOrderParams.

When true:

  • Execute up to min(requested_size, remaining_oi_capacity)
  • Store the unfilled remainder as a new pending order with the same params
  • Emit OrderPartiallyFilled { nonce, filled_size, remaining_size }

When false (default): current behaviour (revert if full size not fillable).

Acceptance Criteria

  • allow_partial_fill = true executes partial fill when OI cap is hit
  • Remainder is stored as a new order with a new nonce
  • User is refunded collateral proportional to the unfilled portion immediately
  • Integration test: order for 10 ETH, OI cap allows only 6 ETH — 6 filled, 4 refunded or queued
  • Integration test: allow_partial_fill = false still reverts when OI cap reached

Affected Contracts

order_handler, exchange_router

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions