-
Notifications
You must be signed in to change notification settings - Fork 18
/
MoneroOceanApi.cs
46 lines (41 loc) · 1.67 KB
/
MoneroOceanApi.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using CryptoProfitSwitcher.Enums;
using CryptoProfitSwitcher.Models;
using Newtonsoft.Json.Linq;
using Serilog;
namespace CryptoProfitSwitcher.ProfitPoviders
{
public class MoneroOceanApi : IPoolProfitProvider
{
public Dictionary<Pool, Profit> GetProfits(IList<Pool> pools, bool enableCaching, DirectoryInfo appRootFolder, CancellationToken ct)
{
var poolProfitsDictionary = new Dictionary<Pool, Profit>();
try
{
if (pools.Any())
{
const string apiUrl = "https://api.moneroocean.stream/pool/stats";
var statsJson = Helpers.GetJsonFromUrl(apiUrl, enableCaching, appRootFolder, ct);
JToken poolStats = JToken.Parse(statsJson)["pool_statistics"];
double activePortProfit = poolStats.Value<double>("activePortProfit");
double profitXmrPerDay = activePortProfit * Profit.BaseHashrate;
double usdPriceXmr = poolStats["price"].Value<double>("usd");
double usdReward = profitXmrPerDay * usdPriceXmr;
foreach (Pool pool in pools)
{
poolProfitsDictionary[pool] = new Profit(usdReward, 0, profitXmrPerDay, 0, ProfitProvider.MoneroOceanApi);
}
}
}
catch (Exception ex)
{
Log.Warning("Failed to get profits data from XmrMinerApi: " + ex.Message);
}
return poolProfitsDictionary;
}
}
}