@MarshallJP/

Historia-Min-Max-Calcations

Python 2.7

No description

fork
loading
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#
# click RUN button above
#
# computes historia 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 2019 subsidy shift
cycle_year = 2019.17248 # 
# 2017 + ((31 + 28 + 4 + (14 + ((21 + (04 / 60)) / 60)) / 24) / 365.25)

cycle_height = 150000 
cycle_outstanding = 2012934

# 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)

# 
#                           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/13
    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      maximum      minimum      maximum       minimum      max/min    max/min %    max/min %"
print "date          height    generated    generated        coins         coins   difference   difference    inflation"
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)
    max_created = float(cycle_subsidy * 1.0) # full budget allocated
    min_created = float(cycle_subsidy * 0.8) # no budget allocated
    totals["max"] += max_created
    totals["min"] += min_created 
    
    delta = totals["max"] - totals["min"]
    delta_pct = (1.0 - totals["min"]/totals["max"]) * 100
    min_inflation = (1.0/(totals["min"]/min_created)) * 100
    max_inflation = (1.0/(totals["max"]/max_created)) * 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}    {:10,d}   {:10,d}        {:.2f}%  {:>5.2f}/{:>4.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(max_created), int(min_created), int(totals["max"]), int(totals["min"]), int(delta), delta_pct, max_inflation, min_inflation)