-
Notifications
You must be signed in to change notification settings - Fork 203
feat(affiliates): add gas rebate merge utility for January 2026 #4928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds a utility script to merge two gas rebate JSON files into a single combined rebate. The script validates block ranges are contiguous and voting contracts match before merging shareholder payouts.
Periods 24136053-24358292 covering 622 voters with 3.97 ETH total.
|
|
||
| for (const [address, amount] of Object.entries(second)) { | ||
| if (merged[address]) { | ||
| merged[address] = merged[address] + amount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebate script uses parsed BigNumber, so we could end up loosing precision when merging multiple rebate sets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ty, fixed!
| return JSON.parse(content); | ||
| } | ||
|
|
||
| function validateBlockRanges(first, second) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also restrict that first.toBlock is the last block of a reveal cycle? Could this otherwise end up with different results than running the rebate script over single block range (e.g. due to constraints that only one commit per round is rebated)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment and a log. We should not use this script more than once, as we have different rebate configs.
…merging - Add ethToWeiBigInt and weiBigIntToEth functions to avoid floating point precision loss when summing rebate amounts - Add warning about splitting rebates at voting round boundaries to avoid inconsistent results vs single-run rebates
| */ | ||
| function ethToWeiBigInt(ethValue) { | ||
| // Convert to string and handle scientific notation | ||
| const ethStr = ethValue.toFixed(18); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this still introduces some JS rounding errors, e.g. ethValue = 0.1; ethValue.toFixed(18); ends up resulting in '0.100000000000000006'
but probably fine to leave for a one-off script as result objects store rebates as number, not string, so this is inevitable. might be better to use some library for parsing and conversion, e.g. ethers, but again, not worth for a one-off script
Adds a utility script to merge two gas rebate JSON files into a single combined rebate. The script validates block ranges are contiguous and voting contracts match before merging shareholder payouts.
Motivation
January 2026 gas rebates needed to be run in two separate block ranges due to memory/performance constraints, then merged into a single rebate file.
Summary
mergeRebates.jsutility to combine two rebate JSON filesRebate_64.jsoncovering blocks 24136053-24358292 (622 voters, 3.97 ETH)Details
Ran January gas rebates in two steps:
CUSTOM_NODE_URL=https://mainnet.infura.io/v3/xxx \ NODE_OPTIONS="--max-old-space-size=32096" \ OVERRIDE_FROM_BLOCK=24136053 \ OVERRIDE_TO_BLOCK=24236386 \ MIN_STAKED_TOKENS=1000 \ TRANSACTION_CONCURRENCY=10 \ MAX_BLOCK_LOOK_BACK=250 \ yarn hardhat run ./gas-rebate/VoterGasRebateV2.ts --network mainnetCUSTOM_NODE_URL=https://mainnet.infura.io/v3/xxx \ NODE_OPTIONS="--max-old-space-size=32096" \ OVERRIDE_FROM_BLOCK=24236387 \ OVERRIDE_TO_BLOCK=24358292 \ MIN_STAKED_TOKENS=1000 \ TRANSACTION_CONCURRENCY=10 \ MAX_BLOCK_LOOK_BACK=250 \ MAX_PRIORITY_FEE_GWEI=0.001 \ yarn hardhat run ./gas-rebate/VoterGasRebateV2.ts --network mainnetThen merged them with
node packages/affiliates/gas-rebate/mergeRebates.js <file1> <file2>Testing