Created
December 4, 2021 14:28
-
-
Save vic-cieslak/65a74a90f114c213c6df76d6518b1aa4 to your computer and use it in GitHub Desktop.
lotus mining calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import requests | |
import math | |
import json | |
system_cost_usd = 4000 # usd | |
power_consumption_watt = 700 # | |
electricity_cost_kwh_usd = 0.1 # usd | |
daily_electricity_consumption = power_consumption_watt | |
weekly_electricity_consumption = power_consumption_watt * 7 | |
monthly_electricity_consumption = power_consumption_watt * 30 | |
weekly_electricity_consumption = power_consumption_watt * 7 * electricity_cost_kwh_usd | |
monthly_electricity_consumption = power_consumption_watt * 30 * electricity_cost_kwh_usd | |
monthly_electricity_cost_usd = monthly_electricity_consumption * electricity_cost_kwh_usd | |
print('getting price in usdt') | |
res = requests.get("https://www.exbitron.com/api/v2/peatio/public/markets/xpiusdt/tickers").json() | |
avg_price = float(res['ticker']['avg_price']) | |
print('getting difficulty') | |
res = requests.get("https://explorer.givelotus.org/api/getdifficulty").json() | |
current_difficulty = float(res) | |
print('getting network hash rate') | |
res = requests.get('https://explorer.givelotus.org/api/getnetworkhashps').json() | |
network_hash_rate = float(res) | |
network_hash_rate_gh = network_hash_rate / 1000000000 | |
def calc_xpi(user_hash_rate_mh): | |
# i have no idea, it works though | |
daily_rewards = (math.log(current_difficulty/16,2)+1)*260/2*user_hash_rate_mh/1000/network_hash_rate_gh*720 | |
hourly_rewards = daily_rewards / 24 | |
weekly_rewards = daily_rewards * 7 | |
monthly_rewards = daily_rewards * 30 # some months have 29 or 31 days but whatever | |
print(f"[*]Lotus mining calculator.") | |
print(f"[*]Difficulty changes every XXX blocks, X weeks") | |
print(f"Hourly: {hourly_rewards:.2f} xpi ||-> { hourly_rewards * avg_price:.2f} usd") | |
print(f"Daily: {daily_rewards:.2f} ||-> { daily_rewards * avg_price:.2f} usd") | |
print(f"Weekly: {weekly_rewards:.2f} xpi ||-> { weekly_rewards * avg_price:.2f} usd") | |
print(f"Monthly: {monthly_rewards:.2f} xpi ||-> { monthly_rewards * avg_price:.2f} usd") | |
def calc_daily_xpi(user_hash_rate_mh): | |
# i have no idea, it works though | |
daily_rewards = (math.log(current_difficulty/16,2)+1)*260/2*user_hash_rate_mh/1000/network_hash_rate_gh*720 | |
return daily_rewards | |
def calc_weekly_xpi(user_hash_rate_mh): | |
return calc_daily_xpi(user_hash_rate_mh) * 7 | |
def calc_monthly_xpi(user_hash_rate_mh): | |
return calc_daily_xpi(user_hash_rate_mh) * 30 | |
def calc_roi(system_cost_usd, user_hash_rate_mh): | |
monthly_usd = calc_monthly_xpi(user_hash_rate_mh) * avg_price | |
monthly_income = monthly_usd - monthly_electricity_cost_usd | |
roi = system_cost_usd / monthly_income | |
return roi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment