Skip to main content

markets

This module provides market configuration data for the GMX protocol across different blockchain networks. It contains predefined market configurations including token addresses and swap limits for trading pairs on supported chains.

Types​

The markets module exports the following TypeScript types.

MarketConfig​

Configuration for a single market, keyed by market token address in the MARKETS map.

type MarketConfig = {
marketTokenAddress: string;
indexTokenAddress: string;
longTokenAddress: string;
shortTokenAddress: string;
};

MarketsConfigMap​

A mapping from market token address to MarketConfig.

type MarketsConfigMap = Record<string, MarketConfig>;

MarketLabel​

A template literal type for market label strings in the format "SYMBOL/USD [LONG-SHORT]".

type MarketLabel = `${string}/USD [${string}-${string}]`;
import type { MarketLabel } from "@gmx-io/sdk/configs/markets";

const label: MarketLabel = "BTC/USD [WBTC.e-USDC]";

Constants​

SWAP_GRAPH_MAX_MARKETS_PER_TOKEN​

SWAP_GRAPH_MAX_MARKETS_PER_TOKEN: number

Maximum number of markets per token considered when building the swap graph. Value: 5.

import { SWAP_GRAPH_MAX_MARKETS_PER_TOKEN } from "@gmx-io/sdk/configs/markets";

console.log(SWAP_GRAPH_MAX_MARKETS_PER_TOKEN); // 5

MARKETS​

MARKETS: Record<ContractsChainId, MarketsConfigMap>

Complete market configuration mapping for all supported chains, keyed first by chain ID and then by market token address.

import { MARKETS, ARBITRUM } from "@gmx-io/sdk/configs/markets";

// Get all markets for Arbitrum
const arbitrumMarkets = MARKETS[ARBITRUM];

// Get a specific market configuration
const btcUsdMarket = MARKETS[ARBITRUM]["0x47c031236e19d024b42f8AE6780E44A573170703"];
console.log(btcUsdMarket.indexTokenAddress); // BTC index token address

DISABLED_SWAP_ROUTE_MARKETS​

DISABLED_SWAP_ROUTE_MARKETS: Partial<Record<ContractsChainId, string[]>>

Markets excluded from swap path routing (collateral swaps and express fee swaps). GM token buying and selling for these markets is unaffected — only routing through them is blocked. On Arbitrum, this currently excludes the ATOM/USD, OP/USD, EIGEN/USD, and APE/USD markets.

import { DISABLED_SWAP_ROUTE_MARKETS, ARBITRUM } from "@gmx-io/sdk/configs/markets";

const disabledOnArbitrum = DISABLED_SWAP_ROUTE_MARKETS[ARBITRUM] ?? [];
console.log(disabledOnArbitrum);
// ["0x248C35760068cE009a13076D573ed3497A47bCD4", "0x4fDd333FF9cA409df583f306B6F5a7fFdE790739", ...]

Methods​

The markets module exports the following functions for looking up market configuration by chain, address, or label.

getMarketsByChainId​

getMarketsByChainId(chainId: ContractsChainId): Record<string, MarketConfig>

Returns all market configs for a chain. Throws if the chain ID has no configured markets.

import { getMarketsByChainId, ARBITRUM } from "@gmx-io/sdk/configs/markets";

const markets = getMarketsByChainId(ARBITRUM);
for (const [address, config] of Object.entries(markets)) {
console.log(address, config.indexTokenAddress);
}

getMarketByLabel​

getMarketByLabel(chainId: ContractsChainId, label: MarketLabel): MarketConfig

Retrieves a market configuration by its human-readable label. Throws if the label is invalid or no matching market is found.

import { getMarketByLabel, ARBITRUM } from "@gmx-io/sdk/configs/markets";

const market = getMarketByLabel(ARBITRUM, "BTC/USD [WBTC.e-USDC]");
console.log(market.marketTokenAddress);

fixTokenSymbolFromMarketLabel​

fixTokenSymbolFromMarketLabel(chainId: ContractsChainId, symbol: string): string

Normalizes a raw token symbol extracted from a market label to match the token configuration format. For example, on Arbitrum "WBTC" maps to "BTC" and "ETH" maps to "WETH".

import { fixTokenSymbolFromMarketLabel, ARBITRUM } from "@gmx-io/sdk/configs/markets";

console.log(fixTokenSymbolFromMarketLabel(ARBITRUM, "WBTC")); // "BTC"
console.log(fixTokenSymbolFromMarketLabel(ARBITRUM, "ETH")); // "WETH"

isMarketTokenAddress​

isMarketTokenAddress(chainId: number, marketTokenAddress: string): boolean

Returns true if the given address is a known market token address on the specified chain.

import { isMarketTokenAddress, ARBITRUM } from "@gmx-io/sdk/configs/markets";

isMarketTokenAddress(ARBITRUM, "0x47c031236e19d024b42f8AE6780E44A573170703"); // true
isMarketTokenAddress(ARBITRUM, "0x0000000000000000000000000000000000000000"); // false

getTokenAddressByMarket​

getTokenAddressByMarket(chainId: number, marketTokenAddress: string, tokenType: "long" | "short" | "index"): string

Returns the address of the long, short, or index token for a market. For "index", returns the native token address where applicable.

import { getTokenAddressByMarket, ARBITRUM } from "@gmx-io/sdk/configs/markets";

const longTokenAddress = getTokenAddressByMarket(ARBITRUM, "0x47c031236e19d024b42f8AE6780E44A573170703", "long");

getMarketIndexToken​

getMarketIndexToken(chainId: number, marketTokenAddress: string): Token

Returns the Token object for a market's index token.

getTokenSymbolByMarket​

getTokenSymbolByMarket(chainId: number, marketTokenAddress: string, tokenType: "long" | "short" | "index"): string

Returns the symbol of the long, short, or index token for a market.

getIsSpotOnlyMarket​

getIsSpotOnlyMarket(chainId: number, marketTokenAddress: string): boolean

Returns true if the market is a spot-only market (index token address is zeroAddress, meaning no perpetuals).

getMarketIsSameCollaterals​

getMarketIsSameCollaterals(chainId: number, marketTokenAddress: string): boolean

Returns true if the market uses the same token for both long and short collateral (single-sided collateral market).