|
|
@ -5,20 +5,13 @@ const MINUTES = SECONDS * 60; |
|
|
|
const HOURS = MINUTES * 60; |
|
|
|
|
|
|
|
const getCoinData = async () => { |
|
|
|
const [ |
|
|
|
crypto51, |
|
|
|
wtmCoins, |
|
|
|
wtmAsic |
|
|
|
] = await Promise.all([ |
|
|
|
'https://www.crypto51.app/coins.json', |
|
|
|
'https://whattomine.com/coins.json', |
|
|
|
'https://whattomine.com/asic.json' |
|
|
|
].map(url => fetch(`https://cors.io/?${url}`).then(res => res.json()))); |
|
|
|
|
|
|
|
const whatToMine = [...Object.values(wtmCoins.coins), ...Object.values(wtmAsic.coins)].filter(alg => alg.tag !== 'NICEHASH'); |
|
|
|
|
|
|
|
let coins = crypto51.coins |
|
|
|
.filter(coin => whatToMine.find(alg => alg.tag === coin.symbol) && typeof coin.attack_hourly_cost === 'number') |
|
|
|
// Fetch coin data
|
|
|
|
const response = await fetch('https://cors.io/?https://www.crypto51.app/coins.json') |
|
|
|
let {coins} = await response.json(); |
|
|
|
|
|
|
|
// Format
|
|
|
|
coins = coins |
|
|
|
.filter(coin => typeof coin.attack_hourly_cost === 'number') |
|
|
|
.map(coin => ({ |
|
|
|
symbol: coin.symbol, |
|
|
|
name: coin.name, |
|
|
@ -27,10 +20,11 @@ const getCoinData = async () => { |
|
|
|
hashRate: coin.hash_rate, |
|
|
|
hashRateFormatted: coin.hash_rate_pretty, |
|
|
|
marketCap: coin.market_cap, |
|
|
|
blockTimeInSeconds: Number(whatToMine.find(alg => alg.tag === coin.symbol).block_time) |
|
|
|
blockTimeInSeconds: coin.block_time |
|
|
|
})) |
|
|
|
.sort((a, b) => b.marketCap - a.marketCap); |
|
|
|
|
|
|
|
// Calculate confirmation data
|
|
|
|
const referenceCoinSymbol = 'BTC'; |
|
|
|
const referenceConfirmations = 6; |
|
|
|
const referenceCoin = coins.find(coin => coin.symbol === referenceCoinSymbol); |
|
|
|