Skip to content

Isolated Markets

The below is an overview of how trading works on Isolated Markets.

Note: This document covers how the feature works from the protocol point of view and not the front end or the indexer.

Trading Isolated Markets

Positions in isolated markets can only be opened on a subaccount with no open perpetual positions or a subaccount with an existing perpetual position in the same isolated market. Once a perpetual position for an isolated market is opened on a subaccount, no positions in any other markets can be opened until the perpetual position is closed.

The above restriction only applies to positions, orders can still be placed for different markets on a subaccount while it holds an open position for an isolated market. The orders will fail and be canceled when they match if the subaccount still holds an open position for a different isolated market. Error code 2005 indicates such a failure.

Other than the above caveat, isolated markets are traded the same way as cross markets.

Note: The maximum number of subaccounts per address is 128000, so that each isolated market can use a separate subaccount.

Querying for Isolated Markets

There is a new market_type parameter in the PerpetualParams proto struct that indicates the type of market.

There are 2 possible values for this parameter:

  • PERPETUAL_MARKET_TYPE_CROSS - markets where subaccounts can have positions cross-margined with other PERPETUAL_MARKET_TYPE_CROSS markets. Every market currently listed on ritbit-mainnet is of this type.
  • PERPETUAL_MARKET_TYPE_ISOLATED - markets that can only be margined in isolated, no cross-margining with other markets is possible

An example of how each type of market looks when queried using the /ritbit/perpetuals/perpetual/:id REST endpoint.

  • PERPETUAL_MARKET_TYPE_CROSS
{
  "perpetual": {
    "params": {
      "id": 1,
      "ticker": "ETH-USD",
      "market_id": 1,
      "atomic_resolution": -9,
      "default_funding_ppm": 0,
      "liquidity_tier": 0,
      "market_type": "PERPETUAL_MARKET_TYPE_CROSS"
    },
    "funding_index": "0",
    "open_interest": "0"
  }
}
  • PERPETUAL_MARKET_TYPE_ISOLATED
{
  "perpetual": {
    "params": {
      "id": 1,
      "ticker": "FLOKI-USD",
      "market_id": 37,
      "atomic_resolution": -13,
      "default_funding_ppm": 0,
      "liquidity_tier": 2,
      "market_type": "PERPETUAL_MARKET_TYPE_ISOLATED"
    },
    "funding_index": "0",
    "open_interest": "0"
  }
}