Add Ethereum Paymasters adapter for ERC-4337 fee tracking #4900
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This adapter tracks gas sponsorship in the ERC-4337 Account Abstraction ecosystem on Ethereum. It scans the official EntryPoint v0.6 contract and aggregates
UserOperationEventlogs to compute the daily gas sponsored by paymasters.Real Data Example (November 30, 2024)
Top Paymaster:
0x00000000000000fb866daaa79352cc568a005d96sponsored 98.22% of all gasless transactions.What it measures
dailyFeesdailyRevenuemeta.totalUserOpsmeta.sponsoredUserOpspaymaster != address(0)meta.sponsoredSharemeta.perPaymasterData source
0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789UserOperationEventgetLogs(no external APIs)Methodology
For each day, we:
UserOperationEventlogs from the EntryPoint contract.paymaster != address(0)(sponsored ops).actualGasCostfor these sponsored operations.dailyFeesanddailyRevenue(they are equal).Non-sponsored operations (where users pay their own gas via their EntryPoint deposit) are counted in
totalUserOpsbut not included in fees calculation.Why this matters
While there are explorers for ERC-4337 (JiffyScan, etc.), there is currently no global "who pays the gas" view in DeFi analytics. This adapter creates a new dataset that shows:
This is particularly valuable for wallet teams, L2 ecosystems, and infrastructure providers competing in the Account Abstraction space.
Technical highlights
formatWeiToETH()function avoidsNumberoverflow for large values.getFromBlock()/getToBlock()plusfromBlock/toBlock(and legacystartBlock/endBlock) to prevent unbounded historical queries.Example output (November 30, 2024)
{ "dailyFees": { "ethereum:0x0000000000000000000000000000000000000000": "219586165041850404" }, "dailyRevenue": { "ethereum:0x0000000000000000000000000000000000000000": "219586165041850404" }, "meta": { "totalUserOps": 552, "sponsoredUserOps": 39, "nonSponsoredUserOps": 513, "sponsoredShare": 0.0707, "sponsoredGasWei": "219586165041850404", "sponsoredGasETH": "0.219586165041850404", "perPaymaster": { "0x00000000000000fb866daaa79352cc568a005d96": { "ops": 37, "gasWei": "215691860934065920", "gasETH": "0.215691860934065920" }, "0x4fd9098af9ddcb41da48a1d78f91f1398965addc": { "ops": 2, "gasWei": "3894304107784484", "gasETH": "0.003894304107784484" } } } }Future extensions
Checklist
createBalances()andaddGasToken()getLogs