Type/to search
Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
Capability Matrix
Centralized Exchanges
Decentralized Exchanges (DEX)
Prediction Markets
Securities and Futures
On-chain & Custom

Obtains commonly used contract addresses on the current chain (or a specified chain), including mainstream tokens, Multicall3, Permit2, as well as the Factory, router, QuoterV2, and position manager contracts of Uniswap V3 and PancakeSwap V3.

exchange.IO(k)
exchange.IO(k, chainId)

Examples

View the commonly used contract addresses of the current chain and use QuoterV2 to get a quote.

javascript
function main() { // Get the commonly used contract address table of the current chain var C = exchange.IO("contracts") Log(C.name, "chainId:", C.chainId, "Wrapped native token:", C.wrappedNative) for (var sym in C.tokens) { Log(sym, C.tokens[sym].address, "decimals:", C.tokens[sym].decimals) } Log("Uniswap V3:", JSON.stringify(C.uniswapV3)) // Use the addresses in the address table and the built-in ABI template to get a quote var quoter = C.uniswapV3.quoterV2 exchange.IO("abi", quoter, "uniswapV3QuoterV2") var q = exchange.IO("call", quoter, "quoteExactInputSingle", [C.tokens.WETH.address, C.tokens.USDC.address, exchange.IO("toUnits", "1", 18), 500, 0]) Log("1 WETH ≈", exchange.IO("fromUnits", q.amountOut, 6), "USDC") // View the address table of another chain Log("BSC PancakeSwap V3:", JSON.stringify(exchange.IO("contracts", 56).pancakeV3)) }

Returns

TypeDescription

object

Returns {chainId, name, wrappedNative, tokens, multicall3, permit2, uniswapV3, pancakeV3}: name is the chain name; wrappedNative is the wrapped native coin's key in tokens (such as WETH or WBNB); each entry of tokens is {address, decimals}; uniswapV3 and pancakeV3 contain factory, router (SwapRouter02 for Uniswap, SmartRouter for PancakeSwap), quoterV2 and positionManager. An unsupported chain returns a null value and reports an error.

Arguments

NameTypeRequiredDescription

k

string

Yes

Functionality of the exchange.IO() function. When set to contracts, it indicates that the function is used to obtain commonly used contract addresses.

chainId

number

No

Chain ID. If not passed, the chain of the current node is used by default. Currently supported chains: Ethereum (1), BNB Smart Chain (56), Base (8453), Arbitrum One (42161).

See Also

Remarks

Every address in the address table has been verified on-chain: the contract code exists; the symbol and decimals of each token are consistent with the on-chain query results; the factory recorded in the router, quoter, and position manager contracts all point to the same Factory contract, and the wrapped native token/USDC liquidity pool can be queried.

When used together with the built-in templates of exchange.IO("abi", ...), these contracts can be called directly without manually writing the ABI.

Currently only Ethereum (EVM) chains are supported; on TRON the call returns a null value with the error in GetLastError().