Files
  • main.py
main.py
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
73
74
75
76
77
78
79
80
81
82
83
84
85
#
# click RUN button above
#
# computes dash min/max coins generated over the next 250 years or so
#

# subsidy reduction interval in blocks (system constant)
CYCLE_LENGTH=210240

# blockchain state at first block of 2017 subsidy shift
cycle_year = 2017.17248 # 2017-03-04 14:21:04
# 2017 + ((31 + 28 + 4 + (14 + ((21 + (04 / 60)) / 60)) / 24) / 365.25)

cycle_height = 630721 
cycle_outstanding = 7137912.0

# 201643 == average annual block discovery rate across 4 years
#         block heights at: yr1       yr2               yr3               yr4
# avg_blocks_per_year = float((205532 + (405626-205532) + (606362-405626) + (806574-606362))/4)

# BUT, removing launch diff-adjust outlier and averaging-in the leap day minting...
# yr height block birthstamp     delta 
# y0      1 2014-01-19 03:54:41
# y1 205532 2015-01-19 03:54:39 205532
# y2 405626 2016-01-19 03:52:15 200094
# y3 606362 2017-01-19 03:54:30 200736 # 2/29 found 550 blocks:428006-428556
# y4 806574 2018-01-19 03:59:30 200212
# skews the results too much.
# 
# experiments find this static value fits the current asic network better
#                           avg-min-per-yr avg-min-per-block
avg_blocks_per_year = float((365.25*24*60)/2.627)

# FORECASTED
# 
# approx          block       minimum       maximum      min/max   difference
# date           height         coins         coins   difference   percentage
# -------    ----------    ----------    ----------   ----------   ----------
# 03/2018       840,961     7,895,396     7,979,561       84,164        1.05%
# 
# ACTUAL                                  7,961,857
# wewt!

# TODO
#cycle_year = 2018.2242 # 2018-03-22 21:25:24
# 2018 + ((31 + 28 + 22 + (21 + ((25 + (54 / 60)) / 60)) / 24) / 365.25)

# now the meat to go with those potatoes...

def block_subsidy_at(nHeight):
    nSubsidy = float(5)  # assume minimum subsidy
    for i in range(CYCLE_LENGTH, nHeight, CYCLE_LENGTH):
        nSubsidy -= nSubsidy/14
    return nSubsidy


future_year = float(cycle_year)
cycle_duration = float(CYCLE_LENGTH / avg_blocks_per_year)
totals = {
    "max" : cycle_outstanding,
    "min" : cycle_outstanding
}


print "approx          block       minimum       maximum      min/max   difference"
print "date           height         coins         coins   difference   percentage"
print "-------    ----------    ----------    ----------   ----------   ----------"
for block in range(cycle_height, cycle_height+(CYCLE_LENGTH*250), CYCLE_LENGTH):
    
    future_year += cycle_duration
    #year_part = int(divmod(future_year, 1)[1] * 12 + 1)
    month = int(divmod(future_year, 1)[1] * 12 + 1)

    cycle_subsidy = (block_subsidy_at(block) * CYCLE_LENGTH)
    totals["max"] += float(cycle_subsidy * 1.0) # full budget allocated
    totals["min"] += float(cycle_subsidy * 0.9) # no budget allocated
    
    delta = totals["max"] - totals["min"]
    delta_pct = (1.0 - totals["min"]/totals["max"]) * 100

    #fmt="{:02d}/{}\t{}\t{:10,d}\t{:10,d}\t{:10,d}\t{:.2f}%"
    fmt="{:02d}/{}    {:10,d}    {:10,d}    {:10,d}   {:10,d}        {:.2f}%"
    mod_scale = int(future_year) <= 2075 and 1 or 5
    if int(future_year) % mod_scale == 0:
        print fmt.format(month, int(future_year), block + CYCLE_LENGTH, int(totals["min"]), int(totals["max"]), int(delta), delta_pct)
Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.8.2] on linux