Package Logo
realfun_token_stream
realfun-token-stream@v0.5.0
Total Downloads
45
Published
1 weeks ago
Publisher
User Avatar tenax002

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.

Documentation

Modules

Maps icon
Maps

map
map_tokens_created

2f67a1e39a1637227db77da2c6d8714a3e3b3342
map map_tokens_created (
blocksf.ethereum.type.v2.Block
)  -> contract.v1.TokensCreatedOutput
substreams gui realfun-token-stream@v0.5.0 map_tokens_created

map
map_buy_sell_events

85c02c50c6a1164872aea367b0e5bcaeab97118d
map map_buy_sell_events (
paramsstring
store_pairsGET<set,string>
)  -> contract.v1.Transactions
substreams gui realfun-token-stream@v0.5.0 map_buy_sell_events

map
map_king_of_the_hill

8822ce2615013afba22cdbf444002e4760a80608
map map_king_of_the_hill (
)  -> contract.v1.KingStatusOutput
substreams gui realfun-token-stream@v0.5.0 map_king_of_the_hill

map
map_price_bars

f761b21f3ef907f62f719b1dfca681cf5d20b0da
map map_price_bars (
paramsstring
)  -> contract.v1.PriceBars
substreams gui realfun-token-stream@v0.5.0 map_price_bars

map
debug_stored_pairs

36d021e9576243859b944a712561f6da403c7903
map debug_stored_pairs (
store_pairsGET<set,string>
)  -> contract.v1.DebugOutput
substreams gui realfun-token-stream@v0.5.0 debug_stored_pairs

map
ethcommon:all_events

963652a247fd23d0823dde62d21ae54c783b6073
map ethcommon:all_events (
)  -> sf.substreams.ethereum.v1.Events

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

substreams gui realfun-token-stream@v0.5.0 ethcommon:all_events

map
ethcommon:all_calls

ba4f8e82a1fdc3ffbf060bed89482619bdc2a771
map ethcommon:all_calls (
)  -> sf.substreams.ethereum.v1.Calls

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

substreams gui realfun-token-stream@v0.5.0 ethcommon:all_calls

map
ethcommon:filtered_events

8fea38111c0a0111c18aa8a573a9d9a2369aa2f1
Default param : evt_sig:0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31

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

substreams gui realfun-token-stream@v0.5.0 ethcommon:filtered_events

map
ethcommon:filtered_calls

d655efe9beb681bed30a0e9183823dcb98344762
Default param : call_method:0xa9059cbb && call_to:0xdac17f958d2ee523a2206206994597c13d831ec7

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

substreams gui realfun-token-stream@v0.5.0 ethcommon:filtered_calls

map
ethcommon:filtered_transactions

d6ccd50b8175be235cbf2f18c0ad7d2d41e913b6
map ethcommon:filtered_transactions (
paramsstring
)  -> sf.substreams.ethereum.v1.Transactions
Default param : evt_sig:0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31 || (call_method:0xa9059cbb && call_to:0xdac17f958d2ee523a2206206994597c13d831ec7)

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

substreams gui realfun-token-stream@v0.5.0 ethcommon:filtered_transactions

map
ethcommon:filtered_events_and_calls

a0c728ef58e8dc842dc3a0f234cfc18bc8b3a2c7
Default param : evt_sig:0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31 || (call_method:0xa9059cbb && call_to:0xdac17f958d2ee523a2206206994597c13d831ec7)

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)

substreams gui realfun-token-stream@v0.5.0 ethcommon:filtered_events_and_calls
Stores icon
Stores

store
store_pairs

ddd06ae219105740d35256753c3ab2ff8cc7a97b
store <set,string> store_pairs (
)
substreams gui realfun-token-stream@v0.5.0 store_pairs
Block Indexes icon
Block Indexes

blockIndex
ethcommon:index_events

87255243f80f5d4755cd826ec57bf70696a4d7b6

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)
substreams gui realfun-token-stream@v0.5.0 ethcommon:index_events

blockIndex
ethcommon:index_calls

5d7204db974da4bb8cea5f7582f0d4a412332acd

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)
substreams gui realfun-token-stream@v0.5.0 ethcommon:index_calls

blockIndex
ethcommon:index_events_and_calls

9fecea473d8588a59ffe0fbdb8dd71f48de302b9

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)
substreams gui realfun-token-stream@v0.5.0 ethcommon:index_events_and_calls
Protobuf

Protobuf Docs Explorer

sf.ethereum.type.v2
contract.v1
sf.ethereum.substreams.v1