Created
May 3, 2022 08:36
-
-
Save mutatrum/300d8c10837b3e4be8c3d4257d2b75c1 to your computer and use it in GitHub Desktop.
Block reward and supply calculation
This file contains hidden or 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
for (block_height = 0; block_height < 6_930_000; block_height += 210_000) { | |
epoch = Math.floor(block_height / 210_000) + 1 | |
coin = 100_000_000 | |
reward = Math.floor(100 * coin / Math.pow(2, epoch)) | |
supply = 0 | |
for (i = 1; i <= epoch; i++) { | |
supply += Math.floor(100 * coin / Math.pow(2, i)) * 210_000 | |
} | |
// Or 21_000_000 | |
percent = (supply / coin / 20_999_999.9769) * 100 | |
console.log(`${epoch} ${(reward / coin).toFixed(8)} ${(supply / coin).toFixed(8)} ${percent}`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment