diff --git a/dao.js b/dao.js index 972ba55..8a060f8 100644 --- a/dao.js +++ b/dao.js @@ -304,7 +304,7 @@ function dao(num) { dex.hbd.days = {}; dex.hbd.days[num] = hib; } - post = post + `*****\n### DEX Report\n#### Volume Weighted Prices:\n* ${parseFloat(stats.HiveVWMA.rate).toFixed(3)} HIVE per ${config.TOKEN}\n* ${parseFloat(stats.HbdVWMA.rate).toFixed(3)} HBD per ${config.TOKEN}\n#### Daily Volume:\n* ${parseFloat(vol / 1000).toFixed(3)} ${config.TOKEN}\n* ${parseFloat(vols / 1000).toFixed(3)} HIVE\n* ${parseFloat(parseInt(volhbd) / 1000).toFixed(3)} HBD\n*****\n`; + post = post + `*****\n### DEX Report\n#### Prices:\n* ${parseFloat(dex.hive.tick).toFixed(3)} HIVE per ${config.TOKEN}\n* ${parseFloat(dex.hbd.tick).toFixed(3)} HBD per ${config.TOKEN}\n#### Daily Volume:\n* ${parseFloat(vol / 1000).toFixed(3)} ${config.TOKEN}\n* ${parseFloat(vols / 1000).toFixed(3)} HIVE\n* ${parseFloat(parseInt(volhbd) / 1000).toFixed(3)} HBD\n*****\n`; stats.movingWeight.dailyPool = bals.ra bals.rc = bals.rc + bals.ra; bals.ra = 0; diff --git a/index.js b/index.js index f2fd81f..d959461 100755 --- a/index.js +++ b/index.js @@ -122,7 +122,7 @@ var recents = [] //HIVE API CODE //Start Program Options -//startWith('QmbBan3abrGcyibXYvwQMHztfWUDxCmpV7sYHyToEnPnSw', true) //for testing and replaying 58859101 +//startWith('QmSTpxUHoMFaaiLNeCjTFGTjFHfgyfsZ9WDaT1xpTNGhQB', true) //for testing and replaying 58859101 dynStart(config.leader) // API defs diff --git a/processing_routes/dex.js b/processing_routes/dex.js index ab46462..0f4d41e 100644 --- a/processing_routes/dex.js +++ b/processing_routes/dex.js @@ -163,15 +163,10 @@ exports.dex_sell = (json, from, active, pc) => { for(var to in addops){ waitfor.push(add(to, addops[to])) } + const msg = `@${from}| Sell order confirmed.` + if (config.hookurl || config.status) postToDiscord(msg, `${json.block_num}:${json.transaction_id}`) + ops = [{ type: 'put', path: ['feed', `${json.block_num}:${json.transaction_id}`], data: msg }] ops.push({type: 'put', path: ['dex', order.pair], data: dex}) - var hiveTimeWeight = 1 - ((json.block_num - stats[`H${order.pair.substr(1)}VWMA`].block) * 0.000033) - if (hiveTimeWeight < 0) hiveTimeWeight = 0 - if(pair)stats[`H${order.pair.substr(1)}VWMA`] = { - rate: parseFloat((filled + (parseFloat(stats[`H${order.pair.substr(1)}VWMA`].rate) * stats[`H${order.pair.substr(1)}VWMA`].vol * hiveTimeWeight)) / (pair + (stats[`H${order.pair.substr(1)}VWMA`].vol * hiveTimeWeight))).toFixed(6), - block: json.block_num, - vol: parseInt(filled + (stats[`H${order.pair.substr(1)}VWMA`].vol * hiveTimeWeight)) - } - ops.push({type: 'put', path: ['stats'], data: stats}) if(Object.keys(his).length)ops.push({type: 'put', path: ['dex', order.pair, 'his'], data: his}) if(path){ Promise.all([path, ...waitfor]) @@ -221,14 +216,6 @@ exports.transfer = (json, pc) => { ops = [] if (!stats.outOnBlock) { purchase = parseInt(amount / stats.icoPrice * 1000) - var hiveTimeWeight = 1 - ((json.block_num - stats.HiveVWMA.block) * 0.000033) - if (hiveTimeWeight < 0) { hiveTimeWeight = 0 } - if(purchase)hiveVWMA = { - rate: parseFloat((purchase + (parseFloat(stats.HiveVWMA.rate) * stats.HiveVWMA.vol * hiveTimeWeight)) / (purchase + (stats.HiveVWMA.vol * hiveTimeWeight))).toFixed(6), - block: json.block_num, - vol: parseInt(amount + (stats.HiveVWMA.vol * hiveTimeWeight)) - } - //forceCancel(hiveVWMA.rate, 'hive', json.block_num) .then(empty => { if (purchase < i) { i -= purchase @@ -237,8 +224,7 @@ exports.transfer = (json, pc) => { if (config.hookurl || config.status) postToDiscord(msg, `${json.block_num}:${json.transaction_id}`) ops = [{ type: 'put', path: ['feed', `${json.block_num}:${json.transaction_id}`], data: msg }, { type: 'put', path: ['balances', json.from], data: b }, - { type: 'put', path: ['balances', 'ri'], data: i }, - { type: 'put', path: ['stats', 'HiveVWMA'], data: hiveVWMA } + { type: 'put', path: ['balances', 'ri'], data: i } ] if (process.env.npm_lifecycle_event == 'test') pc[2] = ops store.batch(ops, pc) @@ -246,7 +232,6 @@ exports.transfer = (json, pc) => { b += i const left = purchase - i stats.outOnBlock = json.block_num - stats.HiveVWMA = hiveVWMA const msg = `@${json.from}| bought ALL ${parseFloat(parseInt(purchase - left)).toFixed(3)} ${config.TOKEN} with ${parseFloat(parseInt(amount) / 1000).toFixed(3)} HIVE. And bid in the over-auction` if (config.hookurl || config.status) postToDiscord(msg, `${json.block_num}:${json.transaction_id}`) ops = [ @@ -546,13 +531,6 @@ exports.transfer = (json, pc) => { msg = `@${json.from} set a buy order at ${contrate.rate}.` } else { - var hiveTimeWeight = 1 - ((json.block_num - stats[`H${order.pair.substr(1)}VWMA`].block) * 0.000033) - if (hiveTimeWeight < 0) { hiveTimeWeight = 0 } - stats[`H${order.pair.substr(1)}VWMA`] = { - rate: parseFloat((filled + (parseFloat(stats[`H${order.pair.substr(1)}VWMA`].rate) * stats[`H${order.pair.substr(1)}VWMA`].vol * hiveTimeWeight)) / (filled + (stats[`H${order.pair.substr(1)}VWMA`].vol * hiveTimeWeight))).toFixed(6), - block: json.block_num, - vol: parseInt(order.amount + (stats[`H${order.pair.substr(1)}VWMA`].vol * hiveTimeWeight)) - } msg = `@${json.from} | order recieved.` add('rn', fee) } diff --git a/processing_routes/nft.js b/processing_routes/nft.js index 4975ce3..c2b044a 100644 --- a/processing_routes/nft.js +++ b/processing_routes/nft.js @@ -772,22 +772,26 @@ json = { */ exports.nft_add_roy = function(json, from, active, pc) { - let promises = [getPathObj(['sets', json.set])] + let promises = [getPathObj(['sets', json.set]),getPathObj(['balances'])] Promise.all(promises) .then(mem => { - let set = mem[0], failed = false, d + let set = mem[0], bals = mem[1], failed = true, d if (json.distro){ //string verification let pairs = json.distro.split(','), total = 0 + failed = false for (let i = 0; i < pairs.length; i++){ total += parseInt(pairs[i].split('_')[1]) - if(!bals[pairs[i].split('_')[0]])failed = true + if(!bals[pairs[i].split('_')[0]] && pairs[i].split('_')[0] != 'd'){ + failed = true + console.log(pairs[i], bals[pairs[i].split('_')[0]] , pairs[i].split('_')[0] != 'd') + } } if(!failed && total === 10000){ d = json.distro } } - if (set.r == from || set.ra.indexOf(`${from}_` >= 0 && active && !failed) ){ + if (((set.a == from && !set.ra) || set.ra.indexOf(`${from}_` >= 0)) && active && !failed) { let ops = [], amount = 0, running = 0 if (set.ra){ @@ -817,10 +821,11 @@ exports.nft_add_roy = function(json, from, active, pc) { newd.splice(i, 1) } } + d = newd.join(',') } else { set.ra = d } - //ops.push({ type: 'put', path: [json.set, 'ra'], data: {p:json.period,s:json.set} }); + ops.push({ type: 'put', path: ['sets', json.set, 'ra'], data: set.ra }); let msg = `@${from} changed their royalties for ${json.set}` if (config.hookurl || config.status) postToDiscord(msg, `${json.block_num}:${json.transaction_id}`) ops.push({ type: 'put', path: ['feed', `${json.block_num}:${json.transaction_id}`], data: msg }); diff --git a/processor.js b/processor.js index ef58567..9a8f573 100644 --- a/processor.js +++ b/processor.js @@ -83,7 +83,7 @@ module.exports = function(client, steem, currentBlockNumber = 1, blockComputeSpe } getBlock(blockNum) .then((result) => { - block_header = { + block_header[`${blockNum % 20}`] = { timestamp: result.timestamp, block_id: result.block_id, block_number: blockNum @@ -166,7 +166,7 @@ module.exports = function(client, steem, currentBlockNumber = 1, blockComputeSpe if(Vops.length){ transactional(Vops, 0, v[2], v[3], v[4]) } else { - onNewBlock(num, v, v[4].witness_signature, block_header) + onNewBlock(num, v, v[4].witness_signature, block_header[`${num % 20}`]) .then(r => { pc[0](pc[2]) }) @@ -175,7 +175,7 @@ module.exports = function(client, steem, currentBlockNumber = 1, blockComputeSpe }) .catch(e=>{console.log(e);cycleapi()}) } else { - onNewBlock(num, v, v[4].witness_signature, block_header) + onNewBlock(num, v, v[4].witness_signature, block_header[`${num % 20}`]) .then(r => { pc[0](pc[2]) }) @@ -188,7 +188,7 @@ module.exports = function(client, steem, currentBlockNumber = 1, blockComputeSpe pc[1](e) }) } else { - onNewBlock(num, pc, block.witness_signature, block_header) + onNewBlock(num, pc, block.witness_signature, block_header[`${num % 20}`]) .then(r => { r[0]() }) diff --git a/routes/api.js b/routes/api.js index 74187aa..c2becb8 100644 --- a/routes/api.js +++ b/routes/api.js @@ -26,14 +26,8 @@ exports.root = (req, res, next) => { res.setHeader('Content-Type', 'application/json'); store.get(['stats'], function(err, obj) { var stats = obj - hiveVWMA = stats.HiveVWMA - hbdVWMA = stats.HbdVWMA - delete stats.HiveVWMA - delete stats.HbdVWMA res.send(JSON.stringify({ result: stats, - hiveVWMA, - hbdVWMA, behind: RAM.behind, node: config.username, VERSION, diff --git a/state.js b/state.js index 238bb50..8c64aeb 100644 --- a/state.js +++ b/state.js @@ -53,16 +53,6 @@ module.exports = { } }, "stats": { - "HbdVWMA": { - "block": 49747169, - "rate": "0.12500", //set this at ICO price - "vol": 1000 - }, - "HiveVWMA": { - "block": 49936405, - "rate": "0.100000", //set this at ICO price - "vol": 1470 - }, "IPFSRate": 2000, "budgetRate": 2000, "currationRate": 2000, diff --git a/test/test_state.js b/test/test_state.js index c2b0129..dd12f60 100644 --- a/test/test_state.js +++ b/test/test_state.js @@ -53,16 +53,6 @@ module.exports = { } }, "stats": { - "HbdVWMA": { - "block": 1, - "rate": "0.100000", //set this at ICO price - "vol": 1000 - }, - "HiveVWMA": { - "block": 1, - "rate": "0.100000", //set this at ICO price - "vol": 1470 - }, "IPFSRate": 2000, "budgetRate": 2000, "currationRate": 2000,