Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Currency

Sushi models currencies as either native chain assets or addressable tokens. The shared types live in sushi, while concrete chain implementations live in chain-specific entrypoints.

Core types

TypePurpose
BaseCurrencyAbstract base for all currencies.
NativeAbstract base for native chain assets such as ETH or SOL.
TokenAbstract base for addressable fungible tokens.
CurrencyUnion of Native and Token.
import type { Currency, Native, Token } from "sushi";

BaseCurrency provides the fields shared by every currency:

FieldDescription
chainIdChain the currency belongs to.
symbolDisplay symbol.
nameDisplay name.
decimalsDecimal precision used for human formatting and parsing.
metadataOptional app-specific metadata.
typeCurrency kind, usually native or token.
isNative, isTokenRuntime flags for narrowing.
idStable Sushi currency ID.

Native

Native represents a chain gas asset. It is abstract; use concrete chain classes such as EvmNative and SvmNative.

import { EvmNative } from "sushi/evm";
 
const eth = EvmNative.fromChainId(1);
 
eth.isNative; // true
eth.isToken; // false
eth.id; // '1:NATIVE'

Native assets can be wrapped when the chain package knows the canonical wrapped token.

import { EvmNative } from "sushi/evm";
 
const eth = EvmNative.fromChainId(1);
const weth = eth.wrap();

Token

Token represents an addressable fungible currency. It is abstract; use concrete chain token classes.

import { EvmToken } from "sushi/evm";
 
const USDC = new EvmToken({
  chainId: 1,
  address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  symbol: "USDC",
  name: "USD Coin",
  decimals: 6,
});
 
USDC.isToken; // true
USDC.isNative; // false
USDC.id; // '1:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'

Tokens compare by chain, decimals, type, and normalized address.

import { EvmToken } from "sushi/evm";
 
const a = new EvmToken({
  chainId: 1,
  address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  symbol: "USDC",
  name: "USD Coin",
  decimals: 6,
});
 
const b = EvmToken.fromJSON(a.toJSON());
 
a.isSame(b); // true

Concrete currency classes

ClassImportNotes
EvmToken, EvmNativesushi/evmEVM tokens and native assets.
SvmToken, SvmNativesushi/svmSVM/Solana tokens and native SOL.
StellarTokensushi/stellarStellar contract tokens with optional issuer.
MvmTokensushi/mvmMove VM token type tags. No MvmNative class is currently exported.

Chain-generic currency types

Use the root type helpers when writing code that works across multiple chain environments.

TypePurpose
CurrencyFor<TChainId>Currency type for a chain ID.
TokenFor<TChainId>Token type for a chain ID.
NativeFor<TChainId>Native currency type for a chain ID.
AddressFor<TChainId>Address type for a chain ID.
TxHashFor<TChainId>Transaction hash type for a chain ID.
IDFor<TChainId>Currency ID type for a chain ID.
import type { AddressFor, ChainId, CurrencyFor } from "sushi";
 
function selectCurrency<TChainId extends ChainId>(
  chainId: TChainId,
  address: AddressFor<TChainId>,
  currency: CurrencyFor<TChainId>,
) {
  return { chainId, address, currency };
}

Serialization

Concrete currency classes expose toJSON, fromJSON, and serialized zod schemas.

import { EvmToken, serializedEvmTokenSchema } from "sushi/evm";
 
const USDC = new EvmToken({
  chainId: 1,
  address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  symbol: "USDC",
  name: "USD Coin",
  decimals: 6,
});
 
const parsed = serializedEvmTokenSchema().parse(USDC.toJSON());
const restored = EvmToken.fromJSON(parsed);