Skip to content

feat: max position size per trader to limit protocol concentration risk #278

Description

@abayomicornelius

Summary

A single whale trader could open a position so large it dominates one side of the OI, making the pool highly directional and increasing the risk of insolvency. A per-trader max position size cap limits this concentration.

Proposed Design

Store max_position_size_usd_key(market, is_long) in data_store (admin-configurable per market side).

On every position increase, check:
current_position_size + size_delta <= max_position_size_usd

Revert with OrderError::MaxPositionSizeExceeded if violated.

A value of 0 means uncapped (default behaviour preserved).

Acceptance Criteria

  • Position increase beyond cap reverts with typed error
  • Cap of 0 allows any size (no regression)
  • Cap is enforced per trader per market per side (not global)
  • Integration test: set cap to 50,000 USD, attempt 60,000 USD position — revert
  • Integration test: two traders each with 40,000 USD positions — both succeed

Affected Contracts

order_handler, data_store

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