6.4 Trading Instrcutions

Orderbook

The order book functions identically to centralized exchanges, with fully on-chain execution. Orders require prices at integer multiples of the tick size and sizes at integer multiples of the lot size. Matching adheres strictly to price-time priority.

Spot Trading

Assets are bought/sold at the current market or limited price, with ownership transferring directly upon trade execution. Prices reflect real-time supply/demand dynamics, visible to all participants via exchange order books.

How to Spot Trading on SoDEX

  1. Walk Through the SoDEX onboarding process

  2. Click [Trade] to the Spot trading interface

  3. For example, we are buying BTC. Select a BTC trading pair, such as BTC/USDC.

  4. Click [Spot] on the top right and select [Buy]. Then, choose between [Limit] and [Market], and enter the price and amount you wish to purchase. You may also drag the bar below the [Amount] field to customize the percentage of the Spot Account balance to use for the order.

  5. Click [Buy] to place the order.

*Notice: Please note that, by default, the source of funds is your Spot Account. You might need to transfer funds from other accounts, if your Spot account is not enough for Spot trading.

Futures Trading

Futures trading is a financial practice where parties enter standardized contracts to buy or sell assets (like commodities, currencies, or indices) at a predetermined price and future date, enabling risk hedging or speculative profits. In SoDEX, we are now offering perpetual futures, which are cryptocurrency derivatives without expiry dates that use a periodic funding rate mechanism to anchor their prices to the underlying spot market, enabling leveraged long/short positions with crypto-native settlement.

How to Futures Trading on SoDEX

  1. For example, we are trading BTC perpetual contracts. Start by selecting the [Futures] category in the menu, then choose [BTC/USDC].

  1. Click [Futures] on the top right and select [Buy/Long]. Then, choose between [Limit] and [Market], and enter the price and amount you wish to purchase. You may also drag the bar below the [Amount] field to customize the percentage of the Futures Account balance to use for the order.

  2. Click [Buy] to place the order.

Fees

For now, the fees on Testnet for Spot Trading are 0.1% for Taker orders, and 0.05% for Maker orders. For Futures Trading, 0.05% for Takers orders, and 0.02% for Maker orders. In future updates, tiered fee discounts will be introduced based on users' recent trading volume. Additionally, staking mechanisms and referral programs will be implemented to further reduce fee burdens. During the current Testnet phase, our team remains dedicated to implementing these core functionalities.

Order types:

  • Market: An order that executes immediately at the current market price

  • Limit: An order that executes at the selected limit price

  • Stop Market: A market order that is activated when the price reaches the selected stop price. Stop orders are generally used to help limit losses and lock in profits

  • Stop Limit: A limit order that is activated when the price reaches the selected stop price

Order options:

  • Reduce Only: An order type that decreases an existing position without initiating a new one in the opposite direction.

  • Good Till Cancel (GTC): An order that remains active on the order book until it is either executed or manually canceled by the trader.

  • Immediate or Cancel (IOC): An order that attempts immediate execution of all or part of the order, with any unfilled portion automatically canceled.

  • Take Profit (TP): An order that is automatically executed when the market price reaches the predetermined Take Profit level, closing the position to lock in gains.

  • Stop Loss (SL): An order that activates immediately when the market price hits the preset Stop Loss level, liquidating the position to limit potential losses.

  • Traders often use TP and SL orders to set targets and protect profits or minimize losses on positions. TP and SL are automatically market orders. You can set a limit price and configure the amount of the position to have a TP or SL.

Take profit and stop loss orders (TP/SL)

TP/SL orders automatically close positions upon reaching predefined profit (TP) or loss (SL) thresholds.

The mark price serves as the triggering benchmark for TP/SL activation.

Users can configure TP/SL as either market orders (default slippage tolerance: 5%) or limit orders.

  • Limit price control: Setting a limit price adjusts slippage tolerance. Aggressive limits (e.g., closer to trigger price) increase fill likelihood but may exacerbate slippage.

  • Execution example:

    • A SL limit order (trigger: $10, limit: $10) for a long position enters the order book when the mark price breaches $10. If the price gap is from $11 to $9, the order may rest at $10 without filling.

    • A SL limit order with a limit $8 would likely fill between $9 to $8 during rapid declines.

TP/SL orders initiated via the position form default to the full position size, attempting complete closure upon trigger.

