Skip to main content

contracts

This module provides contract addresses for the GMX protocol across different blockchain networks. It includes addresses for V1, V2 (Synthetics), GLV, Multichain, Gelato relay, and external contracts, as well as the getContract utility for typed address lookups.

Constants

CONTRACTS

const CONTRACTS: Record<ContractsChainId, Record<string, Address>>;

A complete mapping of chain IDs to contract addresses for all GMX protocol contracts.

CONTRACTS covers five chain IDs:

ChainChain IDType
Arbitrum42161Production
Avalanche43114Production
Botanix3637Production
Avalanche Fuji43113Development / testnet
Arbitrum Sepolia421614Development / testnet

Contract categories vary by chain. Production chains (Arbitrum and Avalanche) include both V1 contracts (Vault, GLP, staking trackers) and V2 Synthetics contracts (DataStore, ExchangeRouter, SyntheticsReader, GLV router, Multichain routers). Botanix and the testnet chains include V2 Synthetics contracts only, with V1 slots set to zeroAddress.

import { CONTRACTS } from "@gmx-io/sdk/configs/contracts";

// Get the DataStore address on Arbitrum
const dataStoreAddress = CONTRACTS[42161].DataStore;
// Returns: "0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8"

// Get the ExchangeRouter address on Avalanche
const exchangeRouterAddress = CONTRACTS[43114].ExchangeRouter;
// Returns: "0x8f550E53DFe96C055D5Bdb267c21F268fCAF63B2"

// Iterate all production chains
import { CONTRACTS_CHAIN_IDS } from "@gmx-io/sdk/configs/chains";

for (const chainId of CONTRACTS_CHAIN_IDS) {
const router = CONTRACTS[chainId].ExchangeRouter;
console.log(`ExchangeRouter on ${chainId}: ${router}`);
}
tip

Prefer getContract over direct CONTRACTS indexing in application code. It provides a typed lookup and throws a descriptive error if the chain ID or contract name is not found, making integration bugs easier to diagnose.

Types

ContractName

type ContractName = ExtractContractNames<typeof CONTRACTS>;
// resolves to: "DataStore" | "ExchangeRouter" | "SyntheticsReader" | "Vault" | ...

A union of every contract key name defined across all chains in CONTRACTS. The type is derived automatically from the CONTRACTS object, so it stays in sync with the source without manual maintenance.

import type { ContractName } from "@gmx-io/sdk/configs/contracts";

// Valid: "DataStore" is a key in CONTRACTS
const name: ContractName = "DataStore";

// Also valid
const names: ContractName[] = ["ExchangeRouter", "SyntheticsReader", "GlvRouter"];

ContractName includes all contract keys from all chains, including V1-only contracts (such as "Vault", "GlpManager") and V2-only contracts (such as "DataStore", "GlvRouter"). Some contracts are set to zeroAddress on chains where they are not deployed — use getContract to retrieve the address and check the result before use if the contract may not be active on a given chain.

Methods

getContract

function getContract(chainId: ContractsChainId, name: ContractName): Address;

Retrieves a specific contract address for a given chain ID and contract name.

Parameters

ParameterTypeDescription
chainIdContractsChainIdThe numeric chain ID (42161, 43114, 3637, 43113, or 421614)
nameContractNameThe contract name key (for example, "DataStore", "ExchangeRouter")

Returns

Address — the checksummed hex address string for the contract on the given chain.

warning

getContract throws an Error if chainId is not in CONTRACTS or if name is not found for that chain. Always call with a valid ContractsChainId value.

import { getContract } from "@gmx-io/sdk/configs/contracts";
import { ARBITRUM, AVALANCHE } from "@gmx-io/sdk/configs/chains";

// Get DataStore on Arbitrum
const dataStoreAddress = getContract(ARBITRUM, "DataStore");
// Returns: "0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8"

// Get ExchangeRouter on Avalanche
const exchangeRouterAddress = getContract(AVALANCHE, "ExchangeRouter");
// Returns: "0x8f550E53DFe96C055D5Bdb267c21F268fCAF63B2"

// Use with a dynamic chain ID (validated at runtime)
function lookupContract(chainId: number, name: ContractName): Address | null {
try {
return getContract(chainId as ContractsChainId, name);
} catch {
return null;
}
}