Why trade on margins if you can borrow?

Simtopia
8 min readFeb 1, 2024

--

Simtopia.ai and Contango.xyz teamed up to analyse loan positions offered by decentralised lending platforms through the lens of perpetual futures. Indeed, lending protocols enable users to enter long and short positions comparable to perpetual futures, a primary mechanism for trading leverage in a decentralised finance (DeFi) ecosystem. To systematically evaluate the similarities and differences between these two financial contracts, we introduced the notion of the implied funding fee and the implied funding rate and contrasted it with the funding fee/funding rate for perpetual futures and found that the former is significantly less volatile than the latter. We also show that liquidations on decentralised lending platforms correspond to margin closeouts with the appropriately chosen maintenance margin rule, which we derive. Furthermore, we study PnL for both positions, the likelihood of liquidation for loan positions, and the margin calls for perpetual futures across multiple market conditions. A thorough analysis underpinned with market data and simulations can be found in our joint paper: Leveraged Trading via Lending Platforms. The Simtopia team has also developed a dashboard that allows users to compare Perps and Loan contracts across various metrics and under varied market conditions.

How Does it work?

By depositing risky assets as collateral and borrowing a stablecoin, an agent using a lending platform has unlimited upside potential but controlled downside risk. If the price of the risky asset goes up, she keeps all the upside by repaying the loan plus interest. If the price of the risky asset goes down, she may simply forfeit the asset by walking away from the loan. The short position is achieved by depositing stablecoins and borrowing risky assets. As such, loan positions provide an alternative to perpetual futures that are used to enter leveraged trading positions and are, by far, the most popular derivative traded in cryptocurrency markets.

Let’s make things more precise. Let P(t) denote the price of a risky asset, say ETH, at time t with a dollar stablecoin, say DAI, being a numeraire. Let R denote the interest rate for borrowing DAI, and r be depositing ETH as collateral. Let maxLTV be the maximal loan-to-value, which corresponds to the haircut on the collateral. To open a long-ETH loan position, an agent 1) purchases 1 ETH on the market for P(0) of DAI, 2) deposits 1 ETH as collateral, 3) borrow maxLTV of DAI against the collateral. We see that effectively only P(0)(1 — maxLTV) is required to establish the position. For capital efficiency, the agent may use a flashswap¹. At any time, the holder of the position may choose to pay back the loan, principal plus interests, in exchange for the deposited collateral with accrued interest. Note that a rational agent will only do that if the amount of redeemed collateral exceeds the amount the agent owns. Assuming continuous compounding of interest rates, the payoff for a holder of the long-ETH loan contract before the position is liquidated is given by

We can, therefore, consider this contract as equivalent to a down-and-out barrier option, where the position becomes worthless to its holder when the value of collateral falls sufficiently low.

Once the position is liquidated, we assume that the payoff is zero. Let LLTV be a liquidation threshold. If the value of the asset falls too low, the position will be liquidated. This occurs at the stopping time, defined as

The loan contract is equivalent to a down-and-out barrier American-style option, where the position becomes worthless to its holder when the value of the collateral falls sufficiently low—more on that in our incoming blogs.

The PnL of this loan contract up to a liquidation time is given by

Note that for a very short time t, which renders interest rates negligible, the PnL(t) is approximately equal to P(t)- P(0), but the agent only needs P(0)(1-maxLTV) to enter the contract, and not P(0) which would be required to enter a trade on a spot market. Hence, we see that maxLTV translates into leverage:

Funding fee implied by a loan position.

To compare the PnL of a loan position to the PnL of perpetual futures, we introduce the notion of implied funding fee and implied funding rate. By adding and subtracting P(t)- P(0) to the PnL formula above, we have

This shows one can decompose the PnL of the loan position into P(t) — P(0), which corresponds to gains from leveraged trading and implied funding fee IFF(t), which is a counterpart of the funding fee for perpetual futures before the liquidation time. Unlike for perpetual futures, the implied funding fee depends on the leverage (i.e. maxLTV), interest rates on a lending platform and price P(0) at which a position was established. The implied funding rate can be obtained by taking a derivative in time of IFF(t).

Trading on margins via a Lending platform

Liquidations on decentralised lending platforms are an analogue of
margin closeouts on exchanges that offer perpetual futures. On these exchanges, to open the position, an agent deposits funding on a margin account, an initial margin, and the position is automatically closed out when for the first time

where an exchange sets the maintenance margin. We have seen that on decentralised lending platforms, liquidation happens when, for the first time,

By rearranging this inequality, we obtain

