Support ZEC

This commit is contained in:
Josh Harvey 2017-06-24 01:33:10 +03:00
parent 9b51565303
commit 45e6e2b82d
10 changed files with 105 additions and 47 deletions

View file

@ -1,17 +1,27 @@
var BigNumber = require('bignumber.js')
const BigNumber = require('bignumber.js')
var TEN = new BigNumber(10)
const coinUtils = require('../../coin-utils')
var UNIT_SCALES = {
BTC: 8,
ETH: 18
const TEN = new BigNumber(10)
const PAIRS = {
BTC: {
USD: 'XXBTZUSD',
EUR: 'XXBTZEUR'
},
ETH: {
USD: 'XETHZUSD',
EUR: 'XETHZEUR'
},
ZEC: {
USD: 'XZECZUSD',
EUR: 'XZECZEUR'
}
}
function unitScale (cryptoCoin) {
return UNIT_SCALES[cryptoCoin]
}
module.exports = {PAIRS, toUnit}
exports.toUnit = function toUnit (cryptoAtoms, cryptoCoin) {
var scale = TEN.pow(unitScale(cryptoCoin))
function toUnit (cryptoAtoms, cryptoCoin) {
var scale = TEN.pow(coinUtils.unitScale(cryptoCoin))
return cryptoAtoms.div(scale)
}