Skip to content

test: short position opened and funded from short token (USDC) pool #264

Description

@abayomicornelius

Goal

Verify the complete lifecycle of a short position where the collateral and PnL are denominated in the short token (USDC).

Scenario

  1. LP deposits 20,000 USDC into the ETH/USD market short side
  2. Trader opens 5 ETH short at 2000 USD with 1000 USDC collateral
  3. Price moves to 1800 USD — position has 1000 USD unrealised profit
  4. Trader closes the position
  5. Trader receives 1000 USDC collateral + 1000 USDC PnL = 2000 USDC

Assertions

  • USDC pool decreases by exactly 1000 (the PnL paid out)
  • Short OI decreases to 0
  • Position removed from storage
  • No ETH pool balance changes (short uses only USDC)

Acceptance Criteria

  • Test uses the actual execute_order flow, not mocked PnL
  • Test covers the losing-short case too: price rises, trader loses collateral, pool gains
  • File: tests/short_position_lifecycle.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    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