--- id: TASK-13 title: Implement Gyroscope-Style P-AMM Redemption Curve status: To Do assignee: [] created_date: '2026-04-03 21:42' labels: - solidity - gyroscope - pamm - balancer dependencies: - TASK-5 references: - /home/jeffe/Github/myco-bonding-curve/src/primitives/redemption_curve.py - /home/jeffe/Github/myco-bonding-curve/src/primitives/reserve_tranching.py documentation: - backlog/docs/GYROSCOPE_MAPPING.md priority: medium --- ## Description Port src/primitives/redemption_curve.py (P-AMM) to Solidity as a Balancer V3 hook. P-AMM (Primary AMM) provides backing-ratio-dependent redemption pricing: - When system CR > 1: redeem at par (1:1) - When CR < 1: redeem at discount proportional to backing ratio - Prevents death spiral: redemptions at discount preserve remaining collateral for senior tranches - Integrates as Balancer V3 onBeforeSwap() hook Gyroscope reference implementation exists on mainnet — use as reference but our version is more general (not stablecoin-specific). Also port: - reserve_tranching.py — multi-vault weight targets with safety checks - imbalance_fees.py — surge fees when pool is unbalanced - dynamic_weights.py — time-varying + oracle-driven weight adjustments These compose together: P-AMM uses reserve tranche health to determine redemption pricing, imbalance fees prevent one-sided flow, dynamic weights respond to market conditions. ## Acceptance Criteria - [ ] #1 P-AMM redemption price follows backing ratio correctly - [ ] #2 Implements Balancer V3 IHooks interface - [ ] #3 Reserve tranching validates vault weight targets - [ ] #4 Imbalance fees activate when pool skews beyond threshold - [ ] #5 Matches Gyroscope test vectors within 0.01%