diff --git a/.env.example b/.env.example index 73647ec..3142d95 100644 --- a/.env.example +++ b/.env.example @@ -5,4 +5,6 @@ EOS_PAYER_PERMISION = "resourcebot" EOS_PAYER_PRIVATE_KEY = "5..." EOS_WATCH_ACCOUNT = "genesis.eden" EOS_POWERUP_THRESHOLD = 10000 -EOS_POWERUP_AMOUNT = 0.1 \ No newline at end of file +EOS_NET_FRAC = 5555555555 +EOS_CPU_FRAC = 5555555555 +EOS_POWERUP_AMOUNT = 0.1 diff --git a/src/config/eos.config.js b/src/config/eos.config.js index 78b174d..a81c0dc 100644 --- a/src/config/eos.config.js +++ b/src/config/eos.config.js @@ -6,5 +6,7 @@ module.exports = { pvtKey: process.env.EOS_PAYER_PRIVATE_KEY, watchAccount: process.env.EOS_WATCH_ACCOUNT, powerUpAmount: process.env.EOS_POWERUP_AMOUNT, + net: process.env.EOS_NET_FRAC, + cpu: process.env.EOS_CPU_FRAC, threshold: process.env.EOS_POWERUP_THRESHOLD } diff --git a/src/index.js b/src/index.js index 3e6d17f..7f7976f 100644 --- a/src/index.js +++ b/src/index.js @@ -24,13 +24,21 @@ async function init() { const accountStats = await eosUtil.getAccount(account) const existingCPU = Number(accountStats.cpu_limit.available) + const usedCPU = Number(accountStats.cpu_limit.used) console.log('Existing CPU:', existingCPU) + console.log('Used CPU:', usedCPU) const existingNET = Number(accountStats.net_limit.available) + const usedNET = Number(accountStats.net_limit.used) console.log('Existing NET:', existingNET) + console.log('Used NET:', usedNET) + console.log('Current CPU Usage Percentage: ', (usedCPU/existingCPU)*100, '%') - if (existingCPU > eosConfig.threshold) continue + if ((usedCPU/existingCPU) < eosConfig.threshold) continue console.log('Available CPU is below threshhold of: ', eosConfig.threshold) + console.log('Power Up Amount: ', eosConfig.powerUpAmount + ' EOS') + console.log('NET_frac: ', eosConfig.net) + console.log('CPU_frac: ', eosConfig.cpu) const transact = await eosUtil .transact([ @@ -42,9 +50,9 @@ async function init() { payer, receiver: account, days: 1, - net_frac: 1000, - cpu_frac: 25000, - max_payment: eosConfig.powerUpAmount + '.0000 EOS' + net_frac: eosConfig.net, + cpu_frac: eosConfig.cpu, + max_payment: eosConfig.powerUpAmount + ' EOS' } } ])