smart-contracts/backlog/tasks/task-13 - Implement-Gyrosco...

1.8 KiB

id title status assignee created_date labels dependencies references documentation priority
TASK-13 Implement Gyroscope-Style P-AMM Redemption Curve To Do
2026-04-03 21:42
solidity
gyroscope
pamm
balancer
TASK-5
/home/jeffe/Github/myco-bonding-curve/src/primitives/redemption_curve.py
/home/jeffe/Github/myco-bonding-curve/src/primitives/reserve_tranching.py
backlog/docs/GYROSCOPE_MAPPING.md
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%