@sushiswap/math
Version:
96 lines (83 loc) • 3.23 kB
TypeScript
import JSBI from 'jsbi';
export { default as JSBI } from 'jsbi';
declare const _default$1: any;
declare type BigintIsh = JSBI | number | string;
declare enum Rounding {
ROUND_DOWN = 0,
ROUND_HALF_UP = 1,
ROUND_UP = 3
}
declare class Fraction {
readonly numerator: JSBI;
readonly denominator: JSBI;
constructor(numerator: BigintIsh, denominator?: BigintIsh);
private static tryParseFraction;
get quotient(): JSBI;
get remainder(): Fraction;
invert(): Fraction;
add(other: Fraction | BigintIsh): Fraction;
subtract(other: Fraction | BigintIsh): Fraction;
lessThan(other: Fraction | BigintIsh): boolean;
equalTo(other: Fraction | BigintIsh): boolean;
greaterThan(other: Fraction | BigintIsh): boolean;
multiply(other: Fraction | BigintIsh): Fraction;
divide(other: Fraction | BigintIsh): Fraction;
toSignificant(significantDigits: number, format?: object, rounding?: Rounding): string;
toFixed(decimalPlaces: number, format?: object, rounding?: Rounding): string;
/**
* Helper method for converting any super class back to a fraction
*/
get asFraction(): Fraction;
}
declare class Percent extends Fraction {
/**
* This boolean prevents a fraction from being interpreted as a Percent
*/
readonly isPercent: true;
add(other: Fraction | BigintIsh): Percent;
subtract(other: Fraction | BigintIsh): Percent;
multiply(other: Fraction | BigintIsh): Percent;
divide(other: Fraction | BigintIsh): Percent;
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
}
declare const ZERO: JSBI;
declare const ONE: JSBI;
declare const TWO: JSBI;
declare const THREE: JSBI;
declare const FIVE: JSBI;
declare const TEN: JSBI;
declare const _100: JSBI;
declare const _997: JSBI;
declare const _1000: JSBI;
declare const _9994: JSBI;
declare const _9995: JSBI;
declare const _10000: JSBI;
declare const _1e18: JSBI;
declare const _1e12: JSBI;
declare const _1e9: JSBI;
declare const _1e6: JSBI;
declare const MAX_SAFE_INTEGER: JSBI;
declare const MAX_UINT256: JSBI;
declare const MAX_UINT128: JSBI;
declare const ZERO_PERCENT: Percent;
declare const _default: any;
declare function difference(a: JSBI, b: JSBI): JSBI;
/**
* Returns the biggest member of the array
* @param values the values from which the biggest gets returned
* @returns the biggest memmber of the array
*/
declare function maximum(...values: JSBI[]): JSBI;
/**
* Returns the smallest member of the array
* @param values the values from which the smallest gets returned
* @returns the smallest memmber of the array
*/
declare function minimum(...values: JSBI[]): JSBI;
/**
* Computes floor(sqrt(value))
* @param value the value for which to compute the square root, rounded down
*/
declare function sqrt(value: JSBI): JSBI;
export { _default$1 as Big, BigintIsh, _default as Decimal, FIVE, Fraction, MAX_SAFE_INTEGER, MAX_UINT128, MAX_UINT256, ONE, Percent, Rounding, TEN, THREE, TWO, ZERO, ZERO_PERCENT, _100, _1000, _10000, _1e12, _1e18, _1e6, _1e9, _997, _9994, _9995, difference, maximum, minimum, sqrt };