Skip to content

test: LP fee accrual and proportional distribution across multiple depositors #262

Description

@abayomicornelius

Goal

Verify that trading fees accumulate in the pool and are distributed proportionally to LP token holders upon withdrawal.

Scenario

  1. LP Alice deposits 10,000 USDC, receives 10,000 GM tokens
  2. LP Bob deposits 10,000 USDC, receives 10,000 GM tokens (same price, equal shares)
  3. Trader opens and closes a position, generating 200 USDC in fees
  4. Alice withdraws all 10,000 GM tokens
  5. Bob withdraws all 10,000 GM tokens

Assertions

  • Alice receives ≈10,100 USDC (10,000 principal + 100 fee share)
  • Bob receives ≈10,100 USDC
  • Total withdrawn = 20,200 USDC (20,000 principal + 200 fees)
  • GM token supply = 0 after both withdrawals
  • Pool amounts = 0

Acceptance Criteria

  • Test passes deterministically with no rounding discrepancy > 1 unit
  • Test covers case where Alice deposits before and Bob deposits after the trading fee is accrued (unequal shares)
  • File: tests/lp_fee_distribution.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