Protocol

Skew adjustments

The AMM is the only counterparty when opening a position. For example, if a trader opens a long position, the AMM will take the opposite (short) side of the trade.

If there is a large skew in open positions (e.g. there is 5x more long exposure than short exposure), the market should be stabilized. The goal of the AMM is to let shorts and longs provide liquidity to each other, and only use the liquidity funds as a last resort. A market is balanced by adjusting the funding rate and the price of DERPs.

Skew factor

The skew factor is a reflection of the market skew. It is calculated as:

L - total size of all user's long positions
S - total size of all user's short positions

skew factor = (L - S) / (L + S)

Funding rate

The funding rate is paid every 15 seconds by the holders of the skewed side of the market. This means that if there are more longs than shorts, the funding rate will be paid by the longs to the shorts. The funding rate is calculated as:

funding rate = skew factor * base funding rate

The base funding rate is currently set at 2% per hour (around 0.0083% per 15 seconds; subject to change based on stress testing and market conditions.)

This means that if the skew factor is 0.1, the funding rate will be 0.00083% per 15 seconds or 0.2% per hour. If the skew factor is -0.1, the funding rate will be -0.00083% per 15 seconds.

The funding mechanism incentivizes traders to acquire positions on the opposite side of the skew by making it more expensive to hold a position on the skewed side, and more profitable to hold the unskewed side.

Pricing

AMM pricing

The pricing of a DERP is adjusted based on the based on the oracle price (reflecting the underlying asset.)

The AMM quotes two prices:

  • ask price is the price to open a long or close a short,
  • bid price is the price to close a long or open a short.

If the AMM does not have enough funds to cover all trader's equity (delta_amm_equity < 0), it will increase the spreads in a way to make existing trades less profitable until they can all be covered.

To prevent excessive spreads, the bid and ask will deviate from the index price up to a preset maximum deviation (currently set at 20%.)

The prices of a single contract are calculated as:

L - total size of all user's long positions
S - total size of all user's short positions
D - the difference between AMM liquidity and total user's PnL

If D >= 0:
P_ask = P_bid = P_oracle

If D <= 0:
P_ask = min(P_oracle + D * S / (L^2 + S^2), P_oracle * 1.2)
P_bid = max(P_oracle - D * L / (L^2 + S^2), P_oracle * 0.8)

Where P_oracle is the price of the underlying asset as determined by the oracle.

This pricing mechanism results in a pricing structure that reacts to situations where the AMM is in debt by increasing spreads. The specific amounts by which prices change were chosen using the least-squares method to concentrate the impact of spread increases in the side with higher skew.

Mark price

In special cases (such as liquidation checks), using the oracle price directly could allow for market manipulation and increase the market's sensitivity to short-term price or debt spikes, especially in low-liquidity underlying assets.

The mark price is used in those cases. It's calculated using P_mark = P_oracle + EMA((P_ask + P_bid)/2 - P_oracle), where EMA is a 150s exponential moving average.

This was chosen because it allows for fast reactions to the oracle price, while smoothing over the AMM quote.

For technical reasons, the EMA is not updated continuously, but only when users execute an order in the market.

Previous
Asset specification
Next
Fees