Margining

Margin calculations closely mirror the formulas utilized by centralized derivatives exchanges.

Margin Mode

When opening a position, a margin mode must be selected. Cross margin (default) utilizes shared collateral across all cross-margin positions for maximum capital efficiency. Isolated margin restricts collateral allocation to the specific asset, ensuring liquidation:

  • In isolated positions, the margin doesn't affect cross/other isolated positions

  • In cross/other isolated positions, the margin doesn't affect this isolated position

Initial Margin and Leverage

Users may select leverage as any integer between 1 and the asset-specific maximum leverage. Position margin requirements are calculated as: Initial Margin = Position Size × Mark Price ÷ Leverage

  • Cross Margin:

    • Initial margin is locked and non-withdrawable

    • Unrealized PNL automatically serves as available margin for new positions

  • Isolated Margin:

    • Supports post-opening margin adjustments (add/remove)

    • Unrealized PNL applies as an additional margin to the open position

Unrealized PNL and transfer margin

Unrealized PNL withdrawal from isolated positions or cross accounts follows the following formulas:

  • initialMargin = entryPrice * positionSize / leverage

  • floatingMargin = isolatedMargin - initialMargin

  • floatingProfit = calculateFloatingProfitAndLoss(...)

  • availableSubtractMargin = max(0, min(floatingMargin, floatingMargin + floatingProfit))

'Transfer' encompasses any non-trading margin removal, including:

  • External withdrawals

  • Transfers to spot wallets

  • Isolated margin position transfers

Maintenance Margin & Liquidation Mechanics

Cross positions trigger liquidation when: Account Value (incl. unrealized PNL) < Maintenance Margin × Total Open Notional PositionMaintenance Margin = Position value * mainMarginRateThe value of mainMarginRate in various symbols is different. For example, when you open a position below maxNominalValue of 12,500,000 USDC under BTC_USDC, then the mainMarginRate is 0.004. The current Maintenance Margin Rate (mainMarginRate) on SoDEX Testnet for different symbols is consistent, as follows (Updated on 2025.08.01):

Bracket
Max Nominal Value (USDC)
Maint Margin Rate
Start Margin Rate
Max Leverage
Min Leverage

1

10,000,000

0.30%

0.50%

200x

1x

2

12,500,000

0.40%

0.80%

125x

1x

3

20,000,000

0.50%

1.00%

100x

1x

4

25,000,000

1.00%

2.00%

50x

1x

5

50,000,000

2.50%

5.00%

20x

1x

6

100,000,000

5.00%

10.00%

10x

1x

7

200,000,000

10.00%

20.00%

5x

1x

8

400,000,000

12.50%

25.00%

4x

1x

9

1,500,000,000

15.00%

33.30%

3x

1x

10

2,000,000,000

25.00%

50.00%

2x

1x

11

5,000,000,000

50.00%

100.00%

1x

1x

Isolated positions follow identical liquidation logic, with computation inputs solely comprising:

  • Isolated margin balance

  • The isolated position's notional value

Liquidations

A liquidation event occurs when a trader's account equity falls below the maintenance margin due to adverse price movements. The maintenance margin equals position value times mainMarginRate.

Liquidation Process Flow

Initial Liquidation Attempt:

  • When account equity < maintenance margin, the system sends market orders to close the full position size.

  • If partially/fully closed, restoring margin above requirements, the remaining collateral stays with the trader.

Backstop Liquidation Trigger:

  • Activates if account equity drops below 2/3 of the maintenance margin after a failed book liquidation.

  • Positions transfer to the SoDEX Vault and Liquidator Strategy Account.

Margin Handling in Backstop:

  • Cross positions: All cross positions and margin transfer to the liquidator; account equity resets to zero if no isolated positions exist.

  • Isolated positions: Only the affected isolated position and its margin transfer; cross assets remain untouched.

  • Maintenance margin is not returned to users, as it provides the vault's profitability buffer.

Price Mechanism

Liquidations use the mark price (synthesizing external CEX prices and SoDEX book state) for robustness. During high volatility, the mark price may diverge significantly from book prices.

For Cross Margin

  • Maintenance Margin = Quantity (contracts) × Contract Face Value per Contract × Entry Price × Maintenance Margin Rate

