"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bnMax = exports.toBN = exports.toGWei = exports.toWei = exports.bnUint256Max = exports.bnUint32Max = exports.bnOne = exports.bnZero = exports.parseUnits = exports.parseEther = exports.formatUnits = exports.formatEther = void 0;
var tslib_1 = require("tslib");
var ethers_1 = require("ethers");
var bignumber_1 = require("@ethersproject/bignumber");
tslib_1.__exportStar(require("@ethersproject/bignumber"), exports);
exports.formatEther = ethers_1.utils.formatEther, exports.formatUnits = ethers_1.utils.formatUnits, exports.parseEther = ethers_1.utils.parseEther, exports.parseUnits = ethers_1.utils.parseUnits;
exports.bnZero = bignumber_1.BigNumber.from("0");
exports.bnOne = bignumber_1.BigNumber.from("1");
exports.bnUint32Max = bignumber_1.BigNumber.from("0xffffffff");
exports.bnUint256Max = bignumber_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
function toWei(num) {
    return ethers_1.utils.parseEther(num.toString());
}
exports.toWei = toWei;
function toGWei(num) {
    return ethers_1.utils.parseUnits(num.toString(), 9);
}
exports.toGWei = toGWei;
var toBN = function (num, rounding) {
    if (rounding === void 0) { rounding = "floor"; }
    if (num.toString().includes(".")) {
        var _a = num.toString().split("."), integer = _a[0], decimal = _a[1];
        var roundUp = decimal.length > 0 && (rounding === "ceil" || (rounding === "round" && parseInt(decimal[0]) >= 5));
        return bignumber_1.BigNumber.from(integer).add(roundUp ? 1 : 0);
    }
    return bignumber_1.BigNumber.from(num.toString());
};
exports.toBN = toBN;
var bnMax = function (val, cmp) {
    return val.gt(cmp) ? val : cmp;
};
exports.bnMax = bnMax;
//# sourceMappingURL=BigNumberUtils.js.map