All projects
ArbHook
CRE-powered V4 hook - captures arbitrage, offsets impermanent loss and rewards LPs
DeFi & Tokenization
What it is
Problems being solved
Firstly I would like to mention two problems that I noticed that this combination of Uniswap v4 hooks and Chainlink CRE solves:
- Liquidity providers suffer from impermanent loss when the price of assets in their pool diverges from the market price outside the AMM. This is one of the biggest deterrents for both DeFi power users and new investors when it comes to providing liquidity, which in turn limits the potential TVL of a pool. The natural remedy for this price divergence is arbitrage — bots monitor multiple pools, profit from the price discrepancies between them and in doing so rebalance the pool's price back to market rates. While this fixes the price divergence and stops further impermanent loss from accumulating, the potential arbitrage profit is extracted from our liquidity providers.
- Most pools compete for liquidity to increase their TVL, while never giving anything of value except basic swap fees, and liquidity providers are being increasingly more selective about where they deploy capital. In my opinion CLMM's have become the norm and you need more than concentrated liquidity and a points program to compete in today's market.
My solution to this is ARBHook. Thanks to Chainlink CRE, instead of external arbitrageurs extracting value from the pool, the hook captures arbitrage opportunities itself and donates the profits back to LPs — directly offsetting their impermanent loss and increasing the value of their claim tokens. By offering this built-in protection, LPs have a concrete reason to choose this pool over a standard one, helping attract and retain liquidity, while driving higher TVL for the pool, protocol and the chain this hook is deployed on.
How it works
The ARB Hook and Chainlink CRE work together. The CRE listens to every afterSwap event that the hook emits with the new pool state. A quick calculation of the price divergence is done in afterSwap to ensure CRE computation checks are worthwhile before the event is emitted. When a swapper causes the pool price to diverge enough for an arbitrage opportunity, the Chainlink CRE executes the following steps: - Fetches the quote price of our hook pool and the other pool with the same pair. Thanks to the Uniswap V4 Quoter contract, pool fees and price impact are already included in the output.
- Fetches the ETH/USDC spot price using the CoinGecko API.
- Fetches the network gas cost on the chain the hook is deployed on.
- Calculates the potential profit and checks it against our trade threshold.
- If above, executes the trade.
Once CRE determines which pool to buy from and which to sell into, it writes to the hook contract executeArbitrage() function with the amount and direction of the trade. Inside the function the contract calls poolManager.unlock(data), which triggers the unlockCallback function. Inside this callback, the contract swaps on both pools, takes the profit, and donates it back to the hook pool's LPs in a single atomic transaction thanks to Uniswap V4's flash accounting, if arbitrage is profitable.
How it Works
Built using CRE Typescript SDK alongside Uniswap v4 hook which was created and tested in Foundry
Links
Created by
- Szymon Lyzwinski