Created
March 25, 2024 14:46
-
-
Save Maxnflaxl/aae3fbf9a5dd7b4bae1fae28ec68767e to your computer and use it in GitHub Desktop.
This file contains 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
#include <iostream> | |
#include <cmath> | |
int main() { | |
double networkHashrate, yourHashrate, blockTargetTime, blockReward, exchangePrice, costPerKWH; | |
int powerConsumptionWatts; // Added input for power consumption | |
std::cout << "Enter the network hashrate (megahashes per second): "; | |
std::cin >> networkHashrate; | |
std::cout << "Enter your hashrate (kilohashes per second): "; | |
std::cin >> yourHashrate; | |
networkHashrate *= 1e6; | |
yourHashrate *= 1e3; | |
double networkDifficulty = networkHashrate / yourHashrate; | |
std::cout << "Enter the block target time in minutes: "; | |
std::cin >> blockTargetTime; | |
double timeToSolveBlockSeconds = networkDifficulty * blockTargetTime * 60; | |
double timeToSolveBlockHours = timeToSolveBlockSeconds / 3600; | |
int days = static_cast<int>(timeToSolveBlockSeconds / (24 * 3600)); | |
int hours = static_cast<int>(std::fmod(timeToSolveBlockSeconds, 24 * 3600) / 3600); | |
std::cout << "Enter the block reward amount: "; | |
std::cin >> blockReward; | |
std::cout << "Enter the exchange price per unit in USD: "; | |
std::cin >> exchangePrice; | |
std::cout << "Enter the power consumption in watts: "; | |
std::cin >> powerConsumptionWatts; | |
std::cout << "Enter the cost per kilowatt-hour in USD: "; | |
std::cin >> costPerKWH; | |
double powerCost = (powerConsumptionWatts / 1000.0) * costPerKWH * timeToSolveBlockHours; | |
double totalRewardUSD = blockReward * exchangePrice; | |
double breakEvenCoinPrice = (powerCost / totalRewardUSD)*exchangePrice; | |
int minutesInADay = 24 * 60; | |
double coinsPerDay = (minutesInADay / blockTargetTime) * blockReward; | |
double totalValuePerDay = coinsPerDay * exchangePrice; | |
double yourCoinsPerDay = (yourHashrate / networkHashrate) * coinsPerDay; | |
double yourValuePerDay = yourCoinsPerDay * exchangePrice; | |
double dailyPowerCost = (powerConsumptionWatts / 1000.0)*costPerKWH * 24; | |
double Dailyprofitatexchagneprice = yourValuePerDay - dailyPowerCost; | |
double profitpercent=breakEvenCoinPrice/exchangePrice; | |
std::cout << "The network gets approximately " << coinsPerDay << " coins per day.\n"; | |
std::cout << "The total value of the coins per day the network gets = $" << totalValuePerDay << ".\n"; | |
std::cout << "\n"; | |
std::cout << "It would take approximately " << days << " days and " << hours << " hours to solve a block.\n"; | |
std::cout << "If you solve a block, your total reward would be: $" << totalRewardUSD << ".\n"; | |
std::cout << "The estimated cost of power during the time to solve a block is: $" << powerCost << ".\n"; | |
std::cout << "\n"; | |
std::cout << "Your Miner should avg approximately " << yourCoinsPerDay << " coins per day.\n"; | |
std::cout << "The value of coins you get per day = $" << yourValuePerDay << ".\n"; | |
std::cout << "The daily cost of power is: $" << dailyPowerCost << ".\n"; | |
std::cout << "The daily profit: $" << Dailyprofitatexchagneprice << ".\n"; | |
std::cout << "\n"; | |
std::cout << "With the current cost of coins being: $" << exchangePrice<<" \n"; | |
std::cout << "Sell your coins at least: $ " << breakEvenCoinPrice << " to break even in power.\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment