-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathapp.js
76 lines (50 loc) · 3.04 KB
/
app.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var netHashRate = hodlData.netHashRate;
var reward = hodlData.reward;
var currentBlock = hodlData.lastBlock;
var exchangeHODLBTC = hodlData.exchangeHODLBTC;
var exchangeBTCUSD = hodlData.exchangeBTCUSD;
var exchangeHODLUSD = exchangeHODLBTC * exchangeBTCUSD ;
function updateReward() {
var dailyValue = ($("#userHash").val() * reward) / netHashRate;
var weeklyValue = dailyValue * 7;
var monthlyValue = dailyValue * 30;
$("#dailyEarnings").text("Earnings per day: " + dailyValue.toFixed(2) + " Hodl ($" + (dailyValue * exchangeHODLUSD).toFixed(2) +")");
$("#weeklyEarnings").text("Earnings per week: " + weeklyValue.toFixed(2) + " Hodl ($" + (weeklyValue * exchangeHODLUSD).toFixed(2) +")");
$("#monthlyEarnings").text("Earnings per month: " + monthlyValue.toFixed(2) + " Hodl ($" + (monthlyValue * exchangeHODLUSD).toFixed(2) +")");
}
function updateScenario() {
// get term deposits formula for interest and scenario section.
// https://bitcointalk.org/index.php?topic=1317918.0
var blockTime = 154; // in seconds
var blocksPerDay = (24*60*60) / 154; // 561.038961
var principal; // initial investment, get from form
var term; // in days, get from form
var blocksDuringTerm = blocksPerDay * term;
// compound interest forumla: A = P ( 1+r ) ^ t
var standardInterestRate = Math.pow(0.5,22); // (1/2^22) compounded every block
var standardInterestDuringTerm;
var bonusInterestDuringTerm;
var depositInterestDuringTerm;
var effectiveInterest = standardInterestDuringTerm + bonusInterestDuringTerm + depositInterestDuringTerm;
var totalCoins = principal + effectiveInterest;
// bonus interest
// Principal + (Standard Interest + (Bonus Interest * Bonus Multiplier))
var bonusInterest; // Compounded, the rate is 2174%. It's reduced every block by a multiplier - calculated like this =((409530-X)/409530)^4 (X is the block where the balance is recorded as an output).
var maxBonusRate = Math.pow(0.5,16);
var bonusMultipler = Math.pow(((409530 - currentBlock) / 409530), 4);
// Full bonus on term is Principal + ((Standard Interest + (Bonus Interest * Bonus Multiplier))*Term Deposit Multiplier)
var termDepositMultipler; // (1-((409530-X)/409530)^6)*100 X is number of blocks to lock for, min 2 days, max 1 year
}
// attach events
$("#userHash").keyup(updateReward);
$("#miningHardware").change(function () {
$("#userHash").val($("#miningHardware").val());
updateReward();
});
var netInfoString = "<b>Exchange Rate:</b> $" + exchangeHODLUSD.toFixed(5);
netInfoString = netInfoString + "<br /><b>HODL to BTC:</b> " + exchangeHODLBTC.toFixed(8);
netInfoString = netInfoString + "<br /><b>BTC to USD:</b> $" + exchangeBTCUSD.toFixed(2);
netInfoString = netInfoString + "<br /><br /><b>Current Block:</b> " + currentBlock;
netInfoString = netInfoString + "<br /><b>Network Hashrate:</b> " + netHashRate;
$("#networkInfo").html(netInfoString);
$("#exchangeRate").html("Exchange Rate: $" + exchangeHODLUSD.toFixed(5) + "<br /> (HODL to BTC: " + exchangeHODLBTC.toFixed(8) + " BTC to USD:" + exchangeBTCUSD.toFixed(2) +")");