ethers-maths
Version:
➗ Useful ethers-based math libraries to ease the journey through off-chain fixed-point arithmetics
221 lines (220 loc) • 7.36 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("./constants");
const utils_1 = require("./utils");
const format_1 = require("./format");
const comp_1 = require("./comp");
const percent_1 = require("./percent");
const wad_1 = require("./wad");
const ray_1 = require("./ray");
BigInt.prototype.approxEqAbs = function (y, tolerance = 0) {
return (0, utils_1.approxEqAbs)(this, y, tolerance);
};
BigInt.prototype.abs = function () {
return (0, utils_1.abs)(this);
};
BigInt.prototype.min = function (y, ...others) {
return (0, utils_1.min)(this, y, ...others);
};
BigInt.prototype.max = function (y, ...others) {
return (0, utils_1.max)(this, y, ...others);
};
BigInt.prototype.sum = function (others) {
return (0, utils_1.sum)(this, others);
};
BigInt.prototype.format = function (decimals, digits) {
return (0, format_1.format)(this, decimals, digits);
};
BigInt.prototype.toFloat = function (decimals) {
return (0, format_1.toFloat)(this, decimals);
};
BigInt.prototype.mulDiv = function (other, scale) {
return (0, utils_1.mulDivHalfUp)(this, other, scale);
};
BigInt.prototype.mulDivUp = function (other, scale) {
return (0, utils_1.mulDivUp)(this, other, scale);
};
BigInt.prototype.mulDivDown = function (other, scale) {
return (0, utils_1.mulDivDown)(this, other, scale);
};
BigInt.prototype.compMul = function (other) {
return (0, comp_1.compMul)(this, other);
};
BigInt.prototype.compDiv = function (other) {
return (0, comp_1.compDiv)(this, other);
};
BigInt.prototype.percentAdd = function (pct) {
return (0, percent_1.percentAdd)(this, pct);
};
BigInt.prototype.percentSub = function (pct) {
return (0, percent_1.percentSub)(this, pct);
};
BigInt.prototype.percentMul = function (other) {
return (0, percent_1.percentMul)(this, other);
};
BigInt.prototype.percentMulUp = function (other) {
return (0, percent_1.percentMulUp)(this, other);
};
BigInt.prototype.percentMulDown = function (other) {
return (0, percent_1.percentMulDown)(this, other);
};
BigInt.prototype.percentDiv = function (other) {
return (0, percent_1.percentDiv)(this, other);
};
BigInt.prototype.percentDivUp = function (other) {
return (0, percent_1.percentDivUp)(this, other);
};
BigInt.prototype.percentDivDown = function (other) {
return (0, percent_1.percentDivDown)(this, other);
};
BigInt.prototype.percentAvg = function (other, pct) {
return (0, percent_1.percentAvg)(this, other, pct);
};
BigInt.prototype.percentPow = function (exponent) {
return (0, percent_1.percentPow)(this, exponent);
};
BigInt.prototype.percentPowUp = function (exponent) {
return (0, percent_1.percentPowUp)(this, exponent);
};
BigInt.prototype.percentPowDown = function (exponent) {
return (0, percent_1.percentPowDown)(this, exponent);
};
BigInt.prototype.percentExpN = function (N) {
return (0, percent_1.percentExpN)(this, N);
};
BigInt.prototype.percentToDecimals = function (decimals) {
return (0, percent_1.percentToDecimals)(this, decimals);
};
BigInt.prototype.percentToWad = function () {
return (0, percent_1.percentToWad)(this);
};
BigInt.prototype.percentToRay = function () {
return (0, percent_1.percentToRay)(this);
};
BigInt.prototype.formatPercent = function (digits) {
return (0, percent_1.formatPercent)(this, digits);
};
BigInt.prototype.toPercentFloat = function () {
return (0, percent_1.toPercentFloat)(this);
};
BigInt.prototype.wadAdd = function (wad) {
return (0, wad_1.wadAdd)(this, wad);
};
BigInt.prototype.wadSub = function (wad) {
return (0, wad_1.wadSub)(this, wad);
};
BigInt.prototype.wadMul = function (other) {
return (0, wad_1.wadMul)(this, other);
};
BigInt.prototype.wadMulUp = function (other) {
return (0, wad_1.wadMulUp)(this, other);
};
BigInt.prototype.wadMulDown = function (other) {
return (0, wad_1.wadMulDown)(this, other);
};
BigInt.prototype.wadDiv = function (other) {
return (0, wad_1.wadDiv)(this, other);
};
BigInt.prototype.wadDivUp = function (other) {
return (0, wad_1.wadDivUp)(this, other);
};
BigInt.prototype.wadDivDown = function (other) {
return (0, wad_1.wadDivDown)(this, other);
};
BigInt.prototype.wadAvg = function (other, wad) {
return (0, wad_1.wadAvg)(this, other, wad);
};
BigInt.prototype.wadPow = function (exponent) {
return (0, wad_1.wadPow)(this, exponent);
};
BigInt.prototype.wadPowUp = function (exponent) {
return (0, wad_1.wadPowUp)(this, exponent);
};
BigInt.prototype.wadPowDown = function (exponent) {
return (0, wad_1.wadPowDown)(this, exponent);
};
BigInt.prototype.wadExpN = function (N) {
return (0, wad_1.wadExpN)(this, N);
};
BigInt.prototype.wadToDecimals = function (decimals) {
return (0, wad_1.wadToDecimals)(this, decimals);
};
BigInt.prototype.wadToPercent = function () {
return (0, wad_1.wadToPercent)(this);
};
BigInt.prototype.wadToRay = function () {
return (0, wad_1.wadToRay)(this);
};
BigInt.prototype.formatWad = function (digits) {
return (0, wad_1.formatWad)(this, digits);
};
BigInt.prototype.toWadFloat = function () {
return (0, wad_1.toWadFloat)(this);
};
BigInt.prototype.rayAdd = function (ray) {
return (0, ray_1.rayAdd)(this, ray);
};
BigInt.prototype.raySub = function (ray) {
return (0, ray_1.raySub)(this, ray);
};
BigInt.prototype.rayMul = function (other) {
return (0, ray_1.rayMul)(this, other);
};
BigInt.prototype.rayMulUp = function (other) {
return (0, ray_1.rayMulUp)(this, other);
};
BigInt.prototype.rayMulDown = function (other) {
return (0, ray_1.rayMulDown)(this, other);
};
BigInt.prototype.rayDiv = function (other) {
return (0, ray_1.rayDiv)(this, other);
};
BigInt.prototype.rayDivUp = function (other) {
return (0, ray_1.rayDivUp)(this, other);
};
BigInt.prototype.rayDivDown = function (other) {
return (0, ray_1.rayDivDown)(this, other);
};
BigInt.prototype.rayAvg = function (other, ray) {
return (0, ray_1.rayAvg)(this, other, ray);
};
BigInt.prototype.rayPow = function (exponent) {
return (0, ray_1.rayPow)(this, exponent);
};
BigInt.prototype.rayPowUp = function (exponent) {
return (0, ray_1.rayPowUp)(this, exponent);
};
BigInt.prototype.rayPowDown = function (exponent) {
return (0, ray_1.rayPowDown)(this, exponent);
};
BigInt.prototype.rayExpN = function (N) {
return (0, ray_1.rayExpN)(this, N);
};
BigInt.prototype.rayToDecimals = function (decimals) {
return (0, ray_1.rayToDecimals)(this, decimals);
};
BigInt.prototype.rayToPercent = function () {
return (0, ray_1.rayToPercent)(this);
};
BigInt.prototype.rayToWad = function () {
return (0, ray_1.rayToWad)(this);
};
BigInt.prototype.formatRay = function (digits) {
return (0, ray_1.formatRay)(this, digits);
};
BigInt.prototype.toRayFloat = function () {
return (0, ray_1.toRayFloat)(this);
};
BigInt.PERCENT = constants_1.PERCENT;
BigInt.HALF_PERCENT = constants_1.HALF_PERCENT;
BigInt.WAD = constants_1.WAD;
BigInt.HALF_WAD = constants_1.HALF_WAD;
BigInt.RAY = constants_1.RAY;
BigInt.HALF_RAY = constants_1.HALF_RAY;
BigInt.min = utils_1.min;
BigInt.max = utils_1.max;
BigInt.sum = (others) => (0, utils_1.sum)(0, others);
BigInt.pow10 = utils_1.pow10;
BigInt.parsePercent = percent_1.parsePercent;
BigInt.parseWad = wad_1.parseWad;
BigInt.parseRay = ray_1.parseRay;