Piro
Uniswap v4 router using live risk signals to dynamically price or block swaps.
What it is
Piro is a prediction‑informed router built on Uniswap v4. It solves the problem of static fee tiers in volatile or event‑driven markets by dynamically adjusting fees—or blocking swaps entirely—based on live risk signals. The result is safer, more adaptive liquidity provision: LPs can price tail risk in real time, and traders get clear, transparent enforcement when risk spikes.
How it works: Piro consumes two sources of truth. First, it reads an on‑chain RiskSignal contract that publishes a tier, confidence, and staleness flag. Second, it pulls the latest Polymarket probability for a defined condition. The app combines these into an effective tier: Green (normal fee), Amber (elevated fee), or Red (blocked). The UI polls these signals automatically on a timer and exposes the current tier, confidence, and freshness to users.
Swap flow: When a user swaps, Piro checks allowances and routes the swap through the Uniswap v4 Router. The effective tier determines the fee label shown and whether the swap is allowed. Green routes normally, Amber applies higher fees, and Red prevents the swap to protect liquidity during high‑risk conditions. This creates a transparent, self‑updating risk gate for swaps.
In short, Piro brings prediction‑market‑aware risk management to Uniswap v4: a simple interface, on‑chain enforcement, and dynamic fees that adapt to market stress in real time.
How it Works
olidity smart contracts (Foundry) for RiskSignal, PredictionHook (IHooks), PredictionRouter (IUnlockCallback), and RiskSignalReceiver (IReceiver). CRE TypeScript workflow using CronCapability, HTTPClient (Polymarket CLOB API), and EVMClient (writeReport). Deployed on Arbitrum Sepolia with CREATE2-mined hook address for beforeSwap permission bit. All 24 Foundry tests pass. CRE simulation succeeds end-to-end.
Links
Created by
- Fred Gitonga