@alcorexchange/alcor-swap-sdk
Version:
**npm** ``` npm i @alcorexchange/alcor-swap-sdk ``` **yarn** ``` yarn add @alcorexchange/alcor-swap-sdk ``` ## Usage ### Import:
37 lines (36 loc) • 1.98 kB
TypeScript
import { Currency } from "../currency";
import { Token } from "../token";
import { Fraction } from "./fraction";
import { BigintIsh, Rounding } from "../../internalConstants";
export declare class CurrencyAmount<T extends Currency> extends Fraction {
readonly currency: T;
readonly decimalScale: bigint;
/**
* Returns a new currency amount instance from the unitless amount of token, i.e. the raw amount
* @param currency the currency in the amount
* @param rawAmount the raw token or ether amount
*/
static fromRawAmount<T extends Currency>(currency: T, rawAmount: BigintIsh): CurrencyAmount<T>;
/**
* Construct a currency amount with a denominator that is not equal to 1
* @param currency the currency
* @param numerator the numerator of the fractional token amount
* @param denominator the denominator of the fractional token amount
*/
static fromFractionalAmount<T extends Currency>(currency: T, numerator: BigintIsh, denominator: BigintIsh): CurrencyAmount<T>;
protected constructor(currency: T, numerator: BigintIsh, denominator?: BigintIsh);
add(other: CurrencyAmount<T>): CurrencyAmount<T>;
subtract(other: CurrencyAmount<T>): CurrencyAmount<T>;
multiply(other: Fraction | BigintIsh): CurrencyAmount<T>;
divide(other: Fraction | BigintIsh): CurrencyAmount<T>;
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
toExact(format?: object): string;
toAsset(...args: any[]): string;
toExtendedAsset(...args: any[]): string;
toExtendedAssetObject(...args: any[]): object;
static toJSON<T extends Currency>(amount: CurrencyAmount<T>): object;
static fromJSON(json: any): CurrencyAmount<Token>;
static toBuffer<T extends Currency>(amount: CurrencyAmount<T>): object;
static fromBuffer(buffer: Uint8Array): CurrencyAmount<Token>;
}