coinUtils fixes
This commit is contained in:
parent
b7aa655587
commit
5a26f718c5
9 changed files with 63 additions and 71 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue