Skip to content

refactor(subgraph): anchor fee-auction purchases on ERC-20 Transfer#128

Draft
rvagg wants to merge 1 commit intofeat/collect-auction-statsfrom
rvagg/auction-burn-transfer-anchor
Draft

refactor(subgraph): anchor fee-auction purchases on ERC-20 Transfer#128
rvagg wants to merge 1 commit intofeat/collect-auction-statsfrom
rvagg/auction-burn-transfer-anchor

Conversation

@rvagg
Copy link
Copy Markdown

@rvagg rvagg commented Apr 21, 2026

No description provided.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
filecoin-pay-explorer Ready Ready Preview, Comment Apr 21, 2026 9:18am

Request Review

network: "{{network}}"
source:
abi: erc20
address: "{{usdfcContractAddress}}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pay can be used with any ERC20 token, we don't know the token list beforehand 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding all thus far known used tokens: #130

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 burnForFees call handler and corresponding ABI function entry.
  • Adds a new USDFC data source to index Transfer events and route them to handleFeeAuctionTransfer.
  • 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.

Comment on lines +748 to +752
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).
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +778 to +782
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;
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@juliangruber juliangruber marked this pull request as draft April 22, 2026 08:00
@juliangruber
Copy link
Copy Markdown
Member

Converting to draft as axlUSDC is missing (see #130)

@BigLep BigLep moved this from 📌 Triage to 🐱 Todo in FOC Apr 23, 2026
@BigLep BigLep added this to the M4.5: GA Fast Follows milestone May 2, 2026
@BigLep
Copy link
Copy Markdown
Contributor

BigLep commented May 2, 2026

@juliangruber : is this needed for GA? I assume not, but let me know if that isn't the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🐱 Todo

Development

Successfully merging this pull request may close these issues.

5 participants