Merge pull request #1211 from josepfo/feat/add-binance-support
Feat: add binance support
This commit is contained in:
commit
6df291bda0
9 changed files with 76 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ const _ = require('lodash/fp')
|
||||||
const { ALL } = require('../../plugins/common/ccxt')
|
const { ALL } = require('../../plugins/common/ccxt')
|
||||||
|
|
||||||
const { BTC, BCH, DASH, ETH, LTC, ZEC, XMR } = COINS
|
const { BTC, BCH, DASH, ETH, LTC, ZEC, XMR } = COINS
|
||||||
const { bitpay, coinbase, itbit, bitstamp, kraken, binanceus, cex, ftx } = ALL
|
const { bitpay, coinbase, itbit, bitstamp, kraken, binanceus, cex, ftx, binance } = ALL
|
||||||
|
|
||||||
const TICKER = 'ticker'
|
const TICKER = 'ticker'
|
||||||
const WALLET = 'wallet'
|
const WALLET = 'wallet'
|
||||||
|
|
@ -17,6 +17,7 @@ const ZERO_CONF = 'zeroConf'
|
||||||
const WALLET_SCORING = 'wallet_scoring'
|
const WALLET_SCORING = 'wallet_scoring'
|
||||||
|
|
||||||
const ALL_ACCOUNTS = [
|
const ALL_ACCOUNTS = [
|
||||||
|
{ code: 'binance', display: 'Binance', class: TICKER, cryptos: binance.CRYPTO },
|
||||||
{ code: 'binanceus', display: 'Binance.us', class: TICKER, cryptos: binanceus.CRYPTO },
|
{ code: 'binanceus', display: 'Binance.us', class: TICKER, cryptos: binanceus.CRYPTO },
|
||||||
{ code: 'cex', display: 'CEX', class: TICKER, cryptos: cex.CRYPTO },
|
{ code: 'cex', display: 'CEX', class: TICKER, cryptos: cex.CRYPTO },
|
||||||
{ code: 'ftx', display: 'FTX', class: TICKER, cryptos: ftx.CRYPTO },
|
{ code: 'ftx', display: 'FTX', class: TICKER, cryptos: ftx.CRYPTO },
|
||||||
|
|
@ -39,6 +40,7 @@ const ALL_ACCOUNTS = [
|
||||||
{ code: 'bitstamp', display: 'Bitstamp', class: EXCHANGE, cryptos: bitstamp.CRYPTO },
|
{ code: 'bitstamp', display: 'Bitstamp', class: EXCHANGE, cryptos: bitstamp.CRYPTO },
|
||||||
{ code: 'itbit', display: 'itBit', class: EXCHANGE, cryptos: itbit.CRYPTO },
|
{ code: 'itbit', display: 'itBit', class: EXCHANGE, cryptos: itbit.CRYPTO },
|
||||||
{ code: 'kraken', display: 'Kraken', class: EXCHANGE, cryptos: kraken.CRYPTO },
|
{ code: 'kraken', display: 'Kraken', class: EXCHANGE, cryptos: kraken.CRYPTO },
|
||||||
|
{ code: 'binance', display: 'Binance', class: EXCHANGE, cryptos: binance.CRYPTO },
|
||||||
{ code: 'binanceus', display: 'Binance.us', class: EXCHANGE, cryptos: binanceus.CRYPTO },
|
{ code: 'binanceus', display: 'Binance.us', class: EXCHANGE, cryptos: binanceus.CRYPTO },
|
||||||
{ code: 'cex', display: 'CEX', class: EXCHANGE, cryptos: cex.CRYPTO },
|
{ code: 'cex', display: 'CEX', class: EXCHANGE, cryptos: cex.CRYPTO },
|
||||||
{ code: 'ftx', display: 'FTX', class: EXCHANGE, cryptos: ftx.CRYPTO },
|
{ code: 'ftx', display: 'FTX', class: EXCHANGE, cryptos: ftx.CRYPTO },
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ const SECRET_FIELDS = [
|
||||||
'binanceus.privateKey',
|
'binanceus.privateKey',
|
||||||
'ftx.privateKey',
|
'ftx.privateKey',
|
||||||
'cex.privateKey',
|
'cex.privateKey',
|
||||||
|
'binance.privateKey',
|
||||||
'twilio.authToken'
|
'twilio.authToken'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ const binanceus = require('../exchange/binanceus')
|
||||||
const cex = require('../exchange/cex')
|
const cex = require('../exchange/cex')
|
||||||
const ftx = require('../exchange/ftx')
|
const ftx = require('../exchange/ftx')
|
||||||
const bitpay = require('../ticker/bitpay')
|
const bitpay = require('../ticker/bitpay')
|
||||||
|
const binance = require('../exchange/binance')
|
||||||
|
|
||||||
const { BTC, BCH, DASH, ETH, LTC, ZEC } = COINS
|
const { BTC, BCH, DASH, ETH, LTC, ZEC } = COINS
|
||||||
|
|
||||||
const ALL = {
|
const ALL = {
|
||||||
|
|
@ -21,7 +23,8 @@ const ALL = {
|
||||||
coinbase: {
|
coinbase: {
|
||||||
CRYPTO: [BTC, ETH, LTC, DASH, ZEC, BCH],
|
CRYPTO: [BTC, ETH, LTC, DASH, ZEC, BCH],
|
||||||
FIAT: 'ALL_CURRENCIES'
|
FIAT: 'ALL_CURRENCIES'
|
||||||
}
|
},
|
||||||
|
binance: binance
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildMarket (fiatCode, cryptoCode, serviceName) {
|
function buildMarket (fiatCode, cryptoCode, serviceName) {
|
||||||
|
|
|
||||||
20
lib/plugins/exchange/binance.js
Normal file
20
lib/plugins/exchange/binance.js
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
const { COINS } = require('@lamassu/coins')
|
||||||
|
const _ = require('lodash/fp')
|
||||||
|
|
||||||
|
const { ORDER_TYPES } = require('./consts')
|
||||||
|
|
||||||
|
const ORDER_TYPE = ORDER_TYPES.MARKET
|
||||||
|
const { BTC, BCH, XMR, ETH, LTC, ZEC } = COINS
|
||||||
|
const CRYPTO = [BTC, ETH, LTC, ZEC, BCH, XMR]
|
||||||
|
const FIAT = ['USD', 'EUR']
|
||||||
|
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
|
||||||
|
|
||||||
|
const loadConfig = (account) => {
|
||||||
|
const mapper = {
|
||||||
|
'privateKey': 'secret'
|
||||||
|
}
|
||||||
|
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
||||||
|
return { ...mapped, timeout: 3000 }
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { loadConfig, REQUIRED_CONFIG_FIELDS, CRYPTO, FIAT, ORDER_TYPE }
|
||||||
|
|
@ -10,7 +10,9 @@ const FIAT = ['USD']
|
||||||
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
|
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
|
||||||
|
|
||||||
const loadConfig = (account) => {
|
const loadConfig = (account) => {
|
||||||
const mapper = {}
|
const mapper = {
|
||||||
|
'privateKey': 'secret'
|
||||||
|
}
|
||||||
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
||||||
return { ...mapped, timeout: 3000 }
|
return { ...mapped, timeout: 3000 }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@ const FIAT = ['USD', 'EUR']
|
||||||
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
|
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
|
||||||
|
|
||||||
const loadConfig = (account) => {
|
const loadConfig = (account) => {
|
||||||
const mapper = {}
|
const mapper = {
|
||||||
|
'privateKey': 'secret'
|
||||||
|
}
|
||||||
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
||||||
return { ...mapped, timeout: 3000 }
|
return { ...mapped, timeout: 3000 }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@ const FIAT = ['USD']
|
||||||
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
|
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
|
||||||
|
|
||||||
const loadConfig = (account) => {
|
const loadConfig = (account) => {
|
||||||
const mapper = {}
|
const mapper = {
|
||||||
|
'privateKey': 'secret'
|
||||||
|
}
|
||||||
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
||||||
return { ...mapped, timeout: 3000 }
|
return { ...mapped, timeout: 3000 }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
36
new-lamassu-admin/src/pages/Services/schemas/binance.js
Normal file
36
new-lamassu-admin/src/pages/Services/schemas/binance.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: 'binance',
|
||||||
|
name: 'Binance',
|
||||||
|
title: 'Binance (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('The API key must be a string')
|
||||||
|
.max(100, 'The API key is too long')
|
||||||
|
.required('The API key is required'),
|
||||||
|
privateKey: Yup.string('The private key must be a string')
|
||||||
|
.max(100, 'The private key is too long')
|
||||||
|
.test(secretTest(account?.privateKey, 'private key'))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import binance from './binance'
|
||||||
import binanceus from './binanceus'
|
import binanceus from './binanceus'
|
||||||
import bitgo from './bitgo'
|
import bitgo from './bitgo'
|
||||||
import bitstamp from './bitstamp'
|
import bitstamp from './bitstamp'
|
||||||
|
|
@ -23,5 +24,6 @@ export default {
|
||||||
[binanceus.code]: binanceus,
|
[binanceus.code]: binanceus,
|
||||||
[cex.code]: cex,
|
[cex.code]: cex,
|
||||||
[ftx.code]: ftx,
|
[ftx.code]: ftx,
|
||||||
[ciphertrace.code]: ciphertrace
|
[ciphertrace.code]: ciphertrace,
|
||||||
|
[binance.code]: binance
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue