RefluxHook
Capital-efficient Uniswap v4 hook with Aave lending, JIT liquidity & leverage.
Problem Statement
RefluxHook supplies all user-provided liquidity directly into the Aave pool to continuously earn lending yield. When swaps occur, the hook instantly makes this liquidity available to Uniswap v4 using Just-In-Time (JIT) provisioning. This design allows LPs to earn both Uniswap trading fees and Aave lending yield simultaneously, while also using their liquidity positions as leveraged collateral to borrow additional funds in a single transaction via flash accounting.Built on Uniswap v4’s hook architecture, RefluxHook ensures no capital remains idle. Liquidity is always either generating yield in Aave or actively facilitating swaps. During a swap, the hook injects liquidity into the correct tick ranges, executes the trade with slippage protection, and then returns excess funds back to Aave for yield compounding.Key capabilities include:Dual Yield Streams: LPs earn trading fees from Uniswap swaps and interest from Aave lending.JIT Liquidity Windows: Liquidity is distributed dynamically across multiple tick windows, not locked to a wide or a single peak range.Leveraged Liquidity: LPs can borrow against deposited collateral and reinvest through the hook to compound positions.Flash Accounting: Lending, borrowing, swaps, and settlements are handled atomically in one transaction.Verifiable Randomness: Uniswap v4’s modifyLiquidity() requires a unique salt to derive positionIds. RefluxHook integrates Pyth entropy to generate verifiable, collision-resistant random salts, ensuring distinct position IDs, preventing replay or precomputation attacks, and securing concurrent JIT operations.Capital Efficiency by Design: Every unit of liquidity is either actively deployed in swaps or earning yield in lending pools.By merging Aave’s lending markets with Uniswap v4 JIT provisioning, RefluxHook introduces a new generation of liquidity strategies where LPs can maximize yield, unlock leverage, and maintain slippage-optimized liquidity provision.
Solution
How It’s MadeRefluxHook is a Uniswap v4 hook, integrated with the Aave lending protocol for capital-efficient liquidity management. It leverages Just-In-Time (JIT) provisioning to ensure liquidity is only active during swaps, while idle capital continuously earns yield in Aave.Core ComponentsRefluxHook.sol Inherits from BaseHook and JITPoolManager, managing the lifecycle of JIT liquidity operations. It implements the beforeSwap and afterSwap callbacks to provision and remove liquidity dynamically.LiquidityManager.sol An abstract contract that handles:Managing positions across granular tick windows.Interfacing with Aave for lending/borrowing.Flash loan logic for capital-efficient leverage.Applying leverage multipliers to liquidity updates.Aave Integration Idle liquidity is automatically deposited into Aave, earning yield. During swaps, tokens are withdrawn, temporarily deployed as JIT liquidity, and then any excess is re-supplied to Aave. LPs can also borrow against their deposited collateral and repay using either underlying assets or aTokens.JIT Logic & Flash AccountingBefore Swap (beforeSwap): The hook detects the incoming swap, computes the optimal liquidity range, and supplies JIT liquidity into the pool for execution.After Swap (afterSwap): Liquidity is withdrawn, slippage checks are enforced, and balances are reconciled with Aave in a single transaction (flash accounting).Randomness for Position IDsUniswap v4’s modifyLiquidity() requires a salt parameter to ensure unique positionIds. To avoid deterministic salts (e.g., block.timestamp) and potential collisions, we integrated Pyth Entropy as a source of verifiable randomness. This guarantees unique, collision-resistant salts, protecting against replay attacks and securing concurrent JIT updates.Technologies UsedSolidity (core smart contract logic)Foundry (local + fork testing & simulations for hook + Aave interactions)Uniswap v4 Contracts (pool manager, BaseHook, JITPoolManager, Flash Accounting)Aave V3 Contracts (lending/borrowing, aTokens)Pyth Entropy (secure verifiable randomness for salts)Notable BitsImplemented flash accounting to let LPs lend, borrow, and provide JIT liquidity atomically in a single transaction.Designed liquidity range windows so JIT liquidity isn’t placed at a single peak or overly broad range, but dynamically across multiple ranges based on current price/tick.Leveraged verifiable randomness to secure position IDs and prevent collisions, replay attacks, etc.
Hackathon
ETHGlobal New Delhi
2025
Contributors
- MukulKolpe
22 contributions
- SarveshLimaye
22 contributions