Skip to content

Instantly share code, notes, and snippets.

@mutatrum
Created May 3, 2022 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mutatrum/300d8c10837b3e4be8c3d4257d2b75c1 to your computer and use it in GitHub Desktop.
Save mutatrum/300d8c10837b3e4be8c3d4257d2b75c1 to your computer and use it in GitHub Desktop.
Block reward and supply calculation
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