(bn, decimals, precision)
| 318 | * @returns {number} |
| 319 | */ |
| 320 | export 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 | * |
no outgoing calls
no test coverage detected