Skip to content

Commit

Permalink
v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCaJlaT authored Sep 1, 2021
1 parent 884f929 commit a1239a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Crypto {

async balance(id) {
let res = await this.call('GetUserBalance', id)
return res.balance
return res
}

async buy(name) {
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit a1239a7

Please sign in to comment.