Logarithm Basis: Liquidity Risks
Introduction
In this series of articles, we continue to explore possible risks of the basis trading strategies and their mitigation strategies. The first article discussed Funding Risks , and now we will delve into liquidity risk.
Liquidity risk arises from the strategy’s own actions, that involves buying and selling assets, affecting the spot and futures markets. While funding risk focuses on proving a strategy’s viability and potential profit, liquidity risk is concerned with the necessary limitations required for the strategy to function effectively in various market conditions.
Liquidity Risk: Preamble
Initiating Actions and Their Impact
In basis trading strategies, initiating actions are function calls that trigger changes in the strategy's position. These actions can be deposits, withdrawals, rebalancing up, rebalancing down, or rehedging. Each action serves a specific purpose and has a unique impact on the strategy:
- Deposit: When a user deposits funds, the strategy adds collateral to support the new positions, then increases the spot size and hedge size. This ensures that the strategy can maintain its leverage and risk parameters while accommodating the new funds.
- Withdraw: Withdrawals decrease the spot size, hedge size, and remove collateral. This action frees up capital for the user while ensuring that the strategy remains balanced.
- Rebalance Up: Rebalancing up is performed to move the strategy from minimum leverage to the target leverage, increasing capital utilization. This involves reallocating capital between the spot and hedge positions to achieve the desired leverage ratio.
- Rebalance Down: Rebalancing down adjusts the strategy from maximum leverage to the target leverage, reducing risk and preventing the strategy from approaching liquidation levels. This action rebalances the capital allocation to ensure stability.
- Rehedge: Rehedging corrects any deviations between the hedge position size and the spot exposure, ensuring that the strategy remains delta-neutral.
Each initiating action incurs trade execution costs, driven by the need to perform opposite market actions. For example, increasing product exposure involves buying spot and selling futures, while reducing exposure involves selling spot and buying futures. By product, we mean a token used to accumulate funding rates (e.g., in the USDC-WETH Basis Strategy, USDC is a notional asset and WETH is the product). These actions can lead to trading costs due to price spread between hedging platform and spot buying or, in favorable conditions, arbitrage profits. The exact numerical impact of initiation actions to the strategy performance will be covered in our next research.
Trade execution costs and Arbitrage Opportunities
Trade execution costs are a critical consideration in basis trading strategies. These costs arise from the need to perform market actions that push prices in opposite directions. For instance, when increasing the size of a short position, the strategy sells futures contracts, which can push the price down. Conversely, buying spot assets can push the price up. The difference between the buy and sell prices constitutes the execution cost.
However, in favorable market conditions, the strategy can capitalize on arbitrage opportunities. Arbitrage occurs when the price of selling is higher than the price of buying, resulting in a negative execution cost, or arbitrage premium. This can happen when market conditions create an execution spread that is favorable to the strategy's actions. By timing these actions effectively, the strategy can minimize trade execution costs and even secure profits through arbitrage.
Rebalancing Logic and Desired State
Rebalancing starts when the hedge position’s leverage reaches the predetermined limit (max leverage). It is used to move the strategy to its desired state, defined by the target leverage. The desired state has specific criteria:
- Spot Exposure Equals Hedge Exposure: Ensuring that the amount of spot product held matches the hedge position.
- Capital Allocation to Spot: The capital allocation to the spot market should be target leverage / (1 + target leverage).
- Capital Allocation to Hedge: The capital allocation to the hedge should be 1 / (1 + target leverage).
These criteria ensure the strategy remains balanced and operates efficiently. For example, if the target leverage is 2x, the capital allocation to the spot would be 2 / (1 + 2) = 2/3, and the capital allocation to the hedge would be 1 / (1 + 2) = 1/3.
Target market behavior and edge cases
Although each rebalancing action incurs costs, they remain essential for the strategy's proper operation. However, depending on the current market situation, position adjustment may need to be performed in different ways.
The ideal market behavior for the strategy entails a lack of extreme price fluctuations that could unexpectedly push the leverage beyond its bounds. The pivotal parameter to monitor in this context is the maximum leverage value predetermined by the strategy. For example, if the target leverage is set at 3 with a maximum allowable leverage of 6, rebalancing (in this case, rebalancing down) will be triggered when the leverage hits 6 to realign it to 3.
In contrast, edge cases represent scenarios where the strategy must free up capital urgently to mitigate the risk of liquidation, even if it means disregarding slippage restrictions. This situation often arises during sudden price spikes in the underlying asset.
For instance, if leverage increases from 5.5 to 7 in a short period of time, the strategy may rebalance gradually (if needed) to minimize price impact costs. However, if leverage jumps from 5.5 to 20+, the risk of liquidation becomes significant. In such cases, it may be necessary to rebalance positions quickly to avoid further liquidation losses. In the spot market impact section, the liquidation prevention logic used in Logarithm finance is described in more details.
Basis vault capacity
With the constantly changing market conditions, it's important to determine how much capital a basis strategy can utilize while keeping trade execution costs low. In Logarithm Finance, this is known as the basis vault capacity, which is influenced by both spot and hedge positions.
Spot positions provide two constraints to consider: qualitative and quantitative. The qualitative constraint involves assessing whether prices are being arbitrated swiftly within the market. If the condition of swift arbitrage is met, the capacity can be considered recoverable, allowing for its utilization, retention, and potential reuse. The quantitative constraint revolves around selling a specific percentage of the position in a single batch, primarily to avert liquidation risks, while aiming for a preferred price impact loss of less than 2%, contingent on specific market conditions. This implies that the vault capacity should not be excessively large, as this could lead to high costs when selling a fixed percentage of the product promptly.
Hedge positions also impact vault capacity as actions taken can affect funding rates. If the rates are too low, it can lead to a decrease in the strategy's APY. It's crucial to estimate the capital amount that can be processed without affecting funding rates too much, as well as the time it takes for funding rates to return to normal levels. In the following sections we provide a more detailed estimation on each of these components.
Spot position impact on vault’s capacity
The most influential parameter associated with liquidity risk on spot position is the price spread value. To address this issue correctly, the average arbitrage time was estimated on the target spot platform - Uniswap v3.
Arbitrage time estimation
The most popular assets such as ETH and BTC are arbitrated extremely quickly - on the order of a couple of dozens of seconds. For a deeper dive, the price spread of Uniswap v3 and Binance for ARB and LINK are presented in this section.
An in-depth data analysis provided the following rough estimation for arbitrage more than 1% spread:
Using this estimations we can consider the mentioned markets to be swiftly arbitraged as the price spread is eliminated in less then 10 minutes event for less liquid assets. This would allow the strategy to perform a sequence of hundreds initiating actions per day if needed without incurring any spread related costs.
These results were derived from a substantial data sample size, leading to the conclusion that if one-batch transactions for selling and buying at the spot are limited by a specific value, the spread generated by these actions will be offset over moderate time, enabling the prediction of the next possibility of conducting transactions with significant amount of capital.
This limitation of one-batch transaction size is crucial for the vault’s spot capacity in Logarithm finance. The capacity, as the analysis above showed, recovers over time, so, it is more accurate to determine it as short-term vault’s spot capacity, or spot capacity, for short.
Spot actions impact on slippage
This section provides an assessment of one-batch transaction size, that could be perform with the predefined limited slippage.
Figures 3a and 3b provide slippage to swap size dependence.
The restriction on immediate sale is intended to mitigate the price impact loss from strategy’s actions. Based on backtests, a heuristic indicator was formed that if the utilizing capital is about 5% of a pool’s TVL, the price impact is generally kept under 2%. Since, outside of critical situations, the strategy retains flexibility in choosing the amount of funds sold to maintain positions in the balance sheet, the restriction on a one-batch sale starts to play a role when the price comes close to the liquidation price.
When the price approaches some liquidation threshold, the restriction on a one-batch sale becomes significant. In such cases, it is necessary to adjust the position to the target leverage as quickly as possible, even if it results in some price impact loss. To be more accurate, Logarithm adjust position’s leverage to the max allowable leverage instead of target, since it helps slightly decrease the costs.
Then, to determine the strategy’s capacity, the first step is to identify the fraction of the position that needs to be sold for rebalancing down to achieve the desired leverage. In Logarithm Finance, this proportion is known as the spot reserve. A detailed calculation is provided in the following section, but it is worth to note here that the spot reserve is dependent on the maximum leverage set for each individual pool and the established leverage limit relative to the expected liquidation level. When the price hits this limit, a portion of the position will be sold regardless of the current price impact loss.
Hedge position impact on vault’s capacity
Target APY threshold
As mentioned previously, any initiating action with the capital within a position impacts the size of both the spot and hedge. Generally, changes in positions’ sizes result in a widening of the spread on both sides. For instance, increasing product exposure involves buying spot and selling short. However, besides widening the spread, there is an another liquidity risk for a hedge position. Position adjustment actions, utilizing significant capital can lead to a substantial decrease in the funding rate, making the basis strategy unprofitable.
In order to mitigate these risks, a target APY threshold is placed. To determine the maximum capital that can be operated in a single batch, the strategy assesses how it will affect FR and potential APY. If the calculated potential APY is below the established threshold, it is necessary to divide the action into multiple transactions, slightly extending the execution time while maintaining profitability.
For example, let’s consider the GMX v2 market. In GMX v2, the funding rate (FR) is determined by Open interest for short position (shorts OI), longs OI, and internal GMX V2 parameters. The effective funding rate, which reflects actual profit, is calculated by subtracting the borrowing rate (which is function of total OI and pool value) from the funding rate.
To identify the point where the potential APY is zero, we vary the total volume of positions from 1% to 100% OI and calculate new FR time series for each volume. Subsequently, for each FR time series, we compute the APY.
The graph illustrates that for the market conditions being analyzed, the zero APY point is reached at 8.5 million of total positions volume. If the APY threshold of 5% is placed, the maximum additional OI imbalance should not exceed 4.2 million (for the current backtest setup).
Funding rate patterns
Structurally, the dependence of the hedge position capacity on the target platforms is similar to the spot one: this capacity is instantaneous and recovers over time. Any market participant, including Logarithm Finance, creates an imbalance of open interest by their actions, thereby affecting the value of the funding rate. Since historically price discovery takes place on the most liquid platforms, the imbalance of open interest created on the target (for Logarithm Finance) markets will be arbitraged, returning the FR value to some default one. For more information about why the default FR value meets the requirements of the Logarithm Finance basis strategy, see the previous article.
To provide additional context, correlation matrices and the weighted funding rate index (WFRI) graph are displayed below. It is clearly seen that there is a strong correlation between the values of FR on GMX, Hyperliquid and dYdX with Binance.
Another noteworthy result in this section is the correlation between GMX and Binance, since HyperLiquid and dYdX use a similar FR calculation mechanics to Binance, while GMX uses a totally different approach.
In addition, the WFRI graph illustrates that the core funding rate values for all platforms are maintained within a narrow range and change over time in a similar way.
Target and Max Leverage: Advanced view
Rebalancing within the strategy occurs when the leverage breaches its designated threshold to realign it with the target value. This breach can happen in either direction — upward or downward. The lower threshold ensures optimal capital utilization for the strategy and typically carries lower risk compared to breaching the upper threshold, that safeguards the strategy from liquidation risks. The methodology for determining the maximum (upper) leverage threshold is outlined below.
From solution of the following system:
where price_i — position open price, price_1 — price in certain moment, when max_lvg should be calculated.
The following ration could be determined:
denoting this ratio as q:
General extreme (max or min) leverage is determined as:
Safe Margin Treasury
Considering spot impact on slippage, the leverage limit relative to the expected liquidation level was mentioned. In Logarithm Finance, this limit is referred to Safe Margin Treasury (SMT) threshold.
This bound is defined as the leverage value at which the asset price has just 5% moving until the position’s liquidation price will be reached. Based on tests for target GMX v2 pairs, it was estimated that liquidation occurs when ~100 leverage is reached.
After testing and plotting the corresponding graphs, a fair estimate of the SMT threshold turned out to be a 20x leverage (fig 7).
Remind, that when a position reaches a leverage equal to the SMT value, the highest priority task for strategy becomes to return the position to the maximum allowable leverage, regardless of price impact loss.
Max allowable leverage
Below is a formalized step-by-step explanation of how to calculate the maximum leverage for the trading strategy.
Preliminary parameters
- Safe Margin Treasury Leverage: The leverage used to govern the risk management of the vault’s balance (set at 20).
- Liquidation Leverage Ld_lvg : The leverage level at which a position would be liquidated (set at 100).
- Resampled Price Time Series: Historical prices for a landed asset obtained from Chainlink since its listing on AAVE, resampled to a 1-second frequency with missing values filled using the previous available prices.
- Cash transfer period (T): Rebalancing down implies a decrease of the spot position and an increase of the collateral. This cash transfer (from spot to hedge) period mainly depends on the time of withdrawal from the spot, based on internal tests this value is fixed at 60 seconds .
Step 1: Calculate price amplitude
For a sliding window on the resampled price time series, calculate the price amplitude value 𝑉 as follows:
where
- 𝑂: Open price in the window.
- 𝐻: High price in the window.
- 𝐿: Low price in the window.
- 𝐶: Close price in the window.
Step 2: Determine Target Frequency
Evaluate target frequency F of margin safe treasury leverage excess. For now, this threshold is placed as 1 time per year, so it can be expressed as:
Step 3: Calculate TF-Quantile amplitude VQ
Calculate corresponding TF-quantile VQ:
This ensures that the probability of 𝑉 exceeding $V_Q$ is greater than the established target frequency.
Step 4: Calculate the maximum price amplitude $V_{max}$
Step 5: Compute LVG_VQ
LVG_VQ value is responsible for max allowable leverage limit, based on VQ quantile, i.e. this limit provides extremely low (~1 time per year) probability to reach SMT threshold.
Calculations are performed using formula (1), where q is equal to
Step 6: Compute $LVG_{liq}$
$LVG_{liq}$ value is responsible for max allowable leverage limit, based on historical max price amplitude and liquidation leverage.
Calculations are also performed using formula (1), where q is equal to V_max, and lvg_1 = Ld_lvg = 100
Step 7: Max allowable leverage choice
Finally, the maximum leverage LVG for the strategy is the minimum of the two leverage measures calculated:
Following this approach it is expected that with high probability leverage will exceed SMT threshold less than once a year, and position will never be liquidated.
Basis vault capacity: calculation example
This section shows the calculation of vault capacity for the GMX v2 exchange. Calculation utilizes historical data, shown in the table 2 and the following assumptions
- Target leverage = 3
- Max leverage are calculated using the approach above
- Safe Margin Treasury = 20
- Liquidation leverage = 100
- 5% of UNI pool TVL is a bound for less than 2% slippage
- Max possible OI imbalance, that strategy could create is limited to 10%
Step 1. Hedge dependent capacity calculation
The hedge capacity shows how much more liquidity can be added to the position before reducing the final APY to a threshold value of 5%. Recovering over time, the strategy gets the opportunity to periodically, if necessary, increase its position.
Step 2. Spot reserve calculation
Reaching the Safe Margin Treasury threshold means that the strategy is dangerously close to the liquidation price. In this case, it is necessary to return to the acceptable leverage range as soon as possible. Since this situation poses a great danger to the profit of the strategy, rebalancing occurs regardless of which price impact is received. In order to minimize costs, but at the same time ensure the safety of the strategy, rebalancing is performed not to the target, but to the maximum leverage.
A spot reserve is a value that shows what percentage of a spot position must be sold in order to bring a hedge position from the SMT state to a state with a specific maximum leverage.
Keeping the hedge and spot positions in balance, the corresponding shares of the strategy’s capital are calculated as follows:
Let A be a total vault size, then A*SMT/SMT+1 is the spot position size within SMT state. The desired state is determined by max allowable leverage, thus in the end position size will be equal to A*(Max_lvg)/(Max_lvg+1).
To reach this, X amount of vault’s capital should be sold, resulting in simple equation:
spot reserve is a fraction of vault’s position, that should be sold, thus $spot\_reserve =\frac{X}{A}$.
Or:
Step 3. Spot dependent capacity calculation
Spot capacity is calculated based on the condition that the required percentage of spot sold at one-batch(spot reserve) is equal to 5% of the total TVL pool:
This part of the capacity is also the limit for a particular market, but unlike hedge capacity, the restoration of this capacity cannot be estimated due to the impossibility of predicting pool’s utilization.
Step 4. Final capacity calculation
The final vault capacity is:
In the example presented, the spot capacity significantly exceeds the hedge capacity. This situation remains in the vast majority of cases, however, the opposite ones are also possible, for example, if a short but significant price spike of an underlying asset was appeared during the observation period
Position adjustment: Naive and Managed approaches
All of the above limitations provide an understanding of what should be be done to ensure a stable and high strategy’s profit within minimal risks. The position adjustment policy answers the question of how it should be executed.
The naive approach to position adjustment involves handling each initiating action immediately and fully. This approach ensures that all relevant changes to the position are addressed right away, maintaining the strategy’s balance and risk parameters.
The difference between the naive and managed approaches to position adjustment lies in the timing and frequency of initiating actions. The naive approach focuses on instantly and fully adjusting the position in response to any changes, ensuring that the strategy remains balanced and within predefined risk parameters at all times. While this approach reflects a thorough and immediate response to market movements, it may lead to more frequent adjustments and potentially higher costs associated with executing trades.
On the other hand, the managed approach introduces an off-chain Operator, which serves as a monitoring mechanism to assess market conditions continually. The Operator executes initiating actions when spreads are favorable, optimizing trade execution and reducing costs in the process. By leveraging real-time market data and automated decision-making, the managed approach aims to achieve more strategic and cost-effective position adjustments. More details about managed approach will be described in the next article in this series.
Conclusion
Risk management is an integral part of any trading strategy. In this article, the Logarithm Finance team presented an analysis of the maximum vault capacity of the basis of the strategy. In order to ensure the safety of deposited funds, some constants are currently shifted in such a way that it is guaranteed to exclude adverse outcomes in case of unforeseen changes in the market.
Overall, by recognizing and addressing liquidity risks through comprehensive estimation techniques and prudent risk management practices, traders can navigate the complexities of basis trading strategy with greater confidence and effectiveness. This proactive approach not only safeguards against potential pitfalls but also paves the way for sustained success in the dynamic world of financial markets.