format for latest standard
This commit is contained in:
parent
4108efd9c7
commit
c2af183911
77 changed files with 1697 additions and 1693 deletions
|
|
@ -11,7 +11,7 @@ function getBuyPrice (obj) {
|
|||
url: `https://api.coinbase.com/v2/prices/${currencyPair}/buy`,
|
||||
headers: {'CB-Version': '2017-07-10'}
|
||||
})
|
||||
.then(r => r.data)
|
||||
.then(r => r.data)
|
||||
}
|
||||
|
||||
function getSellPrice (obj) {
|
||||
|
|
@ -22,34 +22,33 @@ function getSellPrice (obj) {
|
|||
url: `https://api.coinbase.com/v2/prices/${currencyPair}/sell`,
|
||||
headers: {'CB-Version': '2017-07-10'}
|
||||
})
|
||||
.then(r => r.data)
|
||||
.then(r => r.data)
|
||||
}
|
||||
|
||||
function ticker (account, fiatCode, cryptoCode) {
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
if (!_.includes(cryptoCode, ['BTC', 'ETH', 'LTC', 'BCH'])) {
|
||||
throw new Error('Unsupported crypto: ' + cryptoCode)
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
const currencyPair = `${cryptoCode}-${fiatCode}`
|
||||
const promises = [
|
||||
getBuyPrice({currencyPair}),
|
||||
getSellPrice({currencyPair})
|
||||
]
|
||||
.then(() => {
|
||||
if (!_.includes(cryptoCode, ['BTC', 'ETH', 'LTC', 'BCH'])) {
|
||||
throw new Error('Unsupported crypto: ' + cryptoCode)
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
const currencyPair = `${cryptoCode}-${fiatCode}`
|
||||
const promises = [
|
||||
getBuyPrice({currencyPair}),
|
||||
getSellPrice({currencyPair})
|
||||
]
|
||||
|
||||
return Promise.all(promises)
|
||||
})
|
||||
.then(([buyPrice, sellPrice]) => ({
|
||||
rates: {
|
||||
ask: BN(buyPrice.data.amount),
|
||||
bid: BN(sellPrice.data.amount)
|
||||
}
|
||||
}))
|
||||
return Promise.all(promises)
|
||||
})
|
||||
.then(([buyPrice, sellPrice]) => ({
|
||||
rates: {
|
||||
ask: BN(buyPrice.data.amount),
|
||||
bid: BN(sellPrice.data.amount)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ticker
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue