-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadjust.mjs
33 lines (24 loc) · 1.06 KB
/
adjust.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import assert from 'node:assert';
import * as fs from 'node:fs';
import JSONBig from '@cardanosolutions/json-bigint';
const FROM = 280;
const TO = 489;
const $ = JSONBig({ useNativeBigInt: true });
for (let i = FROM; i <= TO; i += 1) {
const rewardsProvenance = $.parse(fs.readFileSync(`./raw/queryLedgerState/rewardsProvenance/${i}.json`));
const stakePools = rewardsProvenance.stakePools;
let activeStake = 0n;
let pools = [];
for (let poolId in stakePools) {
const stake = stakePools[poolId].stake.ada.lovelace;
activeStake += stake instanceof BigInt ? stake : BigInt(stake);
pools.push(stakePools[poolId]);
}
rewardsProvenance.totalRewards = rewardsProvenance.totalRewardsInEpoch;
delete rewardsProvenance.totalRewardsInEpoch;
rewardsProvenance.totalStake = rewardsProvenance.activeStakeInEpoch;
delete rewardsProvenance.activeStakeInEpoch;
rewardsProvenance.activeStake = { ada: { lovelace: activeStake } };
rewardsProvenance.stakePools = pools;
fs.writeFileSync(`./data/mainnet/${i}.json`, $.stringify(rewardsProvenance, null, 2));
}