
Flow-fi
A Uniswap v4 hook that detects MEV and redistributes it to loyal, long-term LPs.
Demo
About
Flow-Fi is a DeFi protocol that flips the economics of MEV extraction on Uniswap v4. Today, liquidity providers routinely lose value to sandwich attacks and JIT (just-in-time) liquidity — where sophisticated actors insert liquidity right before a large trade to capture fees, then withdraw immediately after, without bearing any of the real risk long-term LPs take on. Flow-Fi is built as a Uniswap v4 hook that detects these patterns in real time and imposes dynamic fee surcharges on the actors causing them, rather than letting that value simply disappear from the pool. The captured surcharge revenue isn't just refunded generically — it's redistributed through Flow-Fi, a tenure-weighted rewards system inspired by vote-escrow tokenomics. LPs who commit their liquidity for longer periods earn a proportionally larger share of the redistributed MEV, which directly disincentivizes the flash-in, flash-out behavior that JIT liquidity depends on. In effect, Flow-Fi realigns incentives so that patient, genuine liquidity providers are rewarded at the expense of extractive short-term actors. To make this practical at scale, Flow-Fi uses epoch-based reward accounting (smoothing distributions over time instead of settling every block) and a Merkle proof architecture for claims, so LPs can verify and withdraw their share efficiently without the contract needing to iterate over every participant on-chain.
How it's made
Flow-Fi is built as a Uniswap v4 hook in Solidity, leveraging v4's hook architecture to intercept swaps in real time rather than relying on external monitoring or off-chain bots. The core detection logic identifies sandwich attacks and JIT (just-in-time) liquidity provisioning by analyzing transaction patterns within the same block, then triggers dynamic fee surcharges on detected MEV activity instead of letting that value leak to searchers. The redistribution layer uses Flow-Fi, a tenure-weighted staking model (similar in spirit to vote-escrow tokenomics) so LPs who commit liquidity longer earn a larger share of the surcharge pool — discouraging the flash-liquidity behavior that JIT strategies rely on. Reward accounting is epoch-based, smoothing payouts over time rather than distributing per-block, which avoids reward spikes and reduces gas overhead from frequent claims. For verifiability, reward proofs use a Merkle tree architecture, letting LPs claim their share with a lightweight on-chain proof rather than requiring the contract to iterate over all participants — a common gas-optimization pattern for reward distribution at scale.