Last active
July 4, 2022 12:12
-
-
Save coltondotio/164230e8d6acf814d608de2c74e3954f 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
#!/usr/bin/python3 | |
from datetime import date, timedelta, datetime | |
# Disclaimer: not investment advice, and this is a sloppy script! | |
# Objective Inputs | |
GLOBAL_LOCKED_veCRV = 362000000 | |
# Subjective Inputs | |
TARGET_INTEREST_RATE = 0.07 | |
veCRV_FEE_SHARING_RATE = 0.5 | |
PROJECTED_LOCK_RATE = 0.5 | |
PROJECTED_AVG_WEEKLY_TRADING_FEES = 1400000 | |
DAYS_HELD = 1460 | |
# Change this to 1 if you plan on buying & locking CRV with your earnings over time | |
REINVEST_RATE = 0 | |
# This is the avg price you're projecting to buy CRV at with your earnings | |
REINVEST_PRICE = 8 | |
start_date = datetime.fromisoformat('2020-08-13') | |
initial_supply = 1303030303 | |
initial_distribution_per_day = 274815283 / 365 | |
yearly_inflation_reduction = 2**(1/4) | |
current_supply = initial_supply | |
day_to_crv_produced = {} | |
day_to_current_supply = {} | |
day_counter = 1 | |
supply_diff = 1 | |
while (supply_diff > 0): | |
sim_now = start_date + timedelta(days=day_counter) | |
year_diff = (sim_now - start_date).days // 365 | |
daily_crv = initial_distribution_per_day | |
for _ in range(0, year_diff): | |
daily_crv = daily_crv / yearly_inflation_reduction | |
supply_diff = int(daily_crv) | |
current_supply += daily_crv | |
day_to_crv_produced[day_counter] = daily_crv | |
day_to_current_supply[day_counter] = current_supply | |
day_counter += 1 | |
DAYS_UNTIL_MAX_SUPPLY = day_counter | |
print( | |
f'{day_to_current_supply[DAYS_UNTIL_MAX_SUPPLY - 1]} cap will be reached around: {start_date + timedelta(days=DAYS_UNTIL_MAX_SUPPLY)}') | |
def calculate_total_accumulated_vecrv_from_today(vecrv: float, days_held: int) -> float: | |
now = datetime.now() | |
days_since_start = (now - start_date).days | |
my_locked_vecrv = vecrv | |
global_locked_vecrv = GLOBAL_LOCKED_veCRV | |
total_crv_weekly = 0 | |
for day in range(days_since_start, days_since_start + days_held): | |
daily_crv = day_to_crv_produced[day] | |
total_crv_weekly += daily_crv | |
sim_now = start_date + timedelta(days=day) | |
if sim_now.weekday() == 6: # Sunday | |
my_weekly_fees = PROJECTED_AVG_WEEKLY_TRADING_FEES * \ | |
(my_locked_vecrv / global_locked_vecrv) * veCRV_FEE_SHARING_RATE | |
my_weekly_crv_share = total_crv_weekly * \ | |
(my_locked_vecrv / global_locked_vecrv) | |
my_weekly_crv_reinvest = ( | |
my_weekly_fees * REINVEST_RATE) / REINVEST_PRICE | |
my_locked_vecrv += my_weekly_crv_share + my_weekly_crv_reinvest | |
global_locked_vecrv += total_crv_weekly * PROJECTED_LOCK_RATE | |
total_crv_weekly = 0 | |
return my_locked_vecrv | |
def calculate_yearly_fees_after_dilution_per_present_vecrv(days_held: int) -> float: | |
now = datetime.now() | |
days_since_start = (now - start_date).days + days_held | |
supply_at_days_held = day_to_current_supply[days_since_start] | |
yearly_trading_fees = PROJECTED_AVG_WEEKLY_TRADING_FEES * 52 | |
end_vecrv = calculate_total_accumulated_vecrv_from_today(1.00, days_held) | |
projected_locked_vecrv = supply_at_days_held * PROJECTED_LOCK_RATE | |
my_share = end_vecrv / projected_locked_vecrv | |
my_fees = yearly_trading_fees * veCRV_FEE_SHARING_RATE * my_share | |
return my_fees | |
crv_fair_value = calculate_yearly_fees_after_dilution_per_present_vecrv(DAYS_HELD) / \ | |
TARGET_INTEREST_RATE | |
print( | |
f'1 veCRV today would yield {calculate_total_accumulated_vecrv_from_today(1.00, DAYS_HELD)} CRV if held for {DAYS_HELD} days') | |
print(f'CRV fair value given variable inputs: ${round(crv_fair_value, 2)}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my_weekly_crv_share = total_crv_weekly * (my_locked_vecrv / global_locked_vecrv), why do you assume you will get the full fraction of the crv emission on a weekly basis? I thought CRV emission will go to the LP?