From a1239a7c5806d5320599b8ac4a46ec3a1c696341 Mon Sep 17 00:00:00 2001 From: TheCaJlaT <66368050+TheCaJlaT@users.noreply.github.com> Date: Wed, 1 Sep 2021 13:45:43 +0300 Subject: [PATCH] v1.0.2 --- index.js | 11 +++++++---- package.json | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 79821ce..52aaf9e 100644 --- a/index.js +++ b/index.js @@ -39,7 +39,7 @@ class Crypto { async balance(id) { let res = await this.call('GetUserBalance', id) - return res.balance + return res } async buy(name) { @@ -60,11 +60,14 @@ class Crypto { { name: 'USD', stat_name: 'usdCoin', boost: 60, price: 2560 }, { name: 'Solana', stat_name: 'solana', boost: 80, price: 4000 } ] + let payback = [] let stat = await this.call() - for (let cost of costs) { - cost.price = cost.price * Math.pow(2, stat[cost.stat_name]) + for (let i = 0; i < costs.length; i++) { + costs[i].price = costs[i].price * Math.pow(2, stat[costs[i].stat_name]) + payback[i] = costs[i].price / (stat.in_minute_mining + costs[i].boost) } - return { costs: costs, balance: stat.balance, profit: stat.in_minute_mining } + let min_payback = Math.min.apply(null, payback) + return { costs: costs, balance: stat.balance, profit: stat.in_minute_mining, recommended: costs[payback.indexOf(min_payback)] } } async getTop() { diff --git a/package.json b/package.json index f01517c..662889f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vk-crypto", - "version": "1.0.0", + "version": "1.0.2", "description": "wrapped methods for vk mini app \"Crypto\"", "main": "index.js", "scripts": {