feat: binance exchange support
This commit is contained in:
parent
81702e2132
commit
0fc7ffefb1
10 changed files with 77 additions and 7 deletions
|
|
@ -4,7 +4,7 @@ const _ = require('lodash/fp')
|
|||
const { ALL } = require('../../plugins/common/ccxt')
|
||||
|
||||
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 WALLET = 'wallet'
|
||||
|
|
@ -17,6 +17,7 @@ const ZERO_CONF = 'zeroConf'
|
|||
const WALLET_SCORING = 'wallet_scoring'
|
||||
|
||||
const ALL_ACCOUNTS = [
|
||||
{ code: 'binance', display: 'Binance', class: TICKER, cryptos: binance.CRYPTO },
|
||||
{ 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 },
|
||||
|
|
@ -39,6 +40,7 @@ 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: 'binance', display: 'Binance', class: EXCHANGE, cryptos: binance.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 },
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ const SECRET_FIELDS = [
|
|||
'binanceus.privateKey',
|
||||
'ftx.privateKey',
|
||||
'cex.privateKey',
|
||||
'binance.privateKey',
|
||||
'twilio.authToken'
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ const binanceus = require('../exchange/binanceus')
|
|||
const cex = require('../exchange/cex')
|
||||
const ftx = require('../exchange/ftx')
|
||||
const bitpay = require('../ticker/bitpay')
|
||||
const binance = require('../exchange/binance')
|
||||
|
||||
const { BTC, BCH, DASH, ETH, LTC, ZEC } = COINS
|
||||
|
||||
const ALL = {
|
||||
|
|
@ -21,7 +23,8 @@ const ALL = {
|
|||
coinbase: {
|
||||
CRYPTO: [BTC, ETH, LTC, DASH, ZEC, BCH],
|
||||
FIAT: 'ALL_CURRENCIES'
|
||||
}
|
||||
},
|
||||
binance: binance
|
||||
}
|
||||
|
||||
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 loadConfig = (account) => {
|
||||
const mapper = {}
|
||||
const mapper = {
|
||||
'privateKey': 'secret'
|
||||
}
|
||||
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
||||
return { ...mapped, timeout: 3000 }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ const FIAT = ['USD', 'EUR']
|
|||
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
|
||||
|
||||
const loadConfig = (account) => {
|
||||
const mapper = {}
|
||||
const mapper = {
|
||||
'privateKey': 'secret'
|
||||
}
|
||||
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
||||
return { ...mapped, timeout: 3000 }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ const FIAT = ['USD']
|
|||
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
|
||||
|
||||
const loadConfig = (account) => {
|
||||
const mapper = {}
|
||||
const mapper = {
|
||||
'privateKey': 'secret'
|
||||
}
|
||||
const mapped = _.mapKeys(key => mapper[key] ? mapper[key] : key)(account)
|
||||
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 bitgo from './bitgo'
|
||||
import bitstamp from './bitstamp'
|
||||
|
|
@ -23,5 +24,6 @@ export default {
|
|||
[binanceus.code]: binanceus,
|
||||
[cex.code]: cex,
|
||||
[ftx.code]: ftx,
|
||||
[ciphertrace.code]: ciphertrace
|
||||
[ciphertrace.code]: ciphertrace,
|
||||
[binance.code]: binance
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@
|
|||
"server": "nodemon bin/lamassu-server --mockSms --logLevel silly",
|
||||
"admin-server": "nodemon bin/lamassu-admin-server --dev --logLevel silly",
|
||||
"graphql-server": "nodemon bin/new-graphql-dev-insecure",
|
||||
"watch": "concurrently \"npm:server\" \"npm:admin-server\" \"npm:graphql-server\"",
|
||||
"watch": "concurrently \"npm:server\" \"npm:admin-server\"",
|
||||
"stress-test": "cd ./test/stress/ && node index.js 50 -v"
|
||||
},
|
||||
"nodemonConfig": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue