Maximum SPOT leverage, how far degen can we go in Marginly?

Maximum SPOT leverage, how far degen can we go in Marginly?

GM, Marginly fans! We’ve already covered the details of the Marginly protocol and why it differs from traditional perp DEX-es. It all boils down to one simple fact: We have a SPOT leverage on Marginly compared to “virtual” leverage provided by perp protocols. Marginly is like a super-optimized lending protocol - fully decentralized and permissionless. At Marginly we do not rely on any off-chain oracles to value users’ positions. 

When trading SPOT, you’re dealing with natural AMM liquidity and the price impact of your trade size, you have to take into account possible protocol and swap fees, and be vary of intent-based swapping, slippage setting, sandwich attacks and MEV (if we talk explicitly about trading on L1).

Given all the nuances, we sometimes envy the simplicity all the perp DEX-es face: hook up a price feed of anything you like and then use a ledger as a database where you record “trades”. All of this is very reminiscent of classical forex bucket-shops and the way they operate where you’re basically playing against LPs. 

Limits of degen

Our constant self-reflection and comparison to perp protocols got us thinking, how far with max leverage can we go with SPOT trading? I mean, there is a very systematic approach we follow to answer this question when we deploy new pools, but we’re here to explore our externally-defined limits. 

There are 2 factors which affect users’ leverage in Marginly: 

  1. The difference between the balance price (the TWAP) and the entry price which leads to a shift in leverage calculations. The actual leverage a trader gets depends on how far the market price is away from the average price.
  2. Price impact and fees reduce the maximum achievable leverage. 

Let’s examine each factor in greater detail next.

Market price vs TWAP price

The common length for the TWAP average we use for Marginly pools is 30 minutes. TWAP is basically the average price for the last 30 minutes. Any type of averaging will lag the current market price and sometimes substantially. Any trader who has seen a price chart with the moving average overlay should know this. There are basically 2 options, price is either above or below the moving average: 

1-minute price of ETH/USDC vs the 30-minute Simple Moving Average (blue line)

There are actually 4 scenarios, given we can either Buy or Sell in two of the situations depicted above. Let's compile everything into the table for a better representation: 

Price above TWAP? 

Side 

Implications for users

Yes

Long

Long position is valued at lower price P_bal < P_mkt
User picking leverage L will get higher actual leverage

Yes

Short

Short position is valued at higher price P_bal < P_mkt
User picking leverage L will get lower actual leverage

No

Long

Long position is valued at higher price P_bal > P_mkt

User picking leverage L will get lower actual leverage

No

Short

Short position is valued at lower price P_bal > P_mkt

User picking leverage L will get higher actual leverage

Table 1: Scenarios and implications for users when market prices differ from balance prices

To give you the feel of the possible deviation on effective leverage for users, consider the following chart when a user picks maximum leverage Lmax = 20 (middle of the graph).

Effective leverage depending on the relative difference between the market price and the balance price

We’ve analysed ARB/USDC and ETH/USDC intraday trading data to measure how far on average price deviates from its mean. 99% of the time price stays within +/- ~1.15% of the 30-minute twap for ARB/USDC and within +/- ~1.0% for ETH/USDC. That means the working area on the chart is roughly between -1% and 1% on the x-axis. 

Now, imagine the situation: market price is 1% above the mean, max leverage is 20, you as a buyer select leverage of 16.83 and enter long, your effective leverage will be exactly 20 and your position will be prone to liquidation! Same works for shorting: If you were to short ETH when the market price is 2% lower than balance price, if you picked 14,49 leverage your effective leverage would be 20 - close to liquidation threshold. Be very careful when you trade on Marginly with high leverage and always remember this effect. Next, let's turn to the fees and their effect on the maximum achievable leverage. 

Market fees

In Marginly users face the following fees.

Fee

Value

Description

DEX Pool Fee

0.05%

The fee of the pool on the DEX we trade. This fee may vary. In classical uniswap setting there are pools with 3 distinct fee tiers:

- 0.05%
- 0.3%
- 1%

Obviously, the higher is the fee, the less is the theoretical maximum SPOT leverage we can provide. 

Price impact

0.1% - 0.5%

Market impact depending on the size of your trade.
For example, on 17 Jan 2024 around 12.00 UTC we saw the following picture on the Uniswap ETH/USDC pool in Arbitrum based on the immediate liquidity available at that time: (sizes are in ETH).

1 0,1000%

10 0,1790%

100 0,2910%

For example, if I sell or buy 100 ETH, I will move the price around 0.3% percent from the current market price. 


This impact is implicit in a sense, that DEX returns you the amount of the tokens after the slippage and the pool fees. 

Marginly fee

0.1%

This is the fee users pay on their trade size when they borrow assets from Marginly pools to go long or short. 

As the DEX-es we work with use the intent-based architecture, the DEX pool fee and the price impact are implicitly accounted for in the amount of tokens we send to or receive from the DEX. Adhering to the concept, we can account for marginly fee in the same way. Basically, we’re just saying that the execution price is worse than the market price for the amount of fees. Here’s a comparative example with and without 0.5% combined fee for longs.

Effective LONG leverage with and without the 0.5% combined fee

Maximum leverage

So far we’ve discussed leverage in relation to users opening their positions. Theoretically, we can make the leverage users may take really-really high, but how high exactly? The natural limit is when the collateral value after all the fees and sell slippage covers the debt value in full. So again, if we combine all of our fees to one fee, we can simply say that: Lmax = 1 / fee.

So if we think that our combined fees are not going to be higher than ~1%, the maximum leverage we can set is x100. Not bad, you might say, but we haven’t taken into account possible balance and market price discrepancies. 

Effective position leverage which takes into account both the price discrepancies and fees should not exceed x100: it turns out that the maximum we can achieve is x40. With this leverage the ~ -/+ 1% deviation of market price relative to balance price, taking into account all the fees, won't exceed x100:

Effective leverage depending on the relative difference between the market price and the balance price (including fees)

Note, that even though the zero point should cross the y axis at L = 40, as we take fees into the account, we actually end up with a substantially higher leverage of 50. That’s because going from x40 to x50 in relative terms is going from 2.5% margin to 2.0% margin for the amount of total fees of 0.5%. 

Conclusion

The comparison between Marginly and traditional perp DEX-es illuminates the unique value proposition of the former as a SPOT leverage protocol. Marginly's distinction lies in offering a super-optimized, fully decentralized, and permissionless lending protocol that operates without reliance on off-chain oracles for position valuation. The intricacies of SPOT trading, including natural AMM liquidity, price impact, protocol and swap fees, intent-based swapping, and risk factors such as slippage, sandwich attacks, and MEV on L1, present a complex landscape for Marginly users.

Marginly's approach necessitates careful assessment of critical factors that dictate leverage, specifically the difference between balance price and entry price as well as price impact and fees. Furthermore, the analysis reveals the impact of TWAP average duration on effective leverage and the potential for liquidation based on market price deviations.

Ultimately, Marginly's exploration of the limits of max leverage in SPOT trading underscores the platform's commitment to continuous self-reflection and improvement. By shedding light on the factors influencing users' leverage and extensive data analysis, Marginly aims to empower its users with a nuanced understanding of leverage dynamics and risk management.


Read more