paradigmxyz/rivet

Enhancement: Auto-import ERC20 tokens after fork

Closed this issue · 0 comments

The Request

The ability for Rivet to automatically import ERC20 tokens that have been transferred to an account after the fork block number.

This feature is different from retrieving ERC20 tokens before the fork block number. This is more non-trivial (should we use an indexer? or should we paginate filter or log queries on the RPC Provider?). However, for after the fork, I believe Anvil has an indefinite block range for log queries (eth_getLogs), so we could probably just use that and filter against ERC20 Transfer events.

Problem

Currently, Rivet does not pick up new ERC20 tokens that have been transferred to an account.

Example: After a successful swap from USDC -> DAI on Uniswap, I would expect to see DAI in my ERC20 tokens list in Rivet, however I cannot see them at the moment.

Solution

As a user, if I receive some new ERC20 tokens, I would expect Rivet to automatically import those tokens so I can see them in the ERC20 token list.

Notes

We could probably use viem's getLogs with a block range of forkBlockNumber to "latest", and scope on the Transfer event.