Hence, we see that liquidations on decentralised lending platforms correspond to margin closeouts with the appropriately chosen maintenance margin rule, which typically is chosen to be a percentage of P(t). In this case, the loan contract implied maintenance margin is given by

Empirical comparison between perpetual futures and loan contracts

Having introduced new metrics for evaluating loan positions, namely implied funding fee/rate and implied maintenance margin, we can systematically assess them against perpetual futures contracts. To do that, Simtopia’s team has developed a dashboard that allows users to set the relevant parameters: maxLTV, LLTV, and initial and maintenance margin and run simulations under varied market conditions. This, for example, can help users study potential statistical arbitrage opportunities that may arise between futures markets and lending platforms or hedge the risk arising from liquidity provision on lending protocols.

We model the price of ETH-DAI as a Geometric Brownian Process P

The drift coefficient mu corresponds to market trend, while the diffusion coefficient sigma corresponds to market volatility. Process W is a standard Brownian motion.

During market trends, leverage-seeking agents may create more buying (or selling) pressure on perpetual futures than on the spot market. In the bullish markets, this translates to the F(t) — P(t) being positive, and hence longs to pay funding fee to shorts, and vice versa during bearish markets. This correlation between funding fee and market sentiment has been observed in historical data³. To account for this phenomenon, we model F to depend on market trends:

Hence, F is above P during bullish markets and vice versa during bearish markets. Here, the sigma with superscript P stands for the average magnitude of the random shock modelled by the exponential of Brownian motion with W with superscript F. Market trends on the spot market (bearish, neutral or bullish) can be detected by comparing the moving average of P over consecutive windows of time; see [1]. The mean-reverting process is defined to oscillate around ETH-DAI as follows

Here, lambda dictates the strength of the mean reversion, sigma with superscript F is the intrinsic volatility of the price of perpetual futures, while rho is a correlation coefficient between noise processes driving the price of ETH-DAI and the Perp. One can see from the data that such a reverting process is sensible², but of course, more sophisticated models are available. All these parameters can be estimated from the data, and the user can specify them in our dashboard. Below in Figure 1, we see generated prices with different random seeds for a bullish market (mu = 0.9), and Figure 2 shows the funding rate for one of those samples. We see the the correlation between funding rate and market sentiment similar to the one found in historical data.

Figure 1. Samples of P(t) and F(t)
Figure 2. Left axis (blue): simulation if ETH price in a bullish market. Right axis (red) The area under the F(t)-P(t) curve corresponds to the funding fee without considering interests.

Under these models, in Figure 3, we compare the distributions of PnL for the loan position versus the long perp position at time t=0.5. In Figure 3, we plot the distribution of funding fees in the left subplot, and the distribution of PnL in the right subplot. We used the following parameters.

  • Market parameters: bullish market (mu = 0.9), annualised volatility 10%, lambda = 50, intrinsic volatility of futures perp price = 5, rho = 0,
  • Loan position parameters: maxLTV = 0.75, LLTV = 0.95
  • Perps position parameters: maintenance margin = 5% of position size.
Figure 3. Time t=0.5. Left: funding fee distribution (Mean funding fee for loan position: 9.3, Mean funding fee for Perp: 21.3). Right: PnL distribution (Mean PnL for loan position: 1128, Mean PnL for Perp: 1023)

The above Figures indicate

  1. The funding fee of the loan position is much less volatile than the funding fee of the long perp position.
  2. Under our model, perpetual futures funding fee increase sharply with time, which can trigger a higher amount of liquidations on average. The effect of liquidations events on the PnL is indicated by the multi-modal shape of the PnL distributions in Figure 3 (Right). Furthermore as time increases loan positions yield a lower funding fee on average, resulting in a higher average PnL than perpetual futures contracts.

Statistical arbitrage opportunity: The above analysis suggests a statistical arbitrage opportunity by building a portfolio with a long loan position and a short perp position.

Figure 4 plots the distribution of PnL of this portfolio under the different market scenarios.

Figure 4. Distribution of (PnL loan position) — (PnL long perp position). Mean PnL: 276

The above experiments can be reproduced in our dashboard (https://simtopia-leveraged-trading-via-lending-platforms.streamlit.app/) with different parameter values.

[1] L. Szpruch, J. Xu, M.S. Vidales, K. Aouane, Leveraged Trading via Lending Platforms, 2024

[2] He, S., Manela, A., Ross, O. and von Wachter, V., 2022. Fundamentals of Perpetual Futures. arXiv preprint arXiv:2212.06888.

[3] https://blog.kraken.com/product/quick-primer-on-funding-rates

--

--