Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Add supply information endpoint to status monitor #81

Merged
merged 10 commits into from
Oct 29, 2020

Conversation

derekpierre
Copy link
Member

@derekpierre derekpierre commented Oct 26, 2020

Fixes #80 .

@derekpierre derekpierre added the enhancement New feature or request label Oct 26, 2020
@codecov-io
Copy link

codecov-io commented Oct 26, 2020

Codecov Report

Merging #81 into master will increase coverage by 3.88%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
+ Coverage   47.28%   51.16%   +3.88%     
==========================================
  Files          10       11       +1     
  Lines         977     1069      +92     
==========================================
+ Hits          462      547      +85     
- Misses        515      522       +7     
Impacted Files Coverage Δ
monitor/dashboard.py 19.69% <57.14%> (+0.34%) ⬆️
monitor/supply.py 98.80% <98.80%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 627dc2d...881d47b. Read the comment docs.

monitor/dashboard.py Outdated Show resolved Hide resolved
monitor/dashboard.py Outdated Show resolved Hide resolved
monitor/dashboard.py Outdated Show resolved Hide resolved
monitor/dashboard.py Outdated Show resolved Hide resolved
monitor/dashboard.py Outdated Show resolved Hide resolved
monitor/dashboard.py Outdated Show resolved Hide resolved
monitor/dashboard.py Outdated Show resolved Hide resolved
monitor/dashboard.py Outdated Show resolved Hide resolved
monitor/dashboard.py Outdated Show resolved Hide resolved
Co-authored-by: MacLane S Wilkison <maclane@nucypher.com>
monitor/dashboard.py Outdated Show resolved Hide resolved
@derekpierre
Copy link
Member Author

derekpierre commented Oct 26, 2020

@mswilkison, current output:

{
"current_total_supply": "1008524647.83 NU",
"est_circulating_supply": "389000000 NU",
    "internal_allocations": {
    "company": "200000000 NU",
    "saft": "399000000 NU",
    "team": "106000000 NU",
    "worklock": "225000000 NU"
},
"max_supply": "3885390081.75 NU",
"staking_rewards_supply": "2876865433.91 NU"
}

@mswilkison
Copy link
Member

mswilkison commented Oct 26, 2020

T> @mswilkison, current output:

{
"current_total_supply": "1008524647.83 NU",
"est_circulating_supply": "389000000 NU",
    "internal_allocations": {
    "company": "200000000 NU",
    "saft": "399000000 NU",
    "team": "106000000 NU",
    "worklock": "225000000 NU"
},
"max_supply": "3885390081.75 NU",
"staking_rewards_supply": "2876865433.91 NU"
}

Looks good - since we're nesting internal_allocations under est_circulating_supply maybe it makes sense to only show saft2 there? Since it's essentially the vested/locked allocations. That way the est_circulating_supply + internal_allocations sums to initial_supply, which is more intuitive of a presentation

@mswilkison
Copy link
Member

mswilkison commented Oct 26, 2020

Actually thinking some more, maybe a buildup like the below makes the most sense?

{
"initial_supply": "1000000000 NU",
"inflation_rewards": "8524647.83 NU",
"current_total_supply": "1008524647.83 NU",
"staking_rewards_supply": "2876865433.91 NU",
"max_supply": "3885390081.75 NU",
"est_circulating_supply": "389000000 NU",
    "internal_locked_allocations": {
    "company": "200000000 NU",
    "saft2": "80000000 NU",
    "team": "106000000 NU",
    "worklock": "225000000 NU"
}
}

@derekpierre
Copy link
Member Author

derekpierre commented Oct 27, 2020

since we're nesting internal_allocations under est_circulating_supply

@mswilkison that was a formatting error, we aren't nesting internal allocations in est_circulating_supply. It was supposed to be (output from before)

{
   "current_total_supply": "1008524647.83 NU",
   "est_circulating_supply": "389000000 NU",
   "internal_allocations": {
       "company": "200000000 NU",
       "saft": "399000000 NU",
       "team": "106000000 NU",
       "worklock": "225000000 NU"
   },
   "max_supply": "3885390081.75 NU",
   "staking_rewards_supply": "2876865433.91 NU"
}

Looks good - since we're nesting internal_allocations under est_circulating_supply maybe it makes sense to only show saft2 there? Since it's essentially the vested/locked allocations. That way the est_circulating_supply + internal_allocations sums to initial_supply, which is more intuitive of a presentation

