@@ -51,22 +51,35 @@ export const fetchGlobalProps = async () => {
5151 ? globalDynamic . head_block_number
5252 : Number ( globalDynamic . head_block_number ) || 0 ;
5353
54- // Hive inflation started at 9.5% and decreases by 0.01% every 250k blocks
55- // (roughly ~8.7 days) until it reaches the 0.95% floor. Using the 9.5% base
56- // keeps the APR math aligned with the blockchain monetary policy.
54+ // The blockchain exposes the current inflation rate (in basis points) as part
55+ // of the global props. Prefer that exact value when present so the APR stays
56+ // perfectly aligned with what on-chain tooling reports.
57+ const currentInflationRateRaw =
58+ typeof globalDynamic . current_inflation_rate === 'number'
59+ ? globalDynamic . current_inflation_rate
60+ : Number ( globalDynamic . current_inflation_rate ) || 0 ;
61+
5762 const inflationBase = 9.5 ;
5863 const inflationDecreasePerStep = 0.01 ;
5964 const blocksPerStep = 250000 ;
6065 const inflationFloor = 0.95 ;
61- const inflationReductionSteps = headBlockNumber / blocksPerStep ;
62- const inflationRate = Math . max (
66+ // Historically Hive did not start lowering the inflation rate until several
67+ // million blocks into the chain. Mirror that behaviour so the fallback math
68+ // matches the node implementation when `current_inflation_rate` is missing.
69+ const inflationStartBlock = 7000000 ;
70+ const inflationReductionSteps = Math . max ( headBlockNumber - inflationStartBlock , 0 ) / blocksPerStep ;
71+ const derivedInflationRate = Math . max (
6372 inflationFloor ,
64- inflationBase - inflationReductionSteps * inflationDecreasePerStep ,
73+ inflationBase - Math . floor ( inflationReductionSteps ) * inflationDecreasePerStep ,
6574 ) ;
6675
76+ const inflationRatePercent = currentInflationRateRaw > 0
77+ ? currentInflationRateRaw / 100
78+ : derivedInflationRate ;
79+
6780 const hpAprCandidate =
6881 _totalFunds > 0 && _virtualSupply > 0 && vestingRewardPercent > 0
69- ? ( ( _virtualSupply * ( inflationRate / 100 ) ) * vestingRewardPercent * 100 ) / _totalFunds
82+ ? ( _virtualSupply * ( inflationRatePercent / 100 ) * vestingRewardPercent * 100 ) / _totalFunds
7083 : 0 ;
7184 const hpApr = Number . isFinite ( hpAprCandidate ) ? hpAprCandidate : 0 ;
7285
0 commit comments