refactor(subgraph): anchor fee-auction purchases on ERC-20 Transfer#128
refactor(subgraph): anchor fee-auction purchases on ERC-20 Transfer#128rvagg wants to merge 1 commit intofeat/collect-auction-statsfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| network: "{{network}}" | ||
| source: | ||
| abi: erc20 | ||
| address: "{{usdfcContractAddress}}" |
There was a problem hiding this comment.
Pay can be used with any ERC20 token, we don't know the token list beforehand 🤔
There was a problem hiding this comment.
Pull request overview
Refactors fee-auction purchase indexing in the subgraph to anchor on ERC-20 Transfer logs (USDFC) instead of relying on trace_filter/call handlers, so fee-auction purchases can be captured from standard event logs.
Changes:
- Removes the
burnForFeescall handler and corresponding ABI function entry. - Adds a new
USDFCdata source to indexTransferevents and route them tohandleFeeAuctionTransfer. - Updates config JSONs to supply USDFC contract address/startBlock variables used by the manifest template.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/subgraph/templates/subgraph.template.yaml | Drops call handler; adds USDFC ERC-20 Transfer data source with context for Payments address. |
| packages/subgraph/src/payments.ts | Replaces call-based fee auction handling with Transfer-based handler + selector filtering; updates Token aggregates. |
| packages/subgraph/config/mainnet.json | Adds USDFC address/start block to support template expansion. |
| packages/subgraph/config/calibration.json | Adds USDFC address/start block to support template expansion. |
| packages/subgraph/config/Payments-abi.json | Removes burnForFees function definition since it’s no longer used for call handlers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function handleFeeAuctionTransfer(event: TransferEvent): void { | ||
| const paymentsAddress = dataSource.context().getBytes("paymentsAddress"); | ||
|
|
||
| // Only interested in outflows FROM FilecoinPay (i.e. FilecoinPay paying out | ||
| // either a withdrawal or a fee-auction purchase). |
There was a problem hiding this comment.
handleFeeAuctionTransfer introduces new fee-auction indexing logic (selector filtering + FeeAuctionPurchase/Token updates) but there are no Matchstick tests covering this path. Add unit tests for the happy path and for negative cases (wrong selector / wrong from / tx.to != payments).
| const purchaseId = getFeeAuctionPurchaseEntityId(event.transaction.hash, event.transaction.index); | ||
| const purchase = new FeeAuctionPurchase(purchaseId); | ||
| purchase.token = tokenAddress; | ||
| purchase.recipient = recipient; | ||
| purchase.amountPurchased = requested; | ||
| purchase.amountPurchased = amountPurchased; |
There was a problem hiding this comment.
FeeAuctionPurchase IDs are built from (txHash, txIndex). With an ERC-20 Transfer handler, a single transaction can emit multiple matching Transfer logs, which would cause entity ID collisions and overwrite data. Prefer including the log index (e.g., txHash + event.logIndex) and/or reusing getIdFromTxHashAndLogIndex for uniqueness.
|
Converting to draft as axlUSDC is missing (see #130) |
|
@juliangruber : is this needed for GA? I assume not, but let me know if that isn't the case. |
No description provided.