cosmic-interchain-utils
Version:
Cosmic Interchain Utils
45 lines • 2.1 kB
TypeScript
import { BigNumber } from 'bignumber.js';
/**
* Convert the given Wei value to Ether value
* @param value The value to convert.
* @returns Converted value in string type.
*/
export declare function fromWei(value: BigNumber.Value | null | undefined, decimals?: number): string;
/**
* Convert the given Wei value to Ether value,
* round to set number of decimals with a minimum floor, configured per token
* @param value The value to convert.
* @param decimals
* @returns Converted value in string type.
*/
export declare function fromWeiRounded(value: BigNumber.Value | null | undefined, decimals?: number, displayDecimals?: number): string;
/**
* Convert the given value to Wei value
* @param value The value to convert.
* @returns Converted value in string type.
*/
export declare function toWei(value: BigNumber.Value | null | undefined, decimals?: number): string;
/**
* Try to parse the given value into BigNumber.js BigNumber
* @param value The value to parse.
* @returns Parsed value in BigNumber.js BigNumber type.
*/
export declare function tryParseAmount(value: BigNumber.Value | null | undefined): BigNumber | null;
/**
* Checks if an amount is equal of nearly equal to balance within a small margin of error
* Necessary because amounts in the UI are often rounded
* @param amount1 The amount to compare.
* @param amount2 The amount to compare.
* @returns true/false.
*/
export declare function eqAmountApproximate(amount1: BigNumber.Value, amount2: BigNumber.Value, maxDifference: BigNumber.Value): boolean;
/**
* Converts a value with `fromDecimals` decimals to a value with `toDecimals` decimals.
* Incurs a loss of precision when `fromDecimals` > `toDecimals`.
* @param fromDecimals The number of decimals `value` has.
* @param toDecimals The number of decimals to convert `value` to.
* @param value The value to convert.
* @returns `value` represented with `toDecimals` decimals in string type.
*/
export declare function convertDecimals(fromDecimals: number, toDecimals: number, value: BigNumber.Value): string;
//# sourceMappingURL=amount.d.ts.map