add seedPath config; fix lowBalanceMargin bug
This commit is contained in:
parent
73588a978e
commit
c088e092b8
3 changed files with 7 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -31,3 +31,4 @@ raqia.json
|
|||
|
||||
scratch/
|
||||
seeds/
|
||||
lamassu.json
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ module.exports = function (options) {
|
|||
|
||||
lamassuConfig = new LamassuConfig(connectionString)
|
||||
|
||||
plugins.init(connectionString)
|
||||
const seedPath = options.seedPath || './seeds/seed.txt'
|
||||
plugins.init(connectionString, seedPath)
|
||||
|
||||
lamassuConfig.load(function (err, config) {
|
||||
if (err) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ const SWEEP_LIVE_HD_INTERVAL = T.minute
|
|||
const SWEEP_OLD_HD_INTERVAL = 2 * T.minutes
|
||||
const TRADE_INTERVAL = T.minute
|
||||
const TRADE_TTL = 5 * T.minutes
|
||||
const LOW_BALANCE_MARGIN_DEFAULT = 1.05
|
||||
|
||||
let cryptoCodes = null
|
||||
|
||||
|
|
@ -59,8 +60,8 @@ const coins = {
|
|||
let alertFingerprint = null
|
||||
let lastAlertTime = null
|
||||
|
||||
exports.init = function init (connectionString) {
|
||||
const masterSeed = new Buffer(fs.readFileSync('seeds/seed.txt', 'utf8').trim(), 'hex')
|
||||
exports.init = function init (connectionString, seedPath) {
|
||||
const masterSeed = new Buffer(fs.readFileSync(seedPath, 'utf8').trim(), 'hex')
|
||||
hkdf = new HKDF('sha256', 'lamassu-server-salt', masterSeed)
|
||||
|
||||
db.init(connectionString)
|
||||
|
|
@ -401,7 +402,7 @@ exports.fiatBalance = function fiatBalance (cryptoCode) {
|
|||
|
||||
// `lowBalanceMargin` is our safety net. It's a number > 1, and we divide
|
||||
// all our balances by it to provide a safety margin.
|
||||
const lowBalanceMargin = cachedConfig.exchanges.settings.lowBalanceMargin
|
||||
const lowBalanceMargin = cachedConfig.exchanges.settings.lowBalanceMargin || LOW_BALANCE_MARGIN_DEFAULT
|
||||
|
||||
const unitScale = new BigNumber(10).pow(coins[cryptoCode].unitScale)
|
||||
const fiatTransferBalance = lastBalance.div(unitScale).times(rate).div(lowBalanceMargin)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue