Core TypeScript utilities and abstractions for building applications on top of Uniswap V3
—
Comprehensive blockchain network support with pre-configured contract addresses for Uniswap protocols across multiple chains including Ethereum, Polygon, Arbitrum, Optimism, and more.
Enumeration of supported blockchain networks with their respective chain IDs.
/**
* Supported blockchain chain IDs
*/
enum ChainId {
MAINNET = 1,
GOERLI = 5,
SEPOLIA = 11155111,
OPTIMISM = 10,
OPTIMISM_GOERLI = 420,
OPTIMISM_SEPOLIA = 11155420,
ARBITRUM_ONE = 42161,
ARBITRUM_GOERLI = 421613,
ARBITRUM_SEPOLIA = 421614,
POLYGON = 137,
POLYGON_MUMBAI = 80001,
CELO = 42220,
CELO_ALFAJORES = 44787,
GNOSIS = 100,
MOONBEAM = 1284,
BNB = 56,
AVALANCHE = 43114,
BASE_GOERLI = 84531,
BASE_SEPOLIA = 84532,
BASE = 8453,
ZORA = 7777777,
ZORA_SEPOLIA = 999999999,
ROOTSTOCK = 30,
BLAST = 81457,
ZKSYNC = 324,
WORLDCHAIN = 480,
UNICHAIN_SEPOLIA = 1301,
UNICHAIN = 130,
MONAD_TESTNET = 10143,
SONEIUM = 1868,
}
/**
* Array of all supported chain IDs
*/
const SUPPORTED_CHAINS: readonly ChainId[];
/**
* Type representing any supported chain ID
*/
type SupportedChainsType = (typeof SUPPORTED_CHAINS)[number];Names of native currencies for different blockchain networks.
/**
* Native currency names matching CLI input format
*/
enum NativeCurrencyName {
ETHER = 'ETH',
MATIC = 'MATIC',
CELO = 'CELO',
GNOSIS = 'XDAI',
MOONBEAM = 'GLMR',
BNB = 'BNB',
AVAX = 'AVAX',
ROOTSTOCK = 'RBTC',
}Pre-configured contract addresses for Uniswap protocols across all supported chains.
/**
* Mapping of chain IDs to contract addresses
*/
type AddressMap = { [chainId: number]: string };
/**
* Interface defining all contract addresses for a chain
*/
type ChainAddresses = {
v3CoreFactoryAddress: string;
multicallAddress: string;
quoterAddress: string;
v3MigratorAddress?: string;
nonfungiblePositionManagerAddress?: string;
tickLensAddress?: string;
swapRouter02Address?: string;
mixedRouteQuoterV1Address?: string;
mixedRouteQuoterV2Address?: string;
// v4 addresses
v4PoolManagerAddress?: string;
v4PositionManagerAddress?: string;
v4StateView?: string;
v4QuoterAddress?: string;
};
/**
* Master mapping of all contract addresses by chain
*/
const CHAIN_TO_ADDRESSES_MAP: Record<SupportedChainsType, ChainAddresses>;UNI governance token addresses across supported networks.
/**
* UNI token contract addresses by chain ID
*/
const UNI_ADDRESSES: AddressMap;
/**
* NFT airdrop claim contract address
*/
const UNISWAP_NFT_AIRDROP_CLAIM_ADDRESS: string;Contract addresses for Uniswap V2 protocol.
/**
* @deprecated use V2_FACTORY_ADDRESSES instead
*/
const V2_FACTORY_ADDRESS: string;
/**
* V2 factory contract addresses by chain ID
*/
const V2_FACTORY_ADDRESSES: AddressMap;
/**
* @deprecated use V2_ROUTER_ADDRESSES instead
*/
const V2_ROUTER_ADDRESS: string;
/**
* V2 router contract addresses by chain ID
*/
const V2_ROUTER_ADDRESSES: AddressMap;Contract addresses for Uniswap V3 protocol.
/**
* V3 core factory contract addresses by chain ID
*/
const V3_CORE_FACTORY_ADDRESSES: AddressMap;
/**
* V3 migrator contract addresses by chain ID
*/
const V3_MIGRATOR_ADDRESSES: AddressMap;
/**
* Quoter contract addresses by chain ID
*/
const QUOTER_ADDRESSES: AddressMap;
/**
* Nonfungible position manager contract addresses by chain ID
*/
const NONFUNGIBLE_POSITION_MANAGER_ADDRESSES: AddressMap;
/**
* Tick lens contract addresses by chain ID
*/
const TICK_LENS_ADDRESSES: AddressMap;
/**
* Mixed route quoter V1 contract addresses by chain ID
*/
const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap;Addresses for governance, multicall, and other infrastructure contracts.
/**
* Multicall contract addresses by chain ID
*/
const MULTICALL_ADDRESSES: AddressMap;
/**
* V0 governance contract addresses
*/
const GOVERNANCE_ALPHA_V0_ADDRESSES: AddressMap;
/**
* V1 governance contract addresses
*/
const GOVERNANCE_ALPHA_V1_ADDRESSES: AddressMap;
/**
* Current Bravo governance contract addresses
*/
const GOVERNANCE_BRAVO_ADDRESSES: AddressMap;
/**
* Timelock contract addresses
*/
const TIMELOCK_ADDRESSES: AddressMap;
/**
* Merkle distributor contract addresses
*/
const MERKLE_DISTRIBUTOR_ADDRESS: AddressMap;
/**
* Argent wallet detector contract addresses
*/
const ARGENT_WALLET_DETECTOR_ADDRESS: AddressMap;
/**
* ENS registrar contract addresses
*/
const ENS_REGISTRAR_ADDRESSES: AddressMap;
/**
* SOCKS controller contract addresses
*/
const SOCKS_CONTROLLER_ADDRESSES: AddressMap;Functions for retrieving addresses dynamically based on chain ID.
/**
* Returns swap router 02 address for the given chain ID
* @param chainId - The chain ID to get the address for
* @returns The swap router 02 address, or empty string if not supported
*/
function SWAP_ROUTER_02_ADDRESSES(chainId: number): string;Usage Examples:
import { ChainId, V3_CORE_FACTORY_ADDRESSES, SWAP_ROUTER_02_ADDRESSES } from "@uniswap/sdk-core";
// Get V3 factory address for Ethereum mainnet
const factoryAddress = V3_CORE_FACTORY_ADDRESSES[ChainId.MAINNET];
console.log(factoryAddress); // "0x1F98431c8aD98523631AE4a59f267346ea31F984"
// Get swap router address dynamically
const routerAddress = SWAP_ROUTER_02_ADDRESSES(ChainId.POLYGON);
console.log(routerAddress); // Returns router address for Polygon
// Check if chain is supported
if (SUPPORTED_CHAINS.includes(ChainId.ARBITRUM_ONE)) {
console.log("Arbitrum One is supported");
}Utility function for creating address maps with the same address across multiple networks.
/**
* Creates an address map with the same address across default networks and additional networks
* @param address - The contract address to use
* @param additionalNetworks - Additional chain IDs to include
* @returns Address map with the address across specified networks
*/
function constructSameAddressMap(
address: string,
additionalNetworks?: ChainId[]
): AddressMap;Install with Tessl CLI
npx tessl i tessl/npm-uniswap--sdk-core