Simple tool for generating list of all accounts and their underlying balances that were delegating for the Save YAM account at a specific block height
- Node/npm
- An Ethereum node that has all historic DelegateChanged events as well as state at the block height you want to snapshot. Not having either of these will cause the snapshot to have incorrect data.
- Update the
JSON_RPC_URL
field inconfig.js
to have an Ethereum node URL that satisfies the above requirements npm install
to install packagesnpm run build
to build this projectnpm start delegation blockNumber
to print out a snapshot. ReplaceblockNumber
with the block you want to snapshot at. LeavingblockNumber
blank will default it to the current block height
- Fetch all
DelegateChanged
events between [yamContractCreatedBlock, blockHeight] that have the Save YAM account as the target - Grab the delegator addresses from the events
- Filter addresses by unique
- Get the current delegate using
YamContract.delegates
of each delegator at the blockHeight - Filter accounts that are still delegating to proper delegate at proper blockHeight
- Get the
YamContract.balanceOfUnderlying
of each account
Aside from the CLI tool, you can also import the YamDelegationSnapshotBuilder
class for usage in your own project. Calling YamDelegationSnapshotBuilder.getDelegatedBalances(web3: Web3, blockHeight: string): Promise<Array<{address: string, balance: bigint}>>
will return the list of people that were properly delegated at that block height and their underlying balances (internal balances that are unaffected by rebases)