Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update total STX supply to the year 2050 projected amount #1531

Merged
merged 3 commits into from
Jan 27, 2023

Conversation

zone117x
Copy link
Member

@zone117x zone117x commented Jan 26, 2023

Fixes hirosystems/explorer#973

The liquid stx amount that is calculated from the postgres db is accurate (or at least it matches the total_liquid_supply_ustx value reported by the stacks-node):

  • /extended/v1/stx_supply - unlocked_stx: 1357774888442244 matches:
  • /v2/pox - total_liquid_supply_ustx: 1357774888442244

However, the total_stx value is incorrect, and is currently greater than the liquid stx supply.

The total_stx value is a constant that was copied from the Stacks 1.0 codebase, see #466

This was copied from the legacy 1.0 API codebase.

export const TOTAL_STACKS = new BigNumber(1320000000)
.plus(322146 * 100 + 5 * 50000) // air drop
.toString();

Here's what the Stacks 2.0 whitepaper states about about the STX supply:

Block reward: 1000 STX/block for first 4 yrs; 500 STX/block for following 4 yrs; 250 for the 4 yrs after that; and then 125 STX/block in perpetuity after that.
...
The Stacks cryptocurrency has a predefined future supply that reaches approx 1,818M STX by year 2050 ...

This PR changes the total_stx value to the year 2050 projected STX amount, because "125 STX/block in perpetuity" means the total supply is not a constant.

@github-actions
Copy link

github-actions bot commented Jan 26, 2023

@github-actions github-actions bot temporarily deployed to pull request January 26, 2023 11:12 Inactive
@zone117x zone117x self-assigned this Jan 26, 2023
@github-actions github-actions bot temporarily deployed to commit January 26, 2023 11:44 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 26, 2023 11:44 Inactive
Comment on lines +225 to +229
// See the Stacks 2.0 whitepaper: https://cloudflare-ipfs.com/ipfs/QmaGgiVHymeDjAc3aF1AwyhiFFwN97pme5m536cHT4FsAW
// > The Stacks cryptocurrency has a predefined future supply that reaches approx 1,818M STX by year 2050
// > Block reward: 1000 STX/block for first 4 yrs;
// > 500 STX/block for following 4 yrs;
// > 250 for the 4 yrs after that; and then 125 STX/block in perpetuity after that.
Copy link
Member Author

Choose a reason for hiding this comment

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

@kantai does the Stacks implementation match this whitepaper description?

Copy link

Choose a reason for hiding this comment

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

Yes, though it uses bitcoin block height as opposed to calendar years:

See:

        let effective_ht = burn_block_height.saturating_sub(first_burn_block_height);
        let blocks_per_year = 52596;
        let stx_reward = if effective_ht < blocks_per_year * 4 {
            1000
        } else if effective_ht < blocks_per_year * 8 {
            500
        } else if effective_ht < blocks_per_year * 12 {
            250
        } else {
            125
        };

from

https://github.com/stacks-network/stacks-blockchain/blob/master/src/chainstate/stacks/db/blocks.rs#L4136-L4171

first_burn_block_height is 666050

@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2023

Codecov Report

Merging #1531 (9ecd869) into master (b6018dc) will increase coverage by 0.09%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #1531      +/-   ##
==========================================
+ Coverage   77.87%   77.97%   +0.09%     
==========================================
  Files         105      105              
  Lines       10443    10443              
  Branches     2245     2245              
==========================================
+ Hits         8133     8143      +10     
+ Misses       2201     2192       -9     
+ Partials      109      108       -1     
Impacted Files Coverage Δ
src/helpers.ts 68.46% <100.00%> (+0.76%) ⬆️
src/datastore/pg-write-store.ts 92.04% <0.00%> (+0.12%) ⬆️
src/event-stream/event-server.ts 79.81% <0.00%> (+1.55%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment on lines +230 to +231
// We are going to use the year 2050 projected supply because "125 STX/block in perpetuity" means the total supply is infinite.
export const TOTAL_STACKS = new BigNumber(1_818_000_000n.toString());
Copy link
Member Author

Choose a reason for hiding this comment

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

@diwakergupta thoughts on using this value?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah anchoring on 2050 supply makes sense. I would also update the docs for this endpoint to include this qualified in big bold letters.

Copy link
Member Author

Choose a reason for hiding this comment

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

Docs updated 👍

@zone117x zone117x marked this pull request as ready for review January 26, 2023 11:52
@coveralls
Copy link
Collaborator

coveralls commented Jan 26, 2023

Coverage Status

Coverage: 77.723% (+0.1%) from 77.624% when pulling 9ecd869 on fix/total-stx-supply into b6018dc on master.

Copy link
Collaborator

@rafaelcr rafaelcr left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions bot temporarily deployed to pull request January 26, 2023 15:30 Inactive
@github-actions github-actions bot temporarily deployed to commit January 26, 2023 15:30 Inactive
@zone117x zone117x merged commit 0689f60 into master Jan 27, 2023
@zone117x zone117x deleted the fix/total-stx-supply branch January 27, 2023 08:18
blockstack-devops pushed a commit that referenced this pull request Jan 27, 2023
## [6.3.3](v6.3.2...v6.3.3) (2023-01-27)

### Bug Fixes

* update total STX supply to the year 2050 projected amount ([#1531](#1531)) ([0689f60](0689f60))
@blockstack-devops
Copy link

🎉 This PR is included in version 6.3.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

blockstack-devops pushed a commit that referenced this pull request Feb 3, 2023
## [7.0.0-beta.4](v7.0.0-beta.3...v7.0.0-beta.4) (2023-02-03)

### Features

* add `smartContractUpdate` and `smartContractLogUpdate` to `PgWriteStore` event emitter ([#1462](#1462)) ([bce0ef9](bce0ef9))

### Bug Fixes

* add block_height index to contract_logs ([#1534](#1534)) ([dc53af2](dc53af2))
* add contract_identifier index on contract_logs table ([#1523](#1523)) ([1f16513](1f16513))
* avoid selecting `raw_tx` column on read queries ([#1453](#1453)) ([5acfc96](5acfc96))
* build rosetta with node 16 ([654b64f](654b64f))
* datastore tests ([bb96507](bb96507))
* is_unanchored property on /extended/v1/tx/:tx_id ([#1487](#1487)) ([4b85058](4b85058))
* lint docs ci dependencies ([#1458](#1458)) ([19c3a0d](19c3a0d))
* stop resolving revoked BNS names ([#1519](#1519)) ([095c4fc](095c4fc))
* test tx types ([11b9013](11b9013))
* update total STX supply to the year 2050 projected amount ([#1531](#1531)) ([0689f60](0689f60))
@blockstack-devops
Copy link

🎉 This PR is included in version 7.0.0-beta.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STX supply shows "100.38% is unlocked"
7 participants