Skip to content

feat: Implement dynamic fee logic scaffolding based on pool volatility #76

@AlAfiz

Description

@AlAfiz

Description

A static 0.3% fee is great, but next-generation DEXs adjust their fees dynamically based on market volatility.
If a pool is experiencing massive, unbalanced trades, the fee should temporarily increase to protect Liquidity Providers from impermanent loss.
We need to scaffold a function that calculates a "Volatility Multiplier" based on the ratio of recent trade sizes to total reserves.
For now, we will document the logic and return a mock multiplier so the core swap math can integrate it later.

Requirements

  • Create a helper function calculate_volatility_fee_multiplier(trade_size, pool_reserve).
  • If the trade size is less than 1% of the reserve, return a multiplier of 1.0 (standard 0.3% fee).
  • If the trade size exceeds 5% of the reserve, return a multiplier of 1.5 (effectively a 0.45% fee).
  • Add detailed inline documentation explaining how this protects LPs during extreme market events.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions