UNPKG

@plasma-fi/sdk

Version:

🛠 An SDK for building dapp on PlasmaSwap.

112 lines (111 loc) • 3.76 kB
import { ChainId } from '../constants/constants'; /** * A currency is any fungible financial instrument, including Ether, all ERC20 tokens, and other chain-native currencies */ export declare abstract class AbstractCurrency { /** * Returns whether the currency is native to the chain and must be wrapped (e.g. Ether) */ abstract readonly isNative: boolean; /** * Returns whether the currency is a token that is usable in Uniswap without wrapping */ abstract readonly isToken: boolean; /** * The chain ID on which this currency resides */ readonly chainId: ChainId; /** * The decimals used in representing currency amounts */ readonly decimals: number; /** * The symbol of the currency, i.e. a short textual non-unique identifier */ readonly symbol?: string; /** * The name of the currency, i.e. a descriptive textual non-unique identifier */ readonly name?: string; /** * Constructs an instance of the base class `BaseCurrency`. * @param chainId the chain ID on which this currency resides * @param decimals decimals of the currency * @param symbol symbol of the currency * @param name of the currency */ protected constructor(chainId: ChainId, decimals: number, symbol?: string, name?: string); /** * Returns whether this currency is functionally equivalent to the other currency * @param other the other currency */ abstract equals(other: Currency): boolean; /** * Return the wrapped version of this currency that can be used with the Uniswap contracts. Currencies must * implement this to be used in Uniswap */ abstract wrapped(): Token; /** * Returns native version of currency (WETH => ETH) */ abstract unwrapped(): Currency; } /** * Represents the native currency of the chain on which it resides, e.g. */ export declare class Native extends AbstractCurrency { readonly isNative: true; readonly isToken: false; static readonly NATIVE: { [chainId in ChainId]: Native; }; protected constructor(chainId: ChainId, decimals: number, symbol?: string, name?: string); equals(other: Currency): boolean; wrapped(): Token; unwrapped(): Currency; } /** * Represents an ERC20 token with a unique address and some metadata. */ export declare class Token extends AbstractCurrency { readonly address: string; readonly isNative: false; readonly isToken: true; constructor(chainId: ChainId, address: string, decimals: number, symbol?: string, name?: string); /** * Returns true if the two tokens are equivalent, i.e. have the same chainId and address. * @param other other token to compare */ equals(other: Currency): boolean; /** * Returns true if the address of this token sorts before the address of the other token * @param other other token to compare * @throws if the tokens have the same address * @throws if the tokens are on different chains */ sortsBefore(other: Token): boolean; /** * Return this token, which does not need to be wrapped */ wrapped(): Token; /** * Return this token, which does not need to be wrapped */ unwrapped(): Currency; } declare const NATIVE: { 1: Native; 3: Native; 4: Native; 5: Native; 42: Native; 137: Native; 56: Native; 97: Native; }; export { NATIVE }; export declare const WNATIVE: { [chainId in ChainId]: Token; }; export declare type Currency = Native | Token; export declare function isCurrency(obj?: any): boolean;