diff --git a/packages/nimiq-supply-calculator/src/constants.ts b/packages/nimiq-supply-calculator/src/constants.ts index 41e3c93..6a93fcd 100644 --- a/packages/nimiq-supply-calculator/src/constants.ts +++ b/packages/nimiq-supply-calculator/src/constants.ts @@ -16,7 +16,7 @@ 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. @@ -24,7 +24,7 @@ export const SUPPLY_AT_PROOF_OF_STAKE_FORK_DATE = 12_893_109_654_06244 * 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. diff --git a/packages/nimiq-supply-calculator/src/pos.ts b/packages/nimiq-supply-calculator/src/pos.ts index 9c11d86..edb5eeb 100644 --- a/packages/nimiq-supply-calculator/src/pos.ts +++ b/packages/nimiq-supply-calculator/src/pos.ts @@ -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 }