For the build-up, what do you think about something like the following, assuming I can get the ordering to be maintained:

{
   "initial_supply": {
        "total_allocated": "1000000000 NU",
        "locked_allocations": {    <---- (values will adjust based on vesting)
             "company": "200000000 NU",
             "saft2": "80000000 NU",
             "team": "106000000 NU",
             "worklock": "225000000 NU" 
         }
         "unlocked": <total - (sum of internal_locked_allocations)>,
    }
    "staking_rewards_supply": {
         "total_allocated": <staking_rewards_issued + remaining remaining_staking_rewards_supply> (below)
         "staking_rewards_issued": "8524647.83 NU",
         "staking_rewards_remaining": "2876865433.91 NU",
    }
  
    "max_supply": "3885390081.75 NU",    <--- should equal ['initial_supply']['total_alloacated'] + ['staking_rewards_supply']['total_allocated']
    "est_circulating_supply":  <----- equals ['initial_supply']['unlocked']
}

wdyt?

@derekpierre
Copy link
Member Author

Side note - what do we count issued rewards as...? Those can be unlocked if not restaked

@mswilkison
Copy link
Member

mswilkison commented Oct 27, 2020

wdyt?

Looking pretty good. Just for consistency, ease of reading maybe /s/unlocked/"unlocked_allocations" and have it be a dict with both "saft1" and "casi" broken out separately

Side note - what do we count issued rewards as...? Those can be unlocked if not restaked

Maybe we just include them est_circulating_supply (except for the ones earned by NuCo nodes)

@mswilkison
Copy link
Member

Maybe we just include them est_circulating_supply (except for the ones earned by NuCo nodes)

Actually I'm not sure about this, almost all of them are being restaked... maybe for now we leave out of circulating?

@derekpierre
Copy link
Member Author

and have it be a dict with both "saft1" and "casi" broken out separately

What was the final number for CASI?

Saft1 and CASI alone don't account for the rest of unlocked allocations eg. university staking - so should we add a catch-all entry like "other":

    "unlocked_allocations": {
          "saft1": <>
          "casi": <>
          "other": <>
    }

@derekpierre
Copy link
Member Author

derekpierre commented Oct 27, 2020

Actually I'm not sure about this, almost all of them are being restaked... maybe for now we leave out of circulating?

Definitely easiest to omit right now - not a simple calculation 😅

@mswilkison
Copy link
Member

mswilkison commented Oct 27, 2020

and have it be a dict with both "saft1" and "casi" broken out separately

What was the final number for CASI?

Saft1 and CASI alone don't account for the rest of unlocked allocations eg. university staking - so should we add a catch-all entry like "other":

    "unlocked_allocations": {
          "saft1": <>
          "casi": <>
          "other": <>
    }

Right, forgot about uni! Those are actually locked (19,500,000 NU), so should go in locked_allocations.

Include University Stakers in locked allocations.
Added unit tests.
@derekpierre
Copy link
Member Author

derekpierre commented Oct 27, 2020

Current iteration:

{
    "initial_supply": {
        "total_allocated": "1000000000 NU",
        "locked_allocations": {
            "saft2": "80000000 NU",
            "team": "106000000 NU",
            "company": "200000000 NU",
            "worklock": "225000000 NU",
            "university": "19500000 NU"
        },
        "unlocked_allocations": {
            "saft1": "319000000 NU",
            "casi": "8280000 NU",
            "other": "42220000 NU"
        }
    },
    "staking_rewards_supply": {
        "total_allocated": "2885390081.75 NU",
        "staking_rewards_issued": "9544346.16 NU",
        "staking_rewards_remaining": "2875845735.59 NU"
    },
    "max_supply": "3885390081.75 NU",
    "est_circulating_supply": "369500000 NU"
}