For Isolated Margin

  • Liquidation Price = (Entry Value + Side × (Maintenance Margin - Isolated Margin)) / (Position Size × Contract Face Value)

  • Maintenance Margin = Position Size × Contract Face Value × Entry Price × Maintenance Margin Rate

Mark Price is calculated in real-time by using the Black-Scholes model. The implied volatility used to calculate Options Mark Price is derived from the best bid and best ask price for the Options contract, along with the volatility cap and volatility floor set in the system. Implied Volatility = {max[min(implied volatility of best bid, volatility cap), volatility floor] + max[min(implied volatility of best ask, volatility cap), volatility floor]} * 0.5The volatility cap and volatility floor might be adjusted without notification during severe market volatility. Mark price provides an unbiased, robust estimate of the fair price of perpetual contracts (perp). It is utilized for:

  • Calculating margin requirements (margining)

  • Triggering liquidation events (liquidations)

  • Activating Take Profit and Stop Loss orders (TP/SL)

  • Determining unrealized profit and loss (unrealized PnL).

The mark price updates whenever validators submit new oracle price updates. Consequently, both mark and oracle prices refresh approximately every 3 seconds.

Entry price and pnl

Perpetuals (Perps) Mechanics

Position Opening/Closing

  • Opening trade: Absolute position size increases (e.g., increase when long/short positions)

  • Closing trade: Reduces position exposure

Entry Price Calculation

  • Opening trades: New Entry Price = Weighted Average(Current Entry Price, Trade Price)

  • Closing trades: Entry price remains unchanged

PNL Formulas

  • Unrealized PNL = side × (mark_price - entry_price) × position_size(side = 1 for long, -1 for short)

  • Closed PNL = fees + [side × (exit_price - entry_price) × position_size]

Closing trade: Full formula

Opening trade: fee only

Funding

Funding Rates are periodic fees exchanged between long and short positions in perpetual futures contracts to align contract prices with the underlying asset's spot price.

Payment Calculation

The funding payment is calculated as: Funding Amount = Nominal Value of Positions × Funding Rate

  • Nominal Value of Positions = Mark Price * Size of a Contract

Payment Settlement Rules

  • Position Timing:

    • Traders only pay/receive funding if they hold open positions at the exact funding time (e.g., 08:00:00 UTC).

    • Closing a position before settlement exempts traders from funding payments, regardless of direction.

  • Settlement Latency:

    • System processing may take up to 1 minute to complete all settlements.

    • New orders placed during settlement may experience high latency (e.g., opening a position at 08:00:59 UTC could still incur funding fees).

Funding Rate Calculation

The funding rate (F) combines two elements:

  • Premium Index (P): Measures the deviation between the futures price and spot price.

  • Interest Rate (I): A fixed component set by exchanges. In SoDEX, the interest rate is 0.01%.

  • Funding Rate (F) = Average Premium Index (P) + clamp(Interest Rate (I) - P, -0.05%, 0.05%)

Calculation Steps

Step 1: Compute Impact Bid/Ask Prices

  • Impact Margin Notional (IMN): The notional value tradable with a fixed collateral (e.g., 25,000 USDT for BTC-USDT at 125x leverage).

  • Impact Bid Price: Derived from the order book depth required to reach IMN.

  • Impact Bid Price = IMN / [(IMN - ∑px-1*qx-1)/px + ∑qx-1]

Step 2: Calculate Premium Index Series

  • Updated every 5 seconds (5,760 times per 8-hour interval).

  • Premium Index (P) = [Max(0, Impact Bid Price - Index Price) - Max(0, Index Price - Impact Ask Price)] / Index Price

Step 3: Compute Time-Weighted Average Premium Index

  • Average Premium Index = (1*P1 + 2*P2 + ... + n*Pn) / (1 + 2 + ... + n)

Step 4: Apply Funding Rate Formula

Funding Rate (F) = Premium Index (P) + clamp(interest rate - Premium Index (P), -0.05%, 0.05%)

Step 5: Capped Funding Rate

Enforce caps/floors to limit extreme rates: Capped Funding Rate = clamp(Funding Rate, Floor, Cap)

  • The function clamp (x, min, max) means that if (x < min), then x = min; if (x > max), then x = max; if max ≥ a ≥ min, then return x.

  • Floor = 0.75 * Maintenance Margin Ratio

  • Cap = 0.75 * Maintenance Margin Ratio

Last updated