After talking with many Uniswap V3 LPs during 2022 one of the most often heard things were to the effect of:
I have 5000 USDC and I want to add them to my ETH/OP position. To do that I end up doing two or even three swaps, some in opposing directions, and even after that, I am left with change and just give up.
Indeed, that is a pain point we’ve felt as well, and have built a solution for.
One of the challenges in adding liquidity to existing positions on Uniswap v3 is getting the assets you want to add to the correct ratio required. This is because the price of the assets is constantly changing, and the correct ratio is dependent on the current price of the pool as well as the position range. And if you are swapping into the same pool with sufficient price impact, the calculations get even more tricky.
Using Revert you can now add liquidity to an existing position using any amounts of the underlying assets, or even any third arbitrary token. Revert will automatically compute the required amounts that need to be swapped for each of the token pair assets, get the best possible quote using the 0x API, and atomically do the swap and add the liquidity to your positions.
We’ll conveniently do the same in the way out if you want do “withdraw and swap” or “collect fees and swap” for any mounts into either one of the assets or again an arbitrary third token.
This all happens atomically on-chain, we are making use of v3utils.sol, a contract we have published for this purpose, and the 0x protocol to handle any required swaps, so for LPs can confidently use this functionality even when they are providing liquidity for relatively small pools.
We have implemented three basic operations defined by v3utils contract.
Swap and Increase liquidity: Takes any amount of token0, token1, or a third arbitrary token and a Uniswap v3 position NFT. It will swap the tokens into the correct amounts according to parameters passed given the position range, pool price, 0x quotes, and max slippage parameters, perform any required swaps, add the swapped tokens into the Uniswap position and return the NFT to the user.
Decrease liquidity and swap: Is the inverse operation, given a Uniswap position NFT and a desired output token, which does not require to be any of the underlying assets, it will decrease liquidity by the amount indicated by the user and perform the swap as defined by the 0x API, and max slippage parameters, and finally return to the calling user the output of the swap(s) as well as the position NFT. It can be performed by any amount of liquidity contained by the position.
Claim fees and swap: This one, similarly, allows users to collect any amount of uncollected fees on their Uniswap v3 position and atomically swap them into any arbitrary token. Returning, at the end of the operation, the output of the swaps as well as position NFT with the underlying liquidity untouched.
And obvious missing piece here is this same idea of atomically swapping any asset into a determined Uniswap position, but instead of increasing liquidity on an existing position, create a new position that you don’t already hold. Fret not, we are on it, testing, and expect to ship it out in a few more days fully integrated to the revert initiator.
The features described above are already available on the site and across all chains. We are looking forward to your comments and feedback as you try them out. Follow us on Twitter or drop in on our Discord to stay updated.