Questions/notes:

  1. What's the vesting schedule for the company (5 years, and presumably a cliff, i.e. no monthly sub-stakes, just one with 5 year duration?)
  2. What's the CASI supply - currently assumed to be 8,280,000 NU.
  3. Used "other" as catchall for unlocked_allocations unaccounted for i.e. (['initial_supply']['total_allocated]' - sum of locked_allocations - saft1 - casi)
  4. Est. circulating supply is the sum of all unlocked_allocations i.e. saft1 + casi + other.
  5. Days / month for vesting calculation uses 30.416 which was used in allocations spreadsheet.

@derekpierre derekpierre changed the title [WIP] Add supply information endpoint to status monitor Add supply information endpoint to status monitor Oct 28, 2020
@derekpierre derekpierre marked this pull request as ready for review October 28, 2020 13:47
@mswilkison
Copy link
Member

1. What's the vesting schedule for the company (5 years, and presumably a cliff, i.e. no monthly sub-stakes, just one with 5 year duration?)

Yes.

2. What's the CASI supply - currently assumed to be 8,280,000 NU.

Let's do 9,000,000M NU which is the amount we've distributed so far for CASI.

3. Used "other" as catchall for `unlocked_allocations` unaccounted for i.e. (['initial_supply']['total_allocated]' - sum of locked_allocations - saft1 - casi)

Maybe call that ecosystem, which is what we've done elsewhere.

4. Est. circulating supply is the sum of all `unlocked_allocations` i.e. saft1 + casi + other.

Makes sense.

@derekpierre
Copy link
Member Author

derekpierre commented Oct 28, 2020

Latest output:

{
   "initial_supply":{
      "total_allocated":"1000000000 NU",
      "locked_allocations":{
         "saft2":"80000000 NU",
         "team":"106000000 NU",
         "company":"200000000 NU",
         "worklock":"225000000 NU",
         "university":"19500000 NU"
      },
      "unlocked_allocations":{
         "saft1":"319000000 NU",
         "casi":"9000000 NU",
         "ecosystem":"41500000 NU"
      }
   },
   "staking_rewards_supply":{
      "total_allocated":"2885390081.75 NU",
      "staking_rewards_issued":"10383119.52 NU",
      "staking_rewards_remaining":"2875006962.23 NU"
   },
   "max_supply":"3885390081.75 NU",
   "est_circulating_supply":"369500000 NU"
}

Comment on lines 62 to 65
vest_24_month_factor = vesting_remaining_factor(vesting_months=24, cliff=False, now=now)
vest_worklock_factor = vesting_remaining_factor(vesting_months=WORKLOCK_VESTING_MONTHS, cliff=True, now=now)
vest_nuco_factor = vesting_remaining_factor(vesting_months=NUCO_VESTING_MONTHS, cliff=True, now=now)
vest_university_factor = vesting_remaining_factor(vesting_months=UNIVERSITY_VESTING_MONTHS, cliff=True, now=now)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mswilkison pay particular attention here for vesting calcs, and how they are used.

@derekpierre
Copy link
Member Author

Current output with vested NU separated in unlocked allocations.

{
   "initial_supply":{
      "total_allocated":"1000000000 NU",
      "locked_allocations":{
         "saft2":"80000000 NU",
         "team":"106000000 NU",
         "company":"200000000 NU",
         "worklock":"225000000 NU",
         "university":"19500000 NU"
      },
      "unlocked_allocations":{
         "saft1":"319000000 NU",
         "casi":"9000000 NU",
         "vested":"0 NU",
         "ecosystem":"41500000 NU"
      }
   },
   "staking_rewards_supply":{
      "total_allocated":"2885390081.75 NU",
      "staking_rewards_issued":"10383138.7 NU",
      "staking_rewards_remaining":"2875006943.05 NU"
   },
   "max_supply":"3885390081.75 NU",
   "est_circulating_supply":"369500000 NU"
}

Copy link
Member

@arjunhassard arjunhassard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful, nice work! 💹

# Staking Rewards Information
staking_rewards_info = OrderedDict()
supply_info['staking_rewards_supply'] = staking_rewards_info
initial_supply_with_rewards = economics.initial_supply # economics.initial_supply includes issued rewards
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
initial_supply_with_rewards = economics.initial_supply # economics.initial_supply includes issued rewards
initial_supply_with_rewards = economics.token_supply_at_period # economics.initial_supply includes issued rewards

Is this used to return the supply in this current moment (i.e. right now would be the initial 1bn + ~12m rewards issued since launch). If so the BaseEconomics class doesn't actually provide an expression for the supply in a given moment, but StandardTokenEconomics does

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was working off of @KPrasch's point - https://discord.com/channels/411401661714792449/412681039178366996/770397121831501854 - that initial supply already includes rewards.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arjunhassard thanks for raising this - just realized that I should not create an Economics class in the constructor, and reuse it - rather, I should obtain a fresh copy of the Economics every time the endpoint is invoked.

re: StandardTokenEconomics - I'm not sure I have direct access to that class.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include circulating supply on dashboard and JSON endpoint
5 participants