don't trade if no exchange

This commit is contained in:
Josh Harvey 2016-12-08 00:13:59 +02:00
parent e6a7a601c9
commit c80f92c227
3 changed files with 20 additions and 5 deletions

View file

@ -8,11 +8,16 @@ function noExchangeError (cryptoCode) {
return err
}
function lookupExchange (cryptoCode) {
const settings = settingsLoader.settings()
return configManager.cryptoScoped(cryptoCode, settings.config).exchange
}
function fetchExchange (cryptoCode) {
return Promise.resolve()
.then(() => {
const settings = settingsLoader.settings()
const plugin = configManager.cryptoScoped(cryptoCode, settings.config).exchange
const plugin = lookupExchange(cryptoCode)
if (!plugin) throw noExchangeError(cryptoCode)
const account = settings.accounts[plugin]
const exchange = require('lamassu-' + plugin)
@ -31,7 +36,12 @@ function sell (cryptoAtoms, fiatCode, cryptoCode) {
.then(r => r.exchange.sell(r.account, cryptoAtoms, fiatCode, cryptoCode))
}
function active (fiatCode, cryptoCode) {
return !!lookupExchange(cryptoCode)
}
module.exports = {
buy,
sell
sell,
active
}