Merge pull request #814 from josepfo/feat/add-tickers-and-traders
feat: add support for binance.us, cex.io and ftx
This commit is contained in:
commit
682caddb32
11 changed files with 186 additions and 3 deletions
|
|
@ -4,7 +4,7 @@ const _ = require('lodash/fp')
|
|||
const { ALL } = require('../../plugins/common/ccxt')
|
||||
|
||||
const { BTC, BCH, DASH, ETH, LTC, ZEC, USDT } = COINS
|
||||
const { bitpay, coinbase, itbit, bitstamp, kraken } = ALL
|
||||
const { bitpay, coinbase, itbit, bitstamp, kraken, binanceus, cex, ftx } = ALL
|
||||
|
||||
const TICKER = 'ticker'
|
||||
const WALLET = 'wallet'
|
||||
|
|
@ -16,6 +16,9 @@ const EMAIL = 'email'
|
|||
const ZERO_CONF = 'zeroConf'
|
||||
|
||||
const ALL_ACCOUNTS = [
|
||||
{ code: 'binanceus', display: 'Binance.us', class: TICKER, cryptos: binanceus.CRYPTO },
|
||||
{ code: 'cex', display: 'Cex', class: TICKER, cryptos: cex.CRYPTO },
|
||||
{ code: 'ftx', display: 'Ftx', class: TICKER, cryptos: ftx.CRYPTO },
|
||||
{ code: 'bitpay', display: 'Bitpay', class: TICKER, cryptos: bitpay.CRYPTO },
|
||||
{ code: 'kraken', display: 'Kraken', class: TICKER, cryptos: kraken.CRYPTO },
|
||||
{ code: 'bitstamp', display: 'Bitstamp', class: TICKER, cryptos: bitstamp.CRYPTO },
|
||||
|
|
@ -34,6 +37,9 @@ const ALL_ACCOUNTS = [
|
|||
{ code: 'bitstamp', display: 'Bitstamp', class: EXCHANGE, cryptos: bitstamp.CRYPTO },
|
||||
{ code: 'itbit', display: 'itBit', class: EXCHANGE, cryptos: itbit.CRYPTO },
|
||||
{ code: 'kraken', display: 'Kraken', class: EXCHANGE, cryptos: kraken.CRYPTO },
|
||||
{ code: 'binanceus', display: 'Binance.us', class: EXCHANGE, cryptos: binanceus.CRYPTO },
|
||||
{ code: 'cex', display: 'Cex', class: EXCHANGE, cryptos: cex.CRYPTO },
|
||||
{ code: 'ftx', display: 'Ftx', class: EXCHANGE, cryptos: ftx.CRYPTO },
|
||||
{ code: 'mock-wallet', display: 'Mock (Caution!)', class: WALLET, cryptos: ALL_CRYPTOS, dev: true },
|
||||
{ code: 'no-exchange', display: 'No exchange', class: EXCHANGE, cryptos: ALL_CRYPTOS },
|
||||
{ code: 'mock-exchange', display: 'Mock exchange', class: EXCHANGE, cryptos: ALL_CRYPTOS, dev: true },
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ const SECRET_FIELDS = [
|
|||
'infura.apiSecret',
|
||||
'itbit.clientSecret',
|
||||
'kraken.privateKey',
|
||||
'binanceus.privateKey',
|
||||
'ftx.privateKey',
|
||||
'cex.privateKey',
|
||||
'twilio.authToken'
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,16 @@ const _ = require('lodash/fp')
|
|||
const kraken = require('../exchange/kraken')
|
||||
const bitstamp = require('../exchange/bitstamp')
|
||||
const itbit = require('../exchange/itbit')
|
||||
const binanceus = require('../exchange/binanceus')
|
||||
const cex = require('../exchange/cex')
|
||||
const ftx = require('../exchange/ftx')
|
||||
const bitpay = require('../ticker/bitpay')
|
||||
const { BTC, BCH, DASH, ETH, LTC, ZEC } = COINS
|
||||
|
||||
const ALL = {
|
||||
cex: cex,
|
||||
ftx: ftx,
|
||||
binanceus: binanceus,
|
||||
kraken: kraken,
|
||||
bitstamp: bitstamp,
|
||||
itbit: itbit,
|
||||
|
|
|
|||
18
lib/plugins/exchange/binanceus.js
Normal file
18
lib/plugins/exchange/binanceus.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
const { COINS } = require('lamassu-coins')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const { ORDER_TYPES } = require('./consts')
|
||||
|
||||
const ORDER_TYPE = ORDER_TYPES.MARKET
|
||||
const { BTC, BCH, DASH, ETH, LTC, ZEC, USDT } = COINS
|
||||
const CRYPTO = [BTC, ETH, LTC, DASH, ZEC, BCH, USDT]
|
||||
const FIAT = ['USD']
|
||||
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
|
||||
|
||||
const loadConfig = (account) => {
|
||||
const mapper = {}
|
||||
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
||||
return { ...mapped, timeout: 3000 }
|
||||
}
|
||||
|
||||
module.exports = { loadConfig, REQUIRED_CONFIG_FIELDS, CRYPTO, FIAT, ORDER_TYPE }
|
||||
18
lib/plugins/exchange/cex.js
Normal file
18
lib/plugins/exchange/cex.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
const { COINS } = require('lamassu-coins')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const { ORDER_TYPES } = require('./consts')
|
||||
|
||||
const ORDER_TYPE = ORDER_TYPES.MARKET
|
||||
const { BTC, BCH, DASH, ETH, LTC, USDT } = COINS
|
||||
const CRYPTO = [BTC, ETH, LTC, DASH, BCH, USDT]
|
||||
const FIAT = ['USD', 'EUR']
|
||||
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
|
||||
|
||||
const loadConfig = (account) => {
|
||||
const mapper = {}
|
||||
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
||||
return { ...mapped, timeout: 3000 }
|
||||
}
|
||||
|
||||
module.exports = { loadConfig, REQUIRED_CONFIG_FIELDS, CRYPTO, FIAT, ORDER_TYPE }
|
||||
18
lib/plugins/exchange/ftx.js
Normal file
18
lib/plugins/exchange/ftx.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
const { COINS } = require('lamassu-coins')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const { ORDER_TYPES } = require('./consts')
|
||||
|
||||
const ORDER_TYPE = ORDER_TYPES.MARKET
|
||||
const { BTC, BCH, ETH, LTC, USDT } = COINS
|
||||
const CRYPTO = [BTC, ETH, LTC, BCH, USDT]
|
||||
const FIAT = ['USD']
|
||||
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
|
||||
|
||||
const loadConfig = (account) => {
|
||||
const mapper = {}
|
||||
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
||||
return { ...mapped, timeout: 3000 }
|
||||
}
|
||||
|
||||
module.exports = { loadConfig, REQUIRED_CONFIG_FIELDS, CRYPTO, FIAT, ORDER_TYPE }
|
||||
36
new-lamassu-admin/src/pages/Services/schemas/binanceus.js
Normal file
36
new-lamassu-admin/src/pages/Services/schemas/binanceus.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import * as Yup from 'yup'
|
||||
|
||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||
|
||||
import secretTest from './helper'
|
||||
|
||||
export default {
|
||||
code: 'binanceus',
|
||||
name: 'Binance.us',
|
||||
title: 'Binance.us (Exchange)',
|
||||
elements: [
|
||||
{
|
||||
code: 'apiKey',
|
||||
display: 'API Key',
|
||||
component: TextInputFormik,
|
||||
face: true,
|
||||
long: true
|
||||
},
|
||||
{
|
||||
code: 'privateKey',
|
||||
display: 'Private Key',
|
||||
component: SecretInputFormik
|
||||
}
|
||||
],
|
||||
getValidationSchema: account => {
|
||||
return Yup.object().shape({
|
||||
apiKey: Yup.string()
|
||||
.max(100, 'Too long')
|
||||
.required(),
|
||||
privateKey: Yup.string()
|
||||
.max(100, 'Too long')
|
||||
.test(secretTest(account?.privateKey))
|
||||
})
|
||||
}
|
||||
}
|
||||
36
new-lamassu-admin/src/pages/Services/schemas/cex.js
Normal file
36
new-lamassu-admin/src/pages/Services/schemas/cex.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import * as Yup from 'yup'
|
||||
|
||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||
|
||||
import secretTest from './helper'
|
||||
|
||||
export default {
|
||||
code: 'cex',
|
||||
name: 'Cex',
|
||||
title: 'Cex (Exchange)',
|
||||
elements: [
|
||||
{
|
||||
code: 'apiKey',
|
||||
display: 'API Key',
|
||||
component: TextInputFormik,
|
||||
face: true,
|
||||
long: true
|
||||
},
|
||||
{
|
||||
code: 'privateKey',
|
||||
display: 'Private Key',
|
||||
component: SecretInputFormik
|
||||
}
|
||||
],
|
||||
getValidationSchema: account => {
|
||||
return Yup.object().shape({
|
||||
apiKey: Yup.string()
|
||||
.max(100, 'Too long')
|
||||
.required(),
|
||||
privateKey: Yup.string()
|
||||
.max(100, 'Too long')
|
||||
.test(secretTest(account?.privateKey))
|
||||
})
|
||||
}
|
||||
}
|
||||
36
new-lamassu-admin/src/pages/Services/schemas/ftx.js
Normal file
36
new-lamassu-admin/src/pages/Services/schemas/ftx.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import * as Yup from 'yup'
|
||||
|
||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||
|
||||
import secretTest from './helper'
|
||||
|
||||
export default {
|
||||
code: 'ftx',
|
||||
name: 'Ftx',
|
||||
title: 'Ftx (Exchange)',
|
||||
elements: [
|
||||
{
|
||||
code: 'apiKey',
|
||||
display: 'API Key',
|
||||
component: TextInputFormik,
|
||||
face: true,
|
||||
long: true
|
||||
},
|
||||
{
|
||||
code: 'privateKey',
|
||||
display: 'Private Key',
|
||||
component: SecretInputFormik
|
||||
}
|
||||
],
|
||||
getValidationSchema: account => {
|
||||
return Yup.object().shape({
|
||||
apiKey: Yup.string()
|
||||
.max(100, 'Too long')
|
||||
.required(),
|
||||
privateKey: Yup.string()
|
||||
.max(100, 'Too long')
|
||||
.test(secretTest(account?.privateKey))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
import binanceus from './binanceus'
|
||||
import bitgo from './bitgo'
|
||||
import bitstamp from './bitstamp'
|
||||
import blockcypher from './blockcypher'
|
||||
import cex from './cex'
|
||||
import ftx from './ftx'
|
||||
import infura from './infura'
|
||||
import itbit from './itbit'
|
||||
import kraken from './kraken'
|
||||
|
|
@ -15,5 +18,8 @@ export default {
|
|||
[itbit.code]: itbit,
|
||||
[kraken.code]: kraken,
|
||||
[mailgun.code]: mailgun,
|
||||
[twilio.code]: twilio
|
||||
[twilio.code]: twilio,
|
||||
[binanceus.code]: binanceus,
|
||||
[cex.code]: cex,
|
||||
[ftx.code]: ftx
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ const SAVE_ACCOUNTS = gql`
|
|||
}
|
||||
`
|
||||
|
||||
const isConfigurable = it => R.contains(it)(['kraken', 'itbit', 'bitstamp'])
|
||||
const isConfigurable = it => !R.contains(it)(['mock-exchange'])
|
||||
|
||||
const ChooseExchange = ({ data: currentData, addData }) => {
|
||||
const classes = useStyles()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue