1.0.7r
This commit is contained in:
parent
3eb46acd77
commit
2e17933cb2
|
@ -1,3 +1,11 @@
|
|||
### 1.0.7
|
||||
* Fixed release(txid) to wait for promises (order canceling)
|
||||
* Adust elmerlin balance by 9566.250 for release error in block 63014889
|
||||
* Adjust MSHeld Balance by 56 HIVE due to 1.0.4 errors
|
||||
* Added a non-claim to DAO routine
|
||||
* Added voting for DAO routine
|
||||
* Added partial fill tracking on buy orders
|
||||
* Fixed Account Update
|
||||
### 1.0.6
|
||||
* Update fee calculation for buy orders
|
||||
* Fix account update signing and resigning
|
||||
|
|
6
dao.js
6
dao.js
|
@ -148,7 +148,7 @@ function dao(num) {
|
|||
return '@';
|
||||
}
|
||||
}
|
||||
var newOwners = {}, dexfeea = 0, dexfeed = 1, dexmaxa = 0, dexslopea = 0, dexmaxd = 1, dexsloped = 1
|
||||
var newOwners = {}, dexfeea = 0, dexfeed = 1, dexmaxa = 0, dexslopea = 0, dexmaxd = 1, dexsloped = 1, dva = 0, dvd = 1
|
||||
if(j){
|
||||
for (var node in mnode) { //and pay them
|
||||
const wins = mnode[node].wins
|
||||
|
@ -161,6 +161,7 @@ function dao(num) {
|
|||
const feevote = mnode[node].bidRate > 1000 || mnode[node].bidRate < 0 || typeof mnode[node].bidRate != 'number' ? 1000 : mnode[node].bidRate
|
||||
const dmvote = typeof mnode[node].dm != 'number' ? 10000 : mnode[node].dm
|
||||
const dsvote = typeof mnode[node].ds != 'number' ? 0 : mnode[node].ds
|
||||
const dvvote = typeof mnode[node].dv != 'number' ? 1500 : mnode[node].dv
|
||||
mnode[node].ds = dsvote
|
||||
mnode[node].dm = dmvote
|
||||
dexfeea += parseInt(wins * gbal * feevote);
|
||||
|
@ -169,6 +170,8 @@ function dao(num) {
|
|||
dexmaxd += parseInt(wins * gbal * 10000);
|
||||
dexslopea += parseInt(wins * gbal * dsvote);
|
||||
dexsloped += parseInt(wins * gbal * 10000);
|
||||
dva += parseInt(wins * gbal * dvvote);
|
||||
dvd += parseInt(wins * gbal * 10000);
|
||||
i = parseInt(wins / j * b);
|
||||
cbals[node] = cbals[node] ? cbals[node] += i : cbals[node] = i;
|
||||
bals.rn -= i;
|
||||
|
@ -182,6 +185,7 @@ function dao(num) {
|
|||
stats.dex_fee = parseFloat((dexfeea / dexfeed)/100).toFixed(5);
|
||||
stats.dex_max = parseFloat((dexmaxa / dexmaxd)*100).toFixed(2);
|
||||
stats.dex_slope = parseFloat((dexslopea / dexsloped)*100).toFixed(2);
|
||||
stats.daoclaim.v = parseInt(dva / dvd);
|
||||
for(var node in newOwners){
|
||||
newOwners[node].g = runners[node]?.g ? runners[node].g : 0;
|
||||
}
|
||||
|
|
31
index.js
31
index.js
|
@ -1,5 +1,5 @@
|
|||
const config = require('./config');
|
||||
const VERSION = 'v1.0.6'
|
||||
const VERSION = 'v1.0.7r'
|
||||
exports.VERSION = VERSION
|
||||
exports.exit = exit;
|
||||
exports.processor = processor;
|
||||
|
@ -131,8 +131,8 @@ exports.processor = processor
|
|||
//HIVE API CODE
|
||||
|
||||
//Start Program Options
|
||||
dynStart()
|
||||
//startWith('QmQ7HJmJWjMqJ9hUtyCJvAkV2vgiAk6KD6WSizQtF5siEc', true)
|
||||
//dynStart()
|
||||
startWith('Qme19dQFxcKbSikgAsuXAybVhntqr1tmAXb79vfyHSWpfF', true)
|
||||
Watchdog.monitor()
|
||||
|
||||
// API defs
|
||||
|
@ -307,7 +307,8 @@ function startApp() {
|
|||
mss = mem[1], //resign mss
|
||||
msa = mem[2], //if length > 80... sign these
|
||||
mso = mem[3],
|
||||
msso = mem[4]
|
||||
msso = mem[4],
|
||||
mso_keys = Object.keys(mso)
|
||||
let chrops = {},
|
||||
msa_keys = Object.keys(msa)
|
||||
for (var i in a) {
|
||||
|
@ -423,9 +424,9 @@ function startApp() {
|
|||
return new Promise((res, rej)=>{
|
||||
let promises = [HR.margins()]
|
||||
if(num % 100 !== 50){
|
||||
if(mso.length){
|
||||
if(mso_keys.length){
|
||||
promises.push(new Promise((res,rej)=>{
|
||||
osig_submit(consolidate(num, plasma, bh, 'owner'))
|
||||
osig_submit(osign(num, 'mso', mso_keys, bh))
|
||||
.then(nodeOp => {
|
||||
res('SAT')
|
||||
if(plasma.rep)NodeOps.unshift(nodeOp)
|
||||
|
@ -434,7 +435,7 @@ function startApp() {
|
|||
}))
|
||||
} else if(msso.length){
|
||||
promises.push(new Promise((res,rej)=>{
|
||||
osig_submit(osign(num, plasma, msso, bh))
|
||||
osig_submit(osign(num, 'msso', msso, bh))
|
||||
.then(nodeOp => {
|
||||
res('SAT')
|
||||
if(plasma.rep)NodeOps.unshift(nodeOp) //check to see if sig
|
||||
|
@ -717,6 +718,22 @@ function startWith(hash, second) {
|
|||
if (!e && (second || data[0] > API.RAM.head - 325)) {
|
||||
if (hash) {
|
||||
var cleanState = data[1]
|
||||
// cleanState.stats.daoclaim = {
|
||||
// m:'03',
|
||||
// ct: 0,
|
||||
// t: 0,
|
||||
// v: 1500,
|
||||
// }
|
||||
// cleanState.balances.elmerlin += 9566250
|
||||
// cleanState.stats.MSHeld.HIVE += 56000
|
||||
// cleanState.runners = {
|
||||
// regardspk:{
|
||||
// g:30891053
|
||||
// },
|
||||
// ['pizza.spk']:{
|
||||
// g:2920386
|
||||
// }
|
||||
// }
|
||||
store.put([], cleanState, function(err) {
|
||||
if (err) {
|
||||
console.log('errr',err)
|
||||
|
|
14
msa.js
14
msa.js
|
@ -99,31 +99,31 @@ exports.consolidate = (num, plasma, bh, owner) => {
|
|||
})
|
||||
}
|
||||
|
||||
exports.osign = (num, plasma, missed, bh) => {
|
||||
exports.osign = (num, type, missed, bh) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if(bh) {
|
||||
let Pmissed = getPathObj(['msso', `${missed[0].replace(':sigs', '')}`]),
|
||||
let Pmissed = getPathObj([type, `${type == 'mso' ? missed[0] : missed[0].replace(':sigs', '')}`]),
|
||||
Pstats = getPathObj(['stats'])
|
||||
Promise.all([Pmissed, Pstats]).then(mem => {
|
||||
let sig = {
|
||||
block: num,
|
||||
sig: ''
|
||||
},
|
||||
obj = JSON.parse(mem[0]),
|
||||
obj = typeof mem[0] == 'string' ? JSON.parse(mem[0]) : mem[0],
|
||||
ops = [],
|
||||
now = Date.parse(bh.timestamp + '.000Z'),
|
||||
now = Date.parse(bh.timestamp + '.000Z')
|
||||
op = {
|
||||
ref_block_num: bh.block_number & 0xffff,
|
||||
ref_block_prefix: Buffer.from(bh.block_id, 'hex').readUInt32LE(4),
|
||||
expiration: new Date(now + 3660000).toISOString().slice(0, -5),
|
||||
operations: obj.operations,
|
||||
operations: obj.length ? [obj] : obj.operations,
|
||||
extensions: [],
|
||||
}
|
||||
for(var i = 0; i < missed.length; i++){
|
||||
ops.push({type:'del', path:['msso', `${missed[i]}`]})
|
||||
ops.push({type:'del', path:[type, `${missed[i]}`]})
|
||||
}
|
||||
ops.push({type: 'put', path: ['msso', `${num}`], data: stringify(op)})
|
||||
if(mem[1].ms.active_account_auths[config.username] && config.msowner){
|
||||
if(op.operations && mem[1].ms.active_account_auths[config.username] && config.msowner){
|
||||
const stx = hiveClient.auth.signTransaction(op, [config.msowner])
|
||||
sig.sig = stx.signatures[0]
|
||||
}
|
||||
|
|
|
@ -112,6 +112,17 @@ exports.dex_sell = (json, from, active, pc) => {
|
|||
next.amount -= remaining
|
||||
filled += remaining
|
||||
pair += thistarget
|
||||
var partial = {
|
||||
coin: thistarget,
|
||||
token: remaining + thisfee
|
||||
}
|
||||
if(next.partial){
|
||||
next.partial[`${json.transaction_id}`] = partial
|
||||
} else {
|
||||
next.partial = {
|
||||
[`${json.transaction_id}`]: partial
|
||||
}
|
||||
}
|
||||
adds.push([next.from, remaining - thisfee])
|
||||
dex.tick = price.toFixed(6)
|
||||
his[`${json.block_num}:${i}:${json.transaction_id}`] = {type: 'sell', t:Date.parse(json.timestamp), block: json.block_num, base_vol: remaining, target_vol: thistarget + thisfee, target: order.pair, price: next.rate, id: json.transaction_id + i}
|
||||
|
@ -1011,11 +1022,12 @@ exports.transfer = (json, pc) => {
|
|||
|
||||
exports.dex_clear = (json, from, active, pc) => {
|
||||
if (active) {
|
||||
var q = [],
|
||||
promises = []
|
||||
var q = []
|
||||
if (typeof json.txid == 'string') {
|
||||
q.push(json.txid)
|
||||
}
|
||||
} else {
|
||||
pc[0](pc[2])
|
||||
}
|
||||
// else {
|
||||
// q = json.txid
|
||||
// } //book string collision
|
||||
|
@ -1026,34 +1038,34 @@ exports.dex_clear = (json, from, active, pc) => {
|
|||
switch (b.type) {
|
||||
case 'hive:sell':
|
||||
store.get(['dex', 'hive', 'sellOrders', `${b.rate}:${b.txid}`], function(e, a) {
|
||||
if (e) { console.log(e) } else if (isEmpty(a)) { console.log('Nothing here' + b.txid) } else {
|
||||
promises.push(new Promise ((res,rej)=>{release(from, b.txid, json.block_num, json.transaction_id).then(y => {res(y)}).catch(e=>{rej(e)})}))
|
||||
if (e) { pc[0](pc[2]) } else if (isEmpty(a)) { console.log('Nothing here' + b.txid) } else {
|
||||
release(from, b.txid, json.block_num, json.transaction_id).then(y => pc[0](pc[2])).catch(e=>{rej(e)})
|
||||
}
|
||||
})
|
||||
break
|
||||
case 'hbd:sell':
|
||||
store.get(['dex', 'hbd', 'sellOrders', `${b.rate}:${b.txid}`], function(e, a) {
|
||||
if (e) { console.log(e) } else if (isEmpty(a)) { console.log('Nothing here' + b.txid) } else {
|
||||
promises.push(new Promise ((res,rej)=>{release(from, b.txid, json.block_num, json.transaction_id).then(y => {res(y)}).catch(e=>{rej(e)})}))
|
||||
if (e) { pc[0](pc[2]) } else if (isEmpty(a)) { console.log('Nothing here' + b.txid) } else {
|
||||
release(from, b.txid, json.block_num, json.transaction_id).then(y => pc[0](pc[2])).catch(e=>{rej(e)})
|
||||
}
|
||||
})
|
||||
break
|
||||
case 'hive:buy':
|
||||
store.get(['dex', 'hive', 'buyOrders', `${b.rate}:${b.txid}`], function(e, a) {
|
||||
if (e) { console.log(e) } else if (isEmpty(a)) { console.log('Nothing here' + b.txid) } else {
|
||||
promises.push(new Promise ((res,rej)=>{release(from, b.txid, json.block_num, json.transaction_id).then(y => {res(y)}).catch(e=>{rej(e)})}))
|
||||
if (e) { pc[0](pc[2]) } else if (isEmpty(a)) { console.log('Nothing here' + b.txid) } else {
|
||||
release(from, b.txid, json.block_num, json.transaction_id).then(y => pc[0](pc[2])).catch(e=>{rej(e)})
|
||||
}
|
||||
})
|
||||
break
|
||||
case 'hbd:buy':
|
||||
store.get(['dex', 'hbd', 'buyOrders', `${b.rate}:${b.txid}`], function(e, a) {
|
||||
if (e) { console.log(e) } else if (isEmpty(a)) { console.log('Nothing here' + b.txid) } else {
|
||||
promises.push(new Promise ((res,rej)=>{release(from, b.txid, json.block_num, json.transaction_id).then(y => {res(y)}).catch(e=>{rej(e)})}))
|
||||
if (e) { pc[0](pc[2]) } else if (isEmpty(a)) { console.log('Nothing here' + b.txid) } else {
|
||||
release(from, b.txid, json.block_num, json.transaction_id).then(y => pc[0](pc[2])).catch(e=>{rej(e)})
|
||||
}
|
||||
})
|
||||
break
|
||||
default:
|
||||
|
||||
pc[0](pc[2])
|
||||
}
|
||||
} else {
|
||||
pc[0](pc[2])
|
||||
|
@ -1061,7 +1073,6 @@ exports.dex_clear = (json, from, active, pc) => {
|
|||
}
|
||||
})
|
||||
}
|
||||
Promise.all(promises).then(empty => {pc[0](pc[2])}).catch(e=>{console.log(e)})
|
||||
} else {
|
||||
pc[0](pc[2])
|
||||
}
|
||||
|
|
|
@ -47,6 +47,14 @@ exports.node_add = function(json, from, active, pc) {
|
|||
if (ds > 10000) {
|
||||
ds = 10000
|
||||
}
|
||||
var dv = parseInt(json.ds) || 0 //dao vote 10000 = 100.00% / 1 = 0.01%
|
||||
//the portion of the claim that will be put into the chains DAO. Recommend 10-15%
|
||||
if (dv < 0) {
|
||||
dv = 1500
|
||||
}
|
||||
if (dv > 10000) {
|
||||
dv = 1500
|
||||
}
|
||||
var daoRate = parseInt(json.marketingRate) || 0
|
||||
if (daoRate < 1) {
|
||||
daoRate = 0
|
||||
|
@ -80,7 +88,8 @@ exports.node_add = function(json, from, active, pc) {
|
|||
lastGood: 0,
|
||||
report: {},
|
||||
dm,
|
||||
ds
|
||||
ds,
|
||||
dv
|
||||
}
|
||||
if(mskey)data.mskey = mskey
|
||||
ops = [{
|
||||
|
|
|
@ -66,20 +66,39 @@ exports.shares_claim = (json, from, active, pc) => {
|
|||
|
||||
exports.drop_claim = (json, from, active, pc) => {
|
||||
let tbp = getPathNum(['balances', from]),
|
||||
rd = getPathNum(['balances', 'rd']),
|
||||
totp = getPathNum(['stats', 'tokenSupply']),
|
||||
track = getPathObj(['snap', from])
|
||||
Promise.all([tbp, totp, track])
|
||||
track = getPathObj(['snap', from]),
|
||||
burn = getPathObj(['stats', 'daoclaim'])
|
||||
Promise.all([tbp, totp, track, burn, rd])
|
||||
.then(mem => {
|
||||
let tbal = mem[0],
|
||||
supply = mem[1],
|
||||
trak = mem[2],
|
||||
ops = []
|
||||
dao = mem[3],
|
||||
rdbal = mem[4],
|
||||
ops = [],
|
||||
newClaim = 0
|
||||
if(dao.m != json.timestamp.split('-')[1] && (json.timestamp.split('-')[0] == '2022' || json.timestamp.split('-')[0] == '2023') && parseInt(json.timestamp.split('-')[1]) < 4){
|
||||
dao.m = json.timestamp.split('-')[1] //set month
|
||||
newClaim = parseInt((supply - dao.ct) * (dao.v/10000))//only distribute based on new supply
|
||||
dao[json.timestamp.split('-')[1]] = newClaim //set claim reciept by month
|
||||
dao.t += newClaim //add to total
|
||||
dao.ct = supply + newClaim //track the current supply so new tokens only get issued off claims
|
||||
ops.push({ type: 'put', path: ['balances', 'rd'], data: parseInt(rdbal + newClaim) }); //dao account
|
||||
ops.push({ type: 'put', path: ['stats', 'daoclaim'], data: dao }); //this obect
|
||||
ops.push({ type: 'put', path: ['stats', 'tokenSupply'], data: supply + newClaim }); //update supply
|
||||
}
|
||||
if (trak.t) { //get from memory
|
||||
if(trak.l.split('').pop() != parseInt(json.timestamp.split('-')[1], 10).toString(16) && (json.timestamp.split('-')[0] == '2022' || json.timestamp.split('-')[0] == '2023' && parseInt(json.timestamp.split('-')[1]) < 3)){
|
||||
trak.l = parseInt(json.timestamp.split('-')[1], 10).toString(16)
|
||||
trak.t += parseInt(json.timestamp.split('-')[1], 10).toString(16)
|
||||
if(!newClaim)ops.push({ type: 'put', path: ['stats', 'tokenSupply'], data: parseInt(supply + trak.s) });
|
||||
else {
|
||||
ops.pop()
|
||||
ops.push({ type: 'put', path: ['stats', 'tokenSupply'], data: parseInt(supply + trak.s + newClaim) }); //update supply with new claim
|
||||
}
|
||||
ops.push({ type: 'put', path: ['balances', from], data: parseInt(tbal + trak.s) });
|
||||
ops.push({ type: 'put', path: ['stats', 'tokenSupply'], data: parseInt(supply + trak.s) });
|
||||
ops.push({ type: 'put', path: ['snap', from], data: trak });
|
||||
let msg = `@${from}| Claimed ${parseFloat(parseInt(trak.s) / 1000).toFixed(3)} ${config.TOKEN}`
|
||||
if (config.hookurl || config.status) postToDiscord(msg, `${json.block_num}:${json.transaction_id}`)
|
||||
|
@ -99,8 +118,12 @@ exports.drop_claim = (json, from, active, pc) => {
|
|||
t: parseInt(json.timestamp.split('-')[1], 10).toString(16), // total claims
|
||||
l: parseInt(json.timestamp.split('-')[1], 10).toString(16), // last claim month int
|
||||
}
|
||||
if(!newClaim)ops.push({ type: 'put', path: ['stats', 'tokenSupply'], data: parseInt(supply + trak.s) });
|
||||
else {
|
||||
ops.pop()
|
||||
ops.push({ type: 'put', path: ['stats', 'tokenSupply'], data: parseInt(supply + trak.s + newClaim) }); //update supply with new claim
|
||||
}
|
||||
ops.push({ type: 'put', path: ['balances', from], data: parseInt(tbal + trak.s) });
|
||||
ops.push({ type: 'put', path: ['stats', 'tokenSupply'], data: parseInt(supply + trak.s) });
|
||||
ops.push({ type: 'put', path: ['snap', from], data: trak });
|
||||
let msg = `@${from}| Claimed ${parseFloat(parseInt(trak.s) / 1000).toFixed(3)} ${config.TOKEN}`
|
||||
if (config.hookurl || config.status) postToDiscord(msg, `${json.block_num}:${json.transaction_id}`)
|
||||
|
@ -113,8 +136,12 @@ exports.drop_claim = (json, from, active, pc) => {
|
|||
t: parseInt(json.timestamp.split('-')[1], 10).toString(16), // total claims
|
||||
l: parseInt(json.timestamp.split('-')[1], 10).toString(16), // last claim month int
|
||||
}
|
||||
if(!newClaim)ops.push({ type: 'put', path: ['stats', 'tokenSupply'], data: parseInt(supply + trak.s) });
|
||||
else {
|
||||
ops.pop()
|
||||
ops.push({ type: 'put', path: ['stats', 'tokenSupply'], data: parseInt(supply + trak.s + newClaim) }); //update supply with new claim
|
||||
}
|
||||
ops.push({ type: 'put', path: ['balances', from], data: parseInt(tbal + trak.s) });
|
||||
ops.push({ type: 'put', path: ['stats', 'tokenSupply'], data: parseInt(supply + trak.s) });
|
||||
ops.push({ type: 'put', path: ['snap', from], data: trak });
|
||||
let msg = `@${from}| Claimed ${parseFloat(parseInt(trak.s) / 1000).toFixed(3)} ${config.TOKEN}`
|
||||
if (config.hookurl || config.status) postToDiscord(msg, `${json.block_num}:${json.transaction_id}`)
|
||||
|
|
Loading…
Reference in New Issue