Traders

Documentation on how traders typically interact with the protocol

Position Mechanics

There are 4 instructions that dictate the position mechanics:

  1. Create Position

  2. Increase Position

  3. Decrease Position (can either decrease a part or entire position)

  4. Liquidate Position

When a position changes, a few things happen. We will outline the Create Position instruction, but note that say decrease position does the same thing, just in the opposite direction, so we when buy in a Create Position, we sell in the Decrease Position, etc.

  1. Check constraints

    1. Leverage

    2. Position Size

    3. Market won't end up net short

    4. Pool has enough liquidity

  2. Fee Calculations

  3. Swap with underlying market to maintain delta neutrality. The price received is the price used for P&L calculations

  4. Move remaining assets & update on-chain state

P&L

The calculation for a trader's P&L. Note the prices are calculated after making any swaps to prevent from MEV attacks.

Weighted Average Entry Price

When a trader increases a position this is what their new entry price is set to:

Fees

There are two types of fees a trader can incur, position update fees and lending fees.

Position Update Fees

The formula to calculate position open/close/update fees is:

This base fee gets multiplied by a multiplier that is dependent on how healthy/unhealthy the position change will make the market, i.e. if the market is near net-short and a trader is opening a long, the open fee could be as low as free. However, if the trader is closing a long in the same market conditions, the fee will be very expensive. The exact formula is:

where

Where the ideal_long_ratio is currently 55%.

Where the rebalance_rate_bps is a setting on the global settings that forces rebalances up to 100% of the position in extreme scenarios.

Lending Fees

Lending fees are charged when a trader decreased their position (or at liquidation). Interest owed is calculated by keeping track of a counter that adds the last interest rate of the LP pool every time the LP pool has reason to change it's rate (like a new position opening, taking up funds), thus it becomes a sort of cumulative interest rate. The position itself has it's own "last seen" cumulative interest rate value, and a difference between these two values is taken. This resulting value can be used to back in to the interest owed. Whenever the position changes, this calculation is done, and the owed interest is paid, and the "last seen" value is set to the current value on the Pool.

Liquidations

If a position looks like it is approaching a level where collateral cannot cover liquidation fees, closing fees, lending fees, and losses to the whole position, the protocol liquidates the position. Conceptually the liquidation price is the price at which a position's total losses equal its collateral (minus a buffer to pay liquidator incentives)

Position is eligible for liquidation when:

When a position is liquidated here is where funds go:

  1. Liquidator - max(remaining × 10%, $2 min)

  2. LP Pool - Interest owed

  3. LP Pool - Share of position fees

  4. Guarantor Fund - Share of position fees

  5. Position Owner - Any remainder

Bad Debt

Unconventionally, the protocol considers bad debt in 2 scenarios:

  1. Bad debt in the traditional sense where a position isn't liquidated fast enough

  2. Market is net short so unhedged profits are owed

If there is bad debt, the market takes from the backstop initially. If losses mount, the LP pool is at risk, but only after exhausting the backstop. If the market drops below the limit for the backstop, it freezes and no new positions can be opened, but the LP is still at risk for existing positions.

Traditional Bad Debt

Here is a situation that summarized how traditional bad debt works:

Trader provides: 2 USDC collateral Position size: 10 USDC (with 5x leverage) Entry price: $100

What happens:

  1. Pool provides 10 USDC to buy tokens (not from collateral!)

  2. Protocol buys tokens worth 10 USDC at $100 each

  3. Trader's 2 USDC collateral is held as security/margin

  4. Tokens go to hedge account (not trader)

The Key Point: Collateral ≠ Purchase Funds

  • Collateral (2 USDC): Security deposit, stays in the pool as margin

  • Position Size (10 USDC): Borrowed from pool to buy the tokens

  • Leverage: Pool lends you 10 USDC using your 2 USDC as collateral

At Liquidation

When price drops to $75:

Position value: 10 USDC × ($75/$100) = 7.5 USDC Loss: 10 USDC - 7.5 USDC = 2.5 USDC

What happens:

  1. Hedge unwind: Sell tokens for 7.5 USDC (returns to pool)

  2. Pool deficit: 10 USDC lent - 7.5 USDC recovered = 2.5 USDC loss

  3. Collateral covers: Take user's 2 USDC collateral

  4. Still short: 0.5 USDC bad debt

  5. Backstop covers: 0.5 USDC

Who Actually Pays

  1. Trader: Loses entire 2 USDC collateral

  2. Pool: Gets back 7.5 USDC from hedge unwind + 2 USDC collateral = 9.5 USDC (lost 0.5 USDC)

  3. Backstop: Pays 0.5 USDC to make pool whole

Losses from Net Short Positions

If the market is net short and owes profits to a short position, the market treats these losses the same as bad debt losses; taking from the backstop before passing losses onto the LP pool.

Last updated