-
Notifications
You must be signed in to change notification settings - Fork 6
Exponentially decaying token rewards #340
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
Conversation
pallets/mining-rewards/src/lib.rs
Outdated
| TryInto::<u128>::try_into(current_supply), | ||
| TryInto::<u128>::try_into(tx_fees), | ||
| ) { | ||
| let unit = 1_000_000_000_000u128; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we store the decimals somewhere? So we could grab them from there instead of hard code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use UNIT actually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately there's no easy way to access it, it's in a different crate, I think it's better to redefine it here instead of creating a dependency, especially since it's only used for logging.
n13
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic numbers should be normalized, ie just multiply by UNIT so they're all absolute values of QUAN.
czareko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All magic numbers should go to the pallet configuration; besides that, it looks good.
Maybe 45 years is a bit too long?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request implements an exponentially decaying token emission schedule for mining rewards, replacing the previous fixed block reward system.
- Introduces a dynamic emission formula:
reward = (max_supply - current_supply) / emission_divisorthat approximates exponential decay - Sets a 21 million token maximum supply with 50% of mining rewards allocated to the treasury
- Adjusts genesis configuration to allocate 30% of max supply (6.3M tokens) to the treasury at launch
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| runtime/src/genesis_config_presets.rs | Updates genesis balances to allocate 100,000 tokens per endowed account and 6.3M tokens to treasury (30% of max supply) |
| runtime/src/configs/mod.rs | Configures mining rewards pallet with MaxSupply (21M), EmissionDivisor (26.28M), and TreasuryPortion (50%) parameters |
| pallets/mining-rewards/src/lib.rs | Implements dynamic reward calculation based on remaining supply, splits rewards between treasury and miners, adds detailed logging |
| pallets/mining-rewards/src/mock.rs | Updates test configuration with new emission parameters (scaled for test simplicity) and removes fixed reward constants |
| pallets/mining-rewards/src/tests.rs | Refactors all tests to calculate expected rewards dynamically rather than using hardcoded values |
| pallets/mining-rewards/simulate_emissions.py | Adds Python simulation script to model the emission schedule over time and analyze curve characteristics |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Maybe, but I also was trying to keep the initial inflation below 10%, it's currently 7%. I have a spreadsheet I can show you. |
n13
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now
* exponentially decaying token rewards * script to simulate emissions * clean up constants and switch python script to rust test * log if we hit max supply somehow
this heuristic results in a close approximation of an exponential curve. The constant is chosen so that, with no burns, the token supply will be 99% emitted in about 45 years.