Andre Cronje recently shared a Uniswap V3 LP impermanent loss insurance contract to understand its design ideas.
Original title: “The Way of DeFi丨An article about AC’s insurance agreement for UniSwap V3 LP’s impermanent loss-Protection Markets “
Written by: Gamma Strategies
Compile: Yangz
Impermanence loss (IL) is the most concerned issue of liquidity providers (LP), because its impact will cause fluctuations in returns, especially for assets whose prices tend to deviate. As people’s interest in providing liquidity rises, innovations to deal with this risk have also begun to be developed. In this Gamma Strategies article, we will review a contract recently shared by Year Finance founder Andre, Protection Markets.
On July 3rd, Andre Cronje shared a prototype of a pay-as-you-go protection market on Uniswap against impermanent losses on Twitter, called ProtectionMarket.sol. The contract specifies a pERC20 token, which functions as an independent insurance market to protect impermanent losses. The premium is determined by the relationship between supply and demand.
Protection Market
Suppose you are interested in doing LP in the WETH/USDC Uniswap v3 pool to earn transaction fees, but you are worried that potential serious price fluctuations will cause you to suffer major impermanent losses during the investment period. Then, the ProtectionMarket.sol prototype contract provides you with the possibility of creating a market. You can hedge against impermanent losses by providing additional WETH to this market and protect the exchange rate of your assets from IL. However, this is in exchange for insurance premiums, which need to be paid when the protection is effective, and are determined by the relationship between supply and demand, and are variable annual interest rates.
There are two types of participants in the protection market, protectors and hedgers. These participants participate in the insurance market for a particular Uniswap pool and define one of the two assets as RESERVE (reserve assets). In this market, both participants provide RESERVE tokens to the smart contract and compensate for the impermanent losses incurred by allowing them to exercise the insurance contract, thereby earning fees in return for providing protection to the hedger.
The following is a schematic diagram of the operation of the contract:
Both the protector and the hedger deposit reserve assets RESERVE in the contract.
The hedger buys protection by pre-provisioning some of the expenses earned by the protector to avoid impermanent losses.
As long as the fees are paid, hedgers can exercise their contracts at any time and close their insurance positions.
As long as there is sufficient liquidity to cover the hedged position, both protectors and hedgers can withdraw their liquid funds.
Impermanence loss calculation
The contract allows users to protect part of the liquidity provided by impermanent losses in exchange for accumulating fees. This mechanism brings together the liquidity of different protection providers and spreads the risk of this hedging to all participants. At the same time, it also provides a new source of income for DeFi, that is, hedging costs (in insurance terms, premiums). ), these costs are updated dynamically according to supply and demand.
When you execute the protection function, you actually purchase insurance for any impermanent losses you may incur to compensate for the price difference of your impermanent losses (need to subtract premiums). The impermanence loss is calculated based on the price when you buy the protection, does not involve a specific position in the liquidity pool, and allows the maximum combination.
After purchasing the insurance and providing some reserved expenses, you can call the exercise function to execute your insurance contract, where your reserve will be modified by the following amount to represent the compensation to IL:
Among them, p_0 is the exchange price when you get the contract, and p_1 is the current price. Therefore, profit is a function of price changes, which can relate your position value to impermanent losses.
Assuming decimals = 18, then the profit function will look like the blue curve below, which is a function of relative price changes. In the red part, it shows what the profit function would look like if it compensated for price changes 1:1. The display shows that for a 20% price drop, the compensation for impermanence losses is about 10%, but for a 20% price increase, the compensation will be a little less.
This function generally behaves as you expect, if the price does not move, you will not incur impermanence losses, so the contract will not have any return, and as the relative price changes, your impermanence losses will be higher. Please note that this profit function assumes a constant product function market, so appropriate hedging of concentrated liquidity positions will require further effort.
Cost structure and economics
The cost is calculated by continuously compounding the percentage of the hedged amount, the hedged amount is determined by the APY used, and the ratio of total hedged liquidity to total protection in the pool is similar to the interest rate of the Compound borrowing market.
On July 4, 2021, the market interest rate model supplied by Compound USDC
As the demand for hedging services increases, the utilization rate should also increase, and the resulting expenses will increase accordingly. This will encourage more protection providers to supply to the pool and increase the solvency of insurance projects. Protect the market contract to ensure that the total amount of hedging is at most equal to the size of all liquid funds in the fund pool. This can provide a lot of protection for hedgers, even for extreme levels of impermanence.
The most relevant parameters that determine whether the protection of the market is economically feasible are the parameters of the cost function and the size of the reserve cost requirement. These parameters must be carefully calibrated to attract protection providers and hedgers to supply the pool of funds.
In economic theory, the criterion for evaluating insurance is whether it is actuarially fair, that is, whether the fees paid are sufficient to reduce the variability of potential results (in this case, provide liquidity accrued impermanent loss) and make it worthwhile . Given the significant price changes we have seen for digital assets, the costs required may ultimately be huge. However, if the market is not allowed to calculate, it is difficult to estimate what is reasonable.
Use of liquidity providers
Protecting the market for the use of liquid positions is a potential improvement that can reduce the volatility of the return of LP strategies, because concentrated liquidity provides a customizable risk of impermanence.
Assuming that liquidity is provided at the price P within the range of [p_a,p_b], and the price change is p_1=kâ‹…p_0, the impermanence loss will be derived as a percentage of the change as:
A comparison with the profit function that protects the market that we have seen before is helpful to understand the amount of hedging required. Assuming p_0=2100, then LP is performed in the range of [2000,2200], then the IL of Uniswap V3 and the profit function of the protection market are as shown in the figure below.
In view of the virtual liquidity provided by Uniswap v3’s centralized liquidity function, when the scope is relatively narrow, a relatively small hedging position needs to be established to make up for the impermanent loss of a larger LP position, as in the above example.
In order to quantify the hedge ratio, it is necessary to calculate the unit of the hedge q required to compensate for the percentage change in IL k=p1â‹…p0 (assuming that there is no cost to maintain the position):
Calculation of the hedge ratio
Calculation of the narrow range hedge ratio
To protect the profitability of the market, you need to purchase 0.05 units of insurance for each unit of your position. As a sanity check, consider another wider LP range. Within this range, you will face significantly more impermanence losses: Assuming the range is [100,15000], then at the same initial price, the following hedging ratio is required :
Concluding observations and implementation
The impermanent loss protection market is an important service, and we expect liquidity providers to have high demands on this. We are working with Visor to implement this service for their positions. This will provide an automated method to improve the risk profile of the LP strategy on Uniswap v3. For Protection Markets, pricing is the focus, especially careful calibration of the charging system will be the key to its adoption and success.
Source link: www.8btc.com
Disclaimer: As a blockchain information platform, the articles published on this site only represent the author’s personal views, and have nothing to do with the position of ChainNews. The information, opinions, etc. in the article are for reference only, and are not intended as or regarded as actual investment advice.