Token

Token represents an ERC20 token with a unique address and additional data on whether the token is a native currency. The Token class ensures Token equivalence when executing functions.

GitHub File: token.ts

Extends

Properties

Public

PropertyTypeModifierDescription

address

string

readonly

The token contract address.

chainId

readonly

The chain ID on which this currency resides. See supported chains.

chainType

readonly

The virtual machine environment. Currently supports EVM only.

decimals

number

readonly

Number of decimals for the currency.

symbol

string

readonly

The currency symbol. Optional.

name

string

readonly

The currency name. Optional.

isNative

boolean

readonly

Whether the currency is native to the chain and must be wrapped.

isToken

boolean

readonly

Whether the currency meets the ERC20 standard and if not, needs to be wrapped.

Note that the mint property was previously used to manage Solana tokens but support for Solana on KyberSwap has since been deprecated.

Constructor

Parameters

ParamsTypeDescription

chainId

number

The chain ID on which this currency resides. See supported chains.

address

string

The token contract address.

decimals

number

Number of decimals for the currency.

symbol

string

The currency symbol. Optional.

name

string

The currency name. Optional.

Methods

equals() - public

Returns whether the token passed in the argument is functionally equivalent to the token implementing this class (i.e. same contract address on the same chain).

Parameters

ParamsTypeDescription

other

Token

The token to check against.

Returns

TypeDescription

boolean

Indicates whether the token passed in the argument is functionally equivalent to the token implementing this class.


sortsBefore() - public

Returns true if the token's contract address sorts before the input token contract address. Also checks if the tokens are equivalent else throws an error (i.e. same contract address and chain).

Parameters

ParamsTypeDescription

other

Token

The currency to check against.

Returns

TypeDescription

boolean

true = Token's contract address sorts before input token address. false = Token's contract address sorts after input token address.


wrapped() - public get

Accessor that returns this ERC20 token.

Returns

TypeDescription

Token

The token implementing this class.

Last updated