UNPKG

ethers-maths

Version:

➗ Useful ethers-based math libraries to ease the journey through off-chain fixed-point arithmetics

14 lines (13 loc) 531 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.compDiv = exports.compMul = void 0; const ethers_1 = require("ethers"); const constants_1 = require("./constants"); const compMul = (x, other) => { return ((0, ethers_1.toBigInt)(x) * (0, ethers_1.toBigInt)(other)) / constants_1.WAD; }; exports.compMul = compMul; const compDiv = (x, other) => { return ((0, ethers_1.toBigInt)(x) * constants_1.WAD_SQUARED) / (0, ethers_1.toBigInt)(other) / constants_1.WAD; }; exports.compDiv = compDiv;