The Uniswap V4 Hook (Yield Harvesting Hook)
Vault Wrappers
Vault wrappers are ERC4626 vaults that have a lending protocol token as the underlying asset. Vault wrapper tokens are always 1:1 with the underlying asset.
When you lend to a lending protocol (x), it usually gives you xTokens as a receipt token whose value keeps increasing as interest accrues. Providing liquidity with these xTokens is not attractive because the price of xTokens keeps changing (increasing due to interest accrual) even without any swaps. Unless you rebalance every second, all of the interest gets captured by MEV bots.
That is why we have developed vault wrappers. The vault wrappers take xTokens and issue VII-xTokens in return. These VII-xTokens are always issued 1:1 to the underlying asset. The interest accrual that happens in xTokens held by VII vault wrappers is distributed to Liquidity Providers by increasing the total supply and donating it to the active Liquidity Providers of the pool.
This means that all existing strategies for vanilla pools work seamlessly with these pools as well. Also, Liquidity Providers don't lose their interest to MEV bots.
We have developed vault wrappers for ERC4626 vaults where interest is distributed by increasing the token value, and also for aToken-like tokens where interest is distributed by increasing the user balance.
Vault Wrappers Factory
Pool initialization always happens through the vault wrappers factory. For each type of vault, the vault wrappers factory deploys the vault wrappers and initializes the Uniswap V4 pool with the yield harvesting hook.
Yield Harvesting Hook
The yield harvesting hook keeps all of the liquidity provision accounting and swap logic the same. Only before swap, add liquidity, and remove liquidity operations, it ensures that the interest accrued so far in the vault wrappers is donated to active liquidity providers of the pool. Additionally, before initialization of the pool, it ensures that only the vault wrappers factory can initialize a pool with this hook.
The advantage of harvesting before each operation is that Liquidity Providers receive the interest accrual in the form of fees, without JIT liquidity providers benefiting from it.