Skip to content

Commit

Permalink
chore: hopefully fix params
Browse files Browse the repository at this point in the history
  • Loading branch information
onmax committed Nov 27, 2024
1 parent 58811ab commit de5520f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/nimiq-supply-calculator/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export const PROOF_OF_STAKE_FORK_DATE = new Date('2024-11-19T16:45:20.000Z')
* Same as:
* powSupplyAfter(powBlockHeightAt(PROOF_OF_STAKE_FORK_DATE))
*/
export const SUPPLY_AT_PROOF_OF_STAKE_FORK_DATE = 12_893_109_654_06244
export const SUPPLY_AT_PROOF_OF_STAKE_FORK_DATE = 12_893_109_654.06244

/**
* The total supply of the cryptocurrency in **Testnet** at the proof-of-stake fork date, in NIM.
*
* Same as:
* powSupplyAfter(powBlockHeightAt(PROOF_OF_STAKE_FORK_DATE))
*/
export const SUPPLY_AT_PROOF_OF_STAKE_FORK_DATE_TESTNET = 12_030_755_339_52899
export const SUPPLY_AT_PROOF_OF_STAKE_FORK_DATE_TESTNET = 12_030_755_339.52899

/**
* The block height of the proof-of-stake fork.
Expand Down
5 changes: 3 additions & 2 deletions packages/nimiq-supply-calculator/src/pos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const SUPPLY_DECAY = 0.9999999999960264
export function posSupplyAt(timestampMs: number): number {
const ts = timestampMs - PROOF_OF_STAKE_FORK_DATE.getTime()
if (ts < 0)
throw new Error('currentTime must be greater or equal to genesisTime')
return (TOTAL_SUPPLY - ((TOTAL_SUPPLY - SUPPLY_AT_PROOF_OF_STAKE_FORK_DATE * 1e5) * powi(SUPPLY_DECAY, ts)))
throw new Error(`Invalid timestamp: ${timestampMs}. It must be greater than ${PROOF_OF_STAKE_FORK_DATE.getTime()}.`)

return (TOTAL_SUPPLY - ((TOTAL_SUPPLY - SUPPLY_AT_PROOF_OF_STAKE_FORK_DATE * 1e5) * powi(SUPPLY_DECAY, ts))) * 1e5
}

0 comments on commit de5520f

Please sign in to comment.