An UniSwap v3 defi tool suite for concentrated liquidity strategies
UniSwap launched its version 3 on May 3rd and reached 700MM daily volume in one month, and greatly increases its utility as the LPs are able to create strategic liquidity provision in order to maximize yields. With the upcoming Arbitrum ETH Layer-2 implementation, UniSwap is expected to challenge the volume of centralized orderbooks exchanges such as Binance/OKex/FTX. However, traditional market makers on current centralized exchanges lack the tools to enter the defi-space.
Teahouse.finance aims to provide an ease-of-mind smart contract interface between UniSwap/Perpetual Protocol Curie and fund managers, where managers may not only develop their strategies off-chain to avoid front-running, but also raise, manage, and payout ETFs on-chain as custodians.
Measuring the Profitability of Strategies
The concentrated liquidity feature of Uniswap enables LPs to customize their active strategies as market makers in DEX. Due to current high-fees, constructing strategies for liquidity provision has been focused on passive, on-chain, and wide price ranges.
teahouse.finance has developed an UniSwap stimulator to calculate every identifiable smart-contract positions on-chain. To measure the profitability of each strategy, teahouse established the coefficient of profitability, which is the coverage rate divided by the average width of liquidity provision price range. In general, the superior strategy will have the more "hit rate", where the spot price is "in-range", corresponding to a narrower range. Teahouse is able to track the time-weighted average coverage of an existing liquidity strategy, Alpha Vault, and calculate the effectiveness of its strategies with the entire 90822 swaps to date (07/10/2011) in ETH/USDC v3 pool.
Alpha Vault Position Analysis
time weighted average coverage (*)
average coefficient (**)
(*) share of swaps hit the positions when it’s active (liquidity > 0) weighted by timespan of the positions in active state
(**) the coefficient of profitability equals coverage divided by tick width
The results show that a passive on-chain strategy isn't quite effective and it is exploitable to front-running.
Constructing an Active Liquidity Provision Strategy
It is understandable that current strategies are passive due to high-fees, however, in order to adapt to the upcoming Arbitrium Implementation and to profit catching, an active liquidity strategy is expected. Teahouse's goal is to produce a reinforced model from the history data collected and backtest with the stimulation constructed below. Instead of hypothesis testing the utility function, we choose to observe the empirical price movement to construct the dynamic price range strategy to optimize yield for the low-gas-fee environment of ETH Layer-2.
The idea starts from decomposing the transactions of UniSwaps, and calculating the Gaussian processes of spot prices to predict the price range with stochastic standard variation. The preliminary result of constructing our flagship strategy shows that the preset price range covers 90% of the spot price with resetting the price range 12% of times, however, to reduce the resetting times, we have to adjust the width of our price range and produce the best-overall condition for our strategy.
Preliminary Results for Teahouse In-House Strategy
The result is back-tested on 70 days’ transections of ETH/USDC pool.
The Dots are the swap price. The Green parallel lines are the upper and lower bound of the price range, and the Blue lines are the time the strategy resets its range.
The preliminary result shows that In-House Strategy covers 83.67% of the spot price and the average width is 106.381 ticks, the coefficient of profitability is 0.00786540918, which is 20x better than passive strategies.
The result opens the world of wonders for active liquidity provision strategies. In the future one may utilize reinforced learning to predict the spot price better, and leverage 10x with Curie to maximize yields.
A Platform for All Strategies
To embrace the low-fee L2 implementation, the active liquidity provision strategies will certainly bloom. Teahouse is also opening up the tool suite for fund managers to raise, manage, and payout ETFs on-chain as custodians.
Uniswap V3 Trading History Database
Teahouse is able to retrieve all trading events (swaps) from an Uniswap V3 pool, including mint (add position), burn (remove position), swap (trade), flash (flash loan), and collect (collecting fees). These informations can be used to validate models predicting how profitable a position will be from past swap history, and also can be used for training new models.
Track Every Swap
Uniswap V3 Simulator
Teahouse uses data from Uniswap V3 trading history to calculate each vault’s performance: The profit of each position can be calculated when one can imagine "burn 0" in the smart-contract stimulator, hence the price can be monitored within a preset range. The large trade can also be separated into smaller ones to avoid price slippage.
As the strategies may be off-chain to avoid front-running, the vaults have to be on-chain as custodian to ensure fund managers from rug-pulling. Teahouse provides a smart contract for fund managers to accept liquidity from investors, in which equips a backend to operate the smart contract to adjust positions on and within a Uniswap V3 pool.
Because the strategy is controlled from an off-chain backend, it can be adjusted any time, have complex computations, and reference from more data. Off-chain backend can only adjust positions and not retrieve liquidities from the smart contract, so users’ funds can’t be ‘stolen’ from the smart contract.
Teahouse also provides two type of ETF models for fund mangers to raise:
Fixed Investment Model
A fund with a fixed total investment amount. It has an “ICO” period, where funds are collected, with corresponding amounts of ERC20 fund coins delivered to the investors. The fund is then managed using the strategy vault. After a preset period of time, such as 6 months, the fund is concluded, and the fund coins can be used to redeem the investments and profits. The fund coins can be freely exchanged so the ownership of the investment can be transferred.
ICO period: receiving investments based on a stable coin (e.g. USDT). Fund coins are initially pegged to the stable coin.
Strategy vault period: the received stable coins are exchanged into the underlying Uniswap V3 tokens (e.g. to BTC and ETH for BTC/ETH pool). Fund coin values are calculated as the current total fund value (value of all positions combined) divided by the total amount of fund coins. Fund coins might also have a separate market value depending on how the market views the future of the fund.
Fund conclusion: all positions are liquidated and exchanged back to the original stable coin. Investors use the fund coin to redeem their investments.
(Optionally) Fund restart: investors may opt to join another round of the fund using their fund coin in exchange for new fund coins of the next round. They might be charged with a smaller fee as an incentive. Timing can be arranged so the investors opting for the new round will not have their shares of positions exchanged back to the original stable coin, thus saving fees.
Variable Investment Model
Similar to the fixed investment model, but the vault works perpetually, with no preset limit of time. Anyone can deposit into the strategy vault and receive the corresponding amount of ERC20 fund coins. The fund coins can be redeemed at any time (with a small fee attached if within a time range). This model is more convenient for investors but higher gas fees may occur, if all positions must be evenly increased after a new investment, and decreased after a withdrawal.
Teahouse Product Timeline
Funds are deposited and withdrawn in the whole, no partial deposit/withdrawal
Allows a fund manager to perform actions on the fund in the vault on a single Uniswap V3 pool
Actions includes mint (add position), burn (remove position), swap, and collect (collect fees)
SDK for fund managers to integrate with other algorithmic trading tools
Allow partial deposit/withdrawal
Dispense tokens representing the shares of fund from a partial deposit
Able to properly calculate the correct share of the fund for deposit/withdrawal
Automatic management of ‘cash positions’ (not staked in the pool) in order to allow large withdrawals
Allow investment in multiple Uniswap v3 pools
Support for more DeFi
Fenix Hsu - UC Berkeley, Columbia grad with degree in Physics and Statistic. a serial- entrepreneur in mobile and gaming, joining blockchain industry in 2018, and won the 1st place at TRON global developer contest with prediction platform FOMOSports, also a member of Binance lab batch 2.
Ping-Che Chen - NTU grad with degree in computer engineering, 2nd place ACM Asia programing contest, IOI silver medalist, focusing on FinTech Start-up development such as Insto and Paaxsoft.
The Team has been working together since 2018 with various project such as FOMOSports, Uwallet and Lucknetwork
CHIH-LI SUNG - Assistant Professor in Uncertainty quantification, Computer experiment, Machine learning, Big data, Engineering statistics at Michigan State University.