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

NativeCurrency

The NativeCurrency abstract class is the base for chain-native currencies like ETH, MATIC, or AVAX.

Import

import { NativeCurrency } from '@uniswap/sdk-core-next'

Class Definition

abstract class NativeCurrency extends BaseCurrency {
  public readonly isNative = true
  public readonly isToken = false
}

NativeCurrency is abstract and cannot be instantiated directly. Use concrete implementations like Ether or create your own for other chains.

Creating a Custom Native Currency

import { NativeCurrency, Token, type Currency } from '@uniswap/sdk-core-next'
 
class Matic extends NativeCurrency {
  private static _cache: { [chainId: number]: Matic } = {}
 
  protected constructor(chainId: number) {
    super(chainId, 18, 'MATIC', 'Polygon')
  }
 
  public get wrapped(): Token {
    // WMATIC on Polygon
    return new Token(
      this.chainId,
      '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
      18,
      'WMATIC',
      'Wrapped MATIC'
    )
  }
 
  public static onChain(chainId: number): Matic {
    if (!Matic._cache[chainId]) {
      Matic._cache[chainId] = new Matic(chainId)
    }
    return Matic._cache[chainId]
  }
 
  public equals(other: Currency): boolean {
    return other.isNative && other.chainId === this.chainId
  }
}
 
// Usage
const matic = Matic.onChain(137)
console.log(matic.symbol)        // 'MATIC'
console.log(matic.wrapped.symbol) // 'WMATIC'

Properties

isNative

readonly isNative: true

Always true for native currencies.

isToken

readonly isToken: false

Always false for native currencies.

Inherited from BaseCurrency

PropertyTypeDescription
chainIdnumberThe chain ID
decimalsnumberDecimal places (usually 18)
symbolstring | undefinedCurrency symbol
namestring | undefinedCurrency name

Abstract Methods

Implementations must provide:

equals(other)

abstract equals(other: Currency): boolean

Check if two currencies are equivalent.

wrapped

abstract get wrapped(): Token

Return the wrapped version of the native currency (e.g., WETH for ETH).

Use Cases

Native currencies are used when:

  1. V4 Pools: V4 supports native ETH directly in pools
  2. Gas Payments: Native currency for transaction fees
  3. Wrapping: Converting native to wrapped for V2/V3 pools
import { Ether, CurrencyAmount } from '@uniswap/sdk-core-next'
 
const eth = Ether.onChain(1)
 
// Create an ETH amount
const amount = CurrencyAmount.fromRawAmount(eth, '1000000000000000000')
 
// Check if native before contract interactions
if (amount.currency.isNative) {
  // Use wrapped version for V2/V3
  const wrappedAmount = amount.wrapped
}