KyberSwap Docs
Search
K

BaseCurrency

A currency is any fungible financial instrument on the blockchain. This includes all tokens which implement the ERC20 token standard as well as chain-native coins (i.e. currencies used to pay for gas) such as ETH, MATIC, etc.
The BaseCurrency is an abstract class that contains basic information about the currency that is being traded and ensures currency equivalence when executing functions (i.e. are the two currencies that are being added the same currency).
GitHub File: baseCurrency.ts

Properties

Public

Property
Type
Modifier
Description
chainId
ChainId
readonly
The chain ID on which this currency resides. See supported chains.
chainType
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.

Abstract properties

Property
Type
Visibility
Modifier
Description
isNative
boolean
public
readonly
Returns whether the currency is native to the chain and must be wrapped.
isToken
boolean
public
readonly
Returns whether the currency meets the ERC20 standard and if not, needs to be wrapped.

Constructor

Parameters

Params
Type
Description
chainId
number
The chain ID on which this currency resides. See supported chains.
decimals
number
Number of decimals for the currency.
symbol
string
The currency symbol. Optional.
name
string
The currency name. Optional.
Note that the invariant function will throw if a falsy value is detected. Refer to tiny-invariant package for more details.

Methods

equals() - public abstract

Returns whether the currency passed in the argument is functionally equivalent to the base currency.

Parameters

Params
Type
Description
other
Currency
The currency to check against.

Returns

Type
Description
boolean
Indicates whether the currency passed in the argument is functionally equivalent to the base currency.

wrapped() - public abstract

Accessor that gets the ERC20 wrapped version of the currency. KyberSwap smart contracts only supports ERC20 tokens.

Returns

Type
Description
Token
The ERC20 wrapped version of the base currency.