coinUtils fixes

This commit is contained in:
Josh Harvey 2017-07-09 13:31:01 +03:00
parent b7aa655587
commit 5a26f718c5
9 changed files with 63 additions and 71 deletions

View file

@ -1,9 +1,5 @@
const BigNumber = require('bignumber.js')
const coinUtils = require('../../coin-utils')
const TEN = new BigNumber(10)
const PAIRS = {
BTC: {
USD: 'XXBTZUSD',
@ -29,7 +25,8 @@ const PAIRS = {
module.exports = {PAIRS, toUnit}
function toUnit (cryptoAtoms, cryptoCoin) {
var scale = TEN.pow(coinUtils.unitScale(cryptoCoin))
return cryptoAtoms.div(scale)
function toUnit (cryptoAtoms, cryptoCode) {
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
const unitScale = cryptoRec.unitScale
return cryptoAtoms.shift(-unitScale)
}