public static EzilBalance GetBalances(Wallet wallet) { EzilBalance balances = null; using (HttpClient httpClient = new HttpClient()) { string request = $"https://billing.ezil.me/balances/{wallet.Eth}.{wallet.Zil}"; string response = httpClient.GetStringAsync(new Uri(request)).Result; balances = JsonConvert.DeserializeObject <EzilBalance>(response); } return(balances); }
private void Display24hEarnings(float eth, float zil, EzilBalance balances) { try { //CoinListings coinListings = GetCryptoPrices(apiKey); //float ethPrice = coinListings.data.Where(d => d.symbol.Equals("ETH")).FirstOrDefault().quote.USD.price; //float zilPrice = coinListings.data.Where(d => d.symbol.Equals("ZIL")).FirstOrDefault().quote.USD.price; MinerstatsAPI minerstatsAPI = new MinerstatsAPI(); var coinInfoList = minerstatsAPI.GetCoinInfo(new string[] { "ETH", "ZIL" }); var coinInfoCurrEth = coinInfoList.Where(d => d.coin.Equals("ETH")).FirstOrDefault(); float ethPrice = coinInfoList.Where(d => d.coin.Equals("ETH")).FirstOrDefault().price; float zilPrice = coinInfoList.Where(d => d.coin.Equals("ZIL")).FirstOrDefault().price; float ethValue = ethPrice * eth; float zilValue = zilPrice * zil; lblEthUsd.Text = $"= ${ethValue:0.00} @ ${ethPrice:0.00}"; lblZilUsd.Text = $"= ${zilValue:0.00} @ ${zilPrice:0.00}"; lblTotal.Text = $"= ${(ethValue + zilValue):0.00}/d, {((ethValue + zilValue) * 7):0.00}/w, {((ethValue + zilValue) * 30):0.00}/m, {((ethValue + zilValue) * 365):0.00}/y"; float ethBalanceValue = balances.eth * ethPrice; float zilBalanceValue = balances.zil * zilPrice; lblEthValue.Text = $"(${ethBalanceValue:0.00})"; lblZilValue.Text = $"(${zilBalanceValue:0.00})"; lblTotalBalance.Text = $"= (${(ethBalanceValue + zilBalanceValue):0.00})"; var coinInfoEth24 = minerstatsAPI.GetCoinHistory("ETH"); float selectedHash = 0; var currentStats = GetCurrentStats(); float averageHash = currentStats.average_hashrate; if (rdoUseAverage.Checked) { selectedHash = averageHash; } else if (rdoUseReported.Checked) { selectedHash = (float)hashPower * 1000000; } else { selectedHash = (float)txtCustomHash.Value * 1000000; } lblNetHash.Text = $"Network Hashrate: {coinInfoCurrEth.network_hashrate / 1000000000000} TH/s"; lblBlockReward.Text = $"Block Reward: {coinInfoCurrEth.reward_block} ETH"; float ethCur = ((coinInfoCurrEth.reward * 0.99f) * 24) * selectedHash; lblEthCurProfit.Text = $"Current Profitability: {ethCur} ETH (${ethCur * ethPrice:0.00})"; float eth24h = ((coinInfoEth24.reward * 0.99f) * 24) * selectedHash; lblEthProfit.Text = $"24h Profitability: {eth24h} ETH (${eth24h * ethPrice:0.00})"; float ezilDiff = eth - eth24h; lblEzilDiff.Text = $"Difference to Ezil: {ezilDiff} ETH (${ezilDiff * ethPrice:0.00})"; lblAverageHashrate.Text = $"Average Hash Rate = {averageHash / 1000000f:0.##} MH/s"; } catch (Exception ex) { if (ex is AggregateException) { throw new Exception($"Cannot retrieve cryptocurrency prices. Try again later.{Environment.NewLine}{ex.InnerException.Message}"); } throw new Exception($"Cannot retrieve cryptocurrency prices. Try again later.{Environment.NewLine}{ex.Message}"); } }