Uni V3 Boosted strategy

Overview

UniV3 Boosted strategy provides a risk profile very similar to a fixed UniV3 position but with higher returns.

Consider UniV3 ETH/USDC 0.05% pool and assume we’d like to put our liquidity into the [1000, 2000] price range (we refer to it as the Domain price range). How can we do better than just providing it directly into the pool?

The trick is to put only a tiny portion of liquidity into a really narrow price range earning the same fees as direct providing. As soon as the price risks going out of the narrow range, rebalance the interval to cover the price safely.

The liquidity requirements for UniV3, in this case, are significantly lower. The rest of the liquidity can be put into some yield protocols like Yearn. Thus the overall returns are higher for the UniV3 Boosted strategy.

UniV3 Boosted strategy is a strategy for a pair of tokens X and Y, for example — WBTC/WETH or USDC/WETH. The entire capital of the strategy is divided into three parts:

  1. A special buffer vault through which all deposits, withdrawals, and rebalancings take place in the strategy to reduce gas consumption

  2. Uniswap V3 position

  3. Yield protocols (Aave/Yearn)

RootVault Structure

To implement the above capital division into parts, the system of three vaults is used:

  1. ERC20Vault - implements the logic of the special buffer vault

  2. UniV3Vault - implements UniswapV3Positon control logic

  3. AaveVault or YearnVault - implements the logic for working with yield protocols

Strategy

The idea of the strategy is to optimize a Uniswap V3 position (domain interval) by using an equally profitable Uniswap V3 position of a smaller size (short interval) and depositing the remaining tokens into yield protocols. This is based on the fact that positions with the same liquidity (in terms of Uniswap V3) receive the same fees and suffer the same impermanent losses. However, the number of tokens required for equal liquidity on a smaller interval is less. So, the remaining tokens are deposited into yield protocols, increasing final APY and reducing non-permanent losses compared to storing tokens in a domain interval on Uniswap V3.

The mathematical justification of the formulas we use here is described in this article:

Uniswap V3 Voodoo Magic Fuckery

To optimize gas consumption for interaction with the strategy, a buffer vault (named erc20Vault in our protocol) is used, the ratioParams.erc20CapitalRatioD parameter determines the fraction of capital that is normally stored in this buffer vault. The rest of the capital is distributed to the protocols according to calculated weights (for more details go to Appendix 1.).

Note: this strategy also can emulate not only the position in Uniswap V3 but also the position in Uniswap V2. To do this, it is enough to choose the widest possible domain interval.

The only problem that arises when emulating a domain interval is keeping a short interval active to receive fees from this interval. To do this, the strategy has a rebalance mechanic, which burns an inactive position and mints new, actual one.

Algorithm

The rebalance function consists of two functions: _partialRebalanceOfUniV3Position, which is optional, and _capitalRebalance, which is called every time.

rebalance:

  1. If the current price has deviated sufficiently concerning the short interval, then the strategy closes the old position and mints a new one via _partialRebalanceOfUniV3Position method:

    1. Firstly, the strategy removes all liquidity from the old position

    2. Determines the borders of the new position and mints it (with small amounts)

    3. Transfers the new position to the uniV3Vault

    4. Closes the old position

  2. Rebalancing capitals via _capitalRebalance method:

    1. Calculates current amounts of tokens on each vault

    2. Calculates expected amounts of tokens after rebalancing with the formulas above

    3. If the deviation between current amounts and expected amounts is large enough, then the following transfers are done. “enough” is determined by the actual deviation and ratioParams parameters of the strategy

    4. Pulls extra tokens from Uniswap V3 position and yield protocols compared to the expected number to erc20Vault (special buffer vault)

    5. Swaps tokens on Uniswap V3 via the SwapRouter on erc20Vault (if needed)

    6. Pulls missing (relative to expected values) tokens to Uniswap V3 position and yield protocols from erc20Vault (special buffer vault)

Note: to calculate the expected amount of tokens in uniV3 we need to know, how to convert capital (measured in token X weis) to uniV3 position amounts. The formulas for these calculations are given in Appendix 2.

Appendix 1

Below are the formulas that determine the portion of the capital that should be directed to the Uniswap V3 position (short interval) and the yield protocols for both tokens.

Appendix 2

To calculate the expected number of tokens in a Uniswap V3 position, we will use the basic Uniswap V3 equation for real tokens:

Where:

The conclusion is the following:

Parameters

Historical token prices for 2022 were used to determine strategy parameters. They were chosen as follows:

  1. the maximum daily price change was no more than halfOfShortInterval

  2. the minimum price is higher than domainLowerTick and the maximum price is less than domainUpperTick.

  • StrategyParams for the strategy WBTC/WETH:

  • StrategyParams for the strategy USDC/WETH:

  • OracleParams:

  • RatioParams:

  • MintingParams for the strategy USDC/WETH:

  • MintingParams for the strategy WBTC/WETH:

Note: tickNeighborhood could be negative as well, this means that tick should be outside of position for at least abs(tickNeighborhood) ticks to call rebalance

Risks:

  1. Profit due to better swap price:

  2. Fees paid for swap:

Last updated