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

PropertyTypeModifierDescription

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.

Abstract properties

PropertyTypeVisibilityModifierDescription

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

ParamsTypeDescription

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

ParamsTypeDescription

other

The currency to check against.

Returns

TypeDescription

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

TypeDescription

Token

The ERC20 wrapped version of the base currency.

Last updated