mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-09 14:48:08 -05:00
lotterysim: add inflation rate analytics
This commit is contained in:
@@ -28,7 +28,6 @@ class DarkfiTable:
|
||||
self.debug=debug
|
||||
self.start_time=time.time()
|
||||
feedback=0 # number leads in previous slot
|
||||
count = 0
|
||||
# random running time
|
||||
rand_running_time = random.randint(1,self.running_time) if rand_running_time else self.running_time
|
||||
self.running_time = rand_running_time
|
||||
@@ -89,7 +88,6 @@ class DarkfiTable:
|
||||
darkie_winning_idx = darkie_idx
|
||||
break
|
||||
self.darkies[darkie_winning_idx].resync_stake(resync_reward)
|
||||
|
||||
count+=1
|
||||
self.end_time=time.time()
|
||||
avg_reward = sum(self.rewards)/len(self.rewards)
|
||||
|
||||
30
script/research/lotterysim/metrics.py
Normal file
30
script/research/lotterysim/metrics.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from core.constants import *
|
||||
import config
|
||||
|
||||
def percent_change(start, end):
|
||||
difference = end - start
|
||||
change = (difference / start) * 100
|
||||
return change
|
||||
|
||||
#def slot_number_at_target(count, supply, target_reached):
|
||||
# if target_reached == False:
|
||||
# if supply > target:
|
||||
# target_reached = True
|
||||
# get_slot_time(count)
|
||||
# return target_reached
|
||||
#
|
||||
#target = ERC20DRK * config.exchange_rate
|
||||
#
|
||||
#def get_slot_time(count):
|
||||
# # @ 90 seconds per slot
|
||||
# slots_per_day = 960
|
||||
# slots_per_month = 28800
|
||||
# slots_per_year = slots_per_month * 12
|
||||
#
|
||||
# days = count / slots_per_day
|
||||
# months = count / slots_per_month
|
||||
# years = count / slots_per_year
|
||||
#
|
||||
# print("Target supply of", str(target), "DRK was achieved after: ",
|
||||
# str(count), "slots", str(days), "(D)", str(months), "(M)",
|
||||
# str(years), "(Y)")
|
||||
@@ -3,6 +3,7 @@ from core.strategy import random_strategy
|
||||
from core.constants import *
|
||||
from pid.pid_base import *
|
||||
from draw import draw
|
||||
import metrics
|
||||
import logging
|
||||
import config
|
||||
import os
|
||||
@@ -30,7 +31,9 @@ def vesting_instance(vesting, running_time):
|
||||
dt.add_darkie(darkie)
|
||||
dt.background(rand_running_time=False)
|
||||
dt.write()
|
||||
return dt.avg_apr()
|
||||
|
||||
inflation = metrics.percent_change(airdrop, sum(dt.rewards))
|
||||
return (dt.avg_apr(), inflation)
|
||||
|
||||
if not os.path.exists(config.vesting_file):
|
||||
print('add vested distribution csv at path {} with vesting period {} (slots) aparts.'.format(config.vesting_file, ONE_MONTH))
|
||||
@@ -51,6 +54,7 @@ if config.running_time== 0:
|
||||
else:
|
||||
running_time = config.running_time
|
||||
|
||||
apr = vesting_instance(vesting, running_time)
|
||||
apr, inflation = vesting_instance(vesting, running_time)
|
||||
print('avg apr: {}%'.format(apr*100))
|
||||
print('inflation: {}%'.format(inflation))
|
||||
draw()
|
||||
|
||||
Reference in New Issue
Block a user