Onchain impermanent loss insurance for Uniswap V3/V4 liquidity providers
UniHedge is an advanced DeFi solution tailored for Uniswap liquidity providers. One of the innate challenges faced by liquidity providers is impermanent loss (IL), particularly when the market price of a provided asset deviates from its initial price. IL can result in significant losses, especially in volatile markets. UniHedge addresses this challenge head-on by utilizing a portion of the provided liquidity to initiate a short position against the volatile asset. This strategic move acts as a hedge, ensuring that if the asset's value drops, the losses are counterbalanced by the gains from the short position. By incorporating this hedging mechanism, UniHedge offers liquidity providers a safety net, safeguarding their asset value during times of volatile market conditions.
UniHedge leverages the power of smart contracts of Uniswap V3, Uniswap V4 hooks, and the Aave V3 lending protocol to implement its core features. The underlying code is designed to allocate a portion of the provided liquidity to open a short position on Aave V3 against the volatile asset. This hedging action is automated and designed to be in proportion to the perceived risk, ensuring optimal asset protection. The short position serves as a countermeasure, so if the asset's value decreases, the gains from the short position help offset the losses. By intertwining lending protocols and advanced market analytics, UniHedge provides a holistic approach to manage and mitigate the risks associated with AMM liquidity provisioning. It also includes a Uniswap V4 hook feature, which is a critical component that triggers the auto-closure of positions once the market price hits the limits of the hedged range. We wrote all the smart contracts in Solidity. We rely extensively on Uniswap's TickMath library as well as using the PRB-V3 math library for occasional computations.