MCPcopy Create free account
hub / github.com/SmartTokenLabs/TokenScript / bnStringPrecision

Function bnStringPrecision

bootstrap-js/modules/ts_helpers.js:320–336  ·  view source on GitHub ↗
(bn, decimals, precision)

Source from the content-addressed store, hash-verified

318 * @returns {number}
319 */
320export function bnStringPrecision(bn, decimals, precision){
321 bn = ethers.BigNumber.from(bn);
322 if (precision > 15) precision = 15;
323 // while (precision > 15){
324 // bn = bn.mul(10**15);
325 // precision -= 15;
326 // }
327 bn = bn.mul(10**precision);
328
329 while (decimals > 15){
330 bn = bn.div(10**15);
331 decimals -= 15;
332 }
333 bn = bn.div(10**decimals);
334
335 return bn.toNumber() / 10**precision;
336}
337
338/**
339 *

Callers 2

getPropsMethod · 0.90
filterResultConverterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected