All packages
realfun_token_stream

realfun_token_stream

tenax002
v0.5.0/3 downloads

Package ref

realfun-token-stream@v0.5.0

Run package

CLI

Run map_tokens_created from the command line.

substreams run realfun-token-stream@v0.5.0 map_tokens_created -e base_sepolia --start-block -1
Authenticate by running substreams auth or directly on thegraph.market (see docs).

README

realfun_token_stream Substreams Modules

This package was initialized via substreams init, using the evm-events-calls template.

Usage

substreams build
substreams auth
substreams gui       			  # Get streaming!
substreams registry login         # Login to substreams.dev
substreams registry publish       # Publish your Substreams to substreams.dev

Modules

All of these modules produce data filtered by these contracts:

  • Factory at 0x39e93ce835fbe020a51da32c2e5fec2580703c2e
  • Pair contracts created from the factory

store_pairs

This module listens for MemeTokenCreated events emitted by the factory contract and stores the addresses of the created token pairs. These stored pair addresses are later used to filter buy and sell events.

Output: Stores pair addresses in a persistent store.


map_tokens_created

This module captures all MemeTokenCreated events from the factory contract. It extracts details about the created tokens, such as their address, name, symbol, image URL, and description.

Output:

  • token_address
  • pair_address
  • creator
  • name
  • symbol
  • image_url
  • description

map_buy_sell_events

This module processes buy and sell events (TokensPurchased and TokensSold) from the token pairs created by the factory. It matches events to the tracked pairs and classifies them as "buy" or "sell" transactions.

Output:

  • event_type: "buy" or "sell"
  • user: Address of the buyer or seller
  • eth_amount: ETH spent or received
  • token_amount: Tokens purchased or sold
  • current_price: Current token price
  • total_supply: Total token supply
  • circulating_supply: Circulating token supply
  • eth_reserve: ETH reserve in the pool

map_king_of_the_hill

This module identifies the token with the highest market cap from the processed TokensPurchased events. Market cap is calculated as:

Market Cap = current_price * circulating_supply

Output:

  • king_bonding_pair: Address of the top token's pair
  • market_cap: Highest market cap value

map_price_bars

This module generates OHLC (Open, High, Low, Close) price data, also known as "price bars," from the token buy and sell events. It aggregates price and volume data over specified intervals (default is 1 minute).

Output:

  • mint: Token identifier
  • timestamp: Time of the price bar
  • open: Opening price
  • high: Highest price during the interval
  • low: Lowest price during the interval
  • close: Closing price
  • volume: Total traded volume
  • slot: Block slot number
  • is_1_min: Indicates if the interval is 1 minute
  • is_5_min: Indicates if the interval is 5 minutes

Event Handling

We implemented the Event trait for the following Ethereum events:

  • MemeTokenCreated
  • TokensPurchased
  • TokensSold

These events are processed by the modules to extract, store, and analyze data for meme tokens and related transactions.


Running the Substreams

Running Without Backprocessing

To run the Substreams starting from the latest block or a specific block (without backprocessing), use the following commands:

# Run from the module's initial block
substreams run ./realfun-token-stream-v0.1.0.spkg map_tokens_created \
  --start-block=21711925

# Run from the latest block (if supported)
substreams run ./realfun-token-stream-v0.1.0.spkg map_tokens_created \
  --start-block=now

Running Other Modules

# Run the buy/sell events module
substreams run ./realfun-token-stream-v0.1.0.spkg map_buy_sell_events \
  --start-block=21711925

# Run the King of the Hill module
substreams run ./realfun-token-stream-v0.1.0.spkg map_king_of_the_hill \
  --start-block=21711925

# Run the price bars module
substreams run ./realfun-token-stream-v0.1.0.spkg map_price_bars \
  --start-block=21711925

GUI Interaction

To visualize and interact with the data via GUI:

substreams gui --start-block=21711925

Ensure you have authenticated and configured your .substreams.env with the correct SUBSTREAMS_API_TOKEN before running these commands.

Modules

Execution graph

15 modules
Show 9 dependencies
map

ethcommon:all_calls

`all_calls` gives you all the calls in a block (including internal calls), with basic block hash/number/timestamp and transaction hash

Output

sf.substreams.ethereum.v1.Calls

map

ethcommon:all_events

`all_events` gives you all the events in a block (from successful transactions), with basic block hash/number/timestamp and transaction hash

Output

sf.substreams.ethereum.v1.Events

map

ethcommon:filtered_calls

`filtered_calls` reads from `all_calls` and applies a filter on the called contract, the caller and the method 4-bytes signature Supported operators are: logical or `||`, logical and `&&` and parenthesis: `()` Addresses to match must be written as 0x-prefixed hexadecimal, lowercase, prefixed by `call_to:` or `call_from:`, methods by `call_method:`. Example: `(call_to:0x1234... || call_from:0x1234...) && call_method:0xdeadbeef...`

Output

sf.substreams.ethereum.v1.Calls

map

ethcommon:filtered_events

`filtered_events` reads from `all_events` and applies a filter on the event addresses and signatures. Supported operators are: logical or `||`, logical and `&&` and parenthesis: `()` Addresses to match must be written as 0x-prefixed hexadecimal, lowercase, prefixed by `evt_addr:` and signatures by `evt_sig:`. Example: `(evt_addr:0x1234... || evt_addr:0x5678...) && evt_sig:0xdeadbeef...`

Output

sf.substreams.ethereum.v1.Events

map

ethcommon:filtered_events_and_calls

`filtered_events_and_calls` reads from `all_calls` and `all_events`, then applies a filter to extract the items that interest you, based on called contract, caller, call method, event address and event signature. Supported operators are: logical or `||`, logical and `&&` and parenthesis: `()` Addresses and signatures to match must be written as 0x-prefixed hexadecimal, lowercase, prefixed by `evt_addr:`, `evt_sig:`, `call_to:`, `call_from:` or `call_method:`. Example: evt_sig:0x9bb8f83800000000000000000000000000000000000000000000000000000000 || (call_method:0xa9059cbb && call_to:0xdac17f958d2ee523a2206206994597c13d831ec7)

Output

sf.substreams.ethereum.v1.EventsAndCalls

map

ethcommon:filtered_transactions

`filtered_transactions` reads from ethereum blocks and applies a filter on the events (addresses and signatures) as well as calls (from, to and method). Supported operators are: logical or `||`, logical and `&&` and parenthesis: `()` Addresses and signatures to match must be written as 0x-prefixed hexadecimal, lowercase, prefixed by `evt_addr:`, `evt_sig:`, `call_to:`, `call_from:` or `call_method:`. Example: `((evt_addr:0x1234... || evt_addr:0x5678...) && evt_sig:0xdeadbeef...) || call_to:0x01010101...`

Output

sf.substreams.ethereum.v1.Transactions

blockIndex

ethcommon:index_calls

`index_calls` sets the following keys on the block: * Call contract call_to:0x0123456789abcdef0123456789abcdef01234567 (contract address in hex, prefixed by 0x) * Caller call_from:0x0123456789abcdef0123456789abcdef01234567 (caller address in hex, prefixed by 0x) * Call method call_method:0x01234567 (4 bytes of method signature in hex, prefixed by 0x)

Output

sf.substreams.index.v1.Keys

blockIndex

ethcommon:index_events

`index_events` sets the following keys on the block: * Event signatures evt_sig:0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef (signature in hex, prefixed by 0x) * Event address evt_addr:0x0123456789abcdef0123456789abcdef01234567 (address in hex, prefixed by 0x)

Output

sf.substreams.index.v1.Keys

blockIndex

ethcommon:index_events_and_calls

`index_events_and_calls` sets the following keys on the block: * Event signatures evt_sig:0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef (signature in hex, prefixed by 0x) * Event address evt_addr:0x0123456789abcdef0123456789abcdef01234567 (address in hex, prefixed by 0x) * Call contract call_to:0x0123456789abcdef0123456789abcdef01234567 (contract address in hex, prefixed by 0x) * Caller call_from:0x0123456789abcdef0123456789abcdef01234567 (caller address in hex, prefixed by 0x) * Call method call_method:0x01234567 (4 bytes of method signature in hex, prefixed by 0x)

Output

sf.substreams.index.v1.Keys