Description: Upgrade the AMM logic from a fixed 0.3% swap fee to a dynamic fee model that increases during times of high market volatility and decreases during stable periods.
Context / Motivation: Fixed fees often fail to compensate LPs adequately during high-volatility events, leading to impermanent loss. A dynamic fee curve protects LPs and optimizes volume during calm periods.
Acceptance Criteria: - [ ] Implement a volatility oracle based on recent trade sizes and price impacts over the last N ledgers.
Description: Upgrade the AMM logic from a fixed 0.3% swap fee to a dynamic fee model that increases during times of high market volatility and decreases during stable periods.
Context / Motivation: Fixed fees often fail to compensate LPs adequately during high-volatility events, leading to impermanent loss. A dynamic fee curve protects LPs and optimizes volume during calm periods.
Acceptance Criteria: - [ ] Implement a volatility oracle based on recent trade sizes and price impacts over the last N ledgers.
MIN_FEE(0.1%) andMAX_FEE(1.0%) based on the volatility metric.swapentrypoint.Technical Pointers: You will need to maintain a moving average of recent price shifts in
instanceorpersistentstorage. Keep the math lightweight to avoid exceeding Soroban's instruction limits.