Chains, Tokens & Prices

The Squid SDK provides utility methods for querying chain configurations, token data, and prices. These methods are available after calling squid.init().

Setup

import { Squid } from "@0xsquid/sdk";

const squid = new Squid({
  baseUrl: "https://v2.api.squidrouter.com",
  integratorId: "your-integrator-id",
});

await squid.init();

// After init(), these properties are populated:
console.log(squid.chains.length);  // e.g. 92 supported chains
console.log(squid.tokens.length);  // e.g. 9689 supported tokens

Chain Data

squid.chains

After init(), the chains property contains an array of all supported chains.

squid.getChainData(chainId)

Look up a specific chain by its chain ID.

Returns:

Field
Type
Description

chainId

string

Chain identifier

chainName

string

Internal chain name

networkName

string

Human-readable network name (e.g. "Arbitrum", "Ethereum")

chainType

string

Chain ecosystem: "evm", "cosmos", "solana", "bitcoin", "xrpl", "stellar"

nativeCurrency

object

Native token details (name, symbol, decimals, icon)

squidContracts

object

Squid contract addresses on this chain (e.g. squidRouter)


Token Data

squid.tokens

After init(), the tokens property contains an array of all supported tokens across all chains.

squid.getTokenData(address, chainId)

Look up a specific token by its address and chain ID.

Returns:

Field
Type
Description

symbol

string

Token symbol

address

string

Token contract address

chainId

string

Chain ID

name

string

Full token name

decimals

number

Token decimal places

coingeckoId

string

CoinGecko identifier for price lookups

type

string

Chain type (e.g. "evm")

logoURI

string

Token logo URL

usdPrice

number

Current USD price


Token Prices

squid.getTokenPrice({ tokenAddress, chainId })

Get the current USD price for a single token.

Returns: number — The current USD price of the token.

squid.getMultipleTokensPrice({ chainId? })

Get all tokens with their current USD prices, optionally filtered by chain ID.

Returns: Token[] — An array of token objects, each including a usdPrice field.

squid.getFromAmount({ fromToken, toToken, toAmount })

Estimate how much of a source token is needed to receive a specific amount of a destination token. Useful for "exact output" UIs.

Returns: string — The estimated source amount in the token's smallest unit.


Token Approval

squid.isRouteApproved({ route, sender })

Check if the sender has approved the Squid router to spend the required source token amount.

squid.approveRoute({ signer, route })

Approve the Squid router to spend the source token. Required before executing ERC-20 swaps.

Last updated