contracts
This module provides contract addresses for the GMX protocol across different blockchain networks. It includes addresses for both V1 and V2 (Synthetics) contracts, as well as external dependencies and utilities.
Constants
CONTRACTS: Record<ContractsChainId, Record<string, Address>>- A mapping of chain IDs to contract addresses for all GMX protocol contracts
import { CONTRACTS } from "@gmx-ui/sdk/configs/contracts";
// Get all contracts for Arbitrum
const arbitrumContracts = CONTRACTS[42161];
// Access specific contract address
const dataStoreAddress = CONTRACTS[42161].DataStore;
Types
ContractName: string- Union type of all available contract names across all supported chains
import { ContractName } from "@gmx-ui/sdk/configs/contracts";
// ContractName includes values like "DataStore", "ExchangeRouter", "SyntheticsReader", etc.
const contractName: ContractName = "DataStore";
Methods
getContract
getContract(chainId: ContractsChainId, name: ContractName): Address
Parameters
chainId: ContractsChainId- The blockchain network IDname: ContractName- The name of the contract to retrieve
Retrieves a specific contract address for a given chain ID and contract name. Throws an error if the chain ID or contract name is not found.
import { getContract } from "@gmx-ui/sdk/configs/contracts";
import { ARBITRUM } from "@gmx-ui/sdk/configs/chains";
// Get DataStore contract address for Arbitrum
const dataStoreAddress = getContract(ARBITRUM, "DataStore");
// Returns: "0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8"
// Get ExchangeRouter contract address for Avalanche
const exchangeRouterAddress = getContract(43114, "ExchangeRouter");
// Returns: "0xF0864BE1C39C0AB28a8f1918BC8321beF8F7C317"