All packages
pump_unified_substreams

pump_unified_substreams

posaune0423
v0.1.0/3 downloads/Repository

Package ref

pump-unified-substreams@v0.1.0

Run package

CLI

Run map_program_data from the command line.

substreams run pump-unified-substreams@v0.1.0 map_program_data -e solana-mainnet --start-block -1
Authenticate by running substreams auth or directly on thegraph.market (see docs).

README

Pump Unified Substreams

Pump.fun Bonding CurvePump AMM の両方のプログラムからイベント・インストラクションをリアルタイムで取得する Substreams パッケージです。

flowchart LR
    subgraph Solana["Solana Mainnet"]
        PUMP["fa:fa-rocket pump.fun<br/>Bonding Curve"]
        AMM["fa:fa-exchange-alt Pump AMM"]
    end
    
    subgraph Substreams["Substreams"]
        MAP["fa:fa-filter map_program_data"]
    end
    
    subgraph Sink["substreams-sink-sql"]
        PG["fa:fa-database PostgreSQL"]
        PGWEB["fa:fa-globe pgweb"]
    end
    
    PUMP --> MAP
    AMM --> MAP
    MAP --> PG
    PG --> PGWEB

概要

プログラムProgram ID説明
pump.fun Bonding Curve6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6Pトークン作成・初期取引(ボンディングカーブ)
Pump AMMpAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEAGraduate後のAMM取引

取得できるイベント

Pump.fun Bonding Curve

イベント説明
CreateEvent新規トークン作成
TradeEvent売買取引
CompleteEventボンディングカーブ完了(Graduate)
SetParamsEventパラメータ設定

Pump AMM

イベント説明
AmmBuyEventAMM購入
AmmSellEventAMM売却
CreatePoolEventプール作成
DepositEventLP追加
WithdrawEventLP削除
CollectCoinCreatorFeeEventクリエイター手数料収集

クイックスタート

前提条件

# Substreams CLI インストール
brew install streamingfast/tap/substreams

# substreams-sink-sql インストール
brew install streamingfast/tap/substreams-sink-sql

# buf インストール(開発時のみ)
brew install bufbuild/buf/buf

1. 認証設定

# Substreams 認証
substreams auth

# .substreams.env が作成されます

2. ビルド

# WASMビルド
cargo build --target wasm32-unknown-unknown --release

# パッケージ作成
substreams pack substreams.yaml

3. 動作確認(GUI)

source .substreams.env
substreams gui substreams.yaml map_program_data

PostgreSQLへのデータ同期

Docker Compose で PostgreSQL 起動

docker-compose up -d
サービスURL説明
PostgreSQLlocalhost:5432データベース
pgwebhttp://localhost:8081Web UI

substreams-sink-sql 実行

source .substreams.env

substreams-sink-sql from-proto \
  "postgres://dev:insecure@localhost:5432/main?sslmode=disable" \
  substreams.yaml \
  map_program_data

オプション

# 開発モード(Undoサポート)
substreams-sink-sql from-proto \
  "postgres://dev:insecure@localhost:5432/main?sslmode=disable" \
  substreams.yaml \
  map_program_data \
  --development-mode

# 特定ブロック範囲
substreams-sink-sql from-proto \
  "postgres://dev:insecure@localhost:5432/main?sslmode=disable" \
  substreams.yaml \
  map_program_data \
  --start-block 298724475 \
  --stop-block +1000

データ確認

pgweb(Web UI)

ブラウザで http://localhost:8081 を開く

psql コマンド

# テーブル一覧
docker exec pump-unified-postgres psql -U dev -d main -c "\dt"

# TradeEvent 件数
docker exec pump-unified-postgres psql -U dev -d main -c "SELECT COUNT(*) FROM tradeevent"

# 最新のトレード
docker exec pump-unified-postgres psql -U dev -d main -c \
  "SELECT mint, sol_amount, token_amount, is_buy, \"user\", timestamp 
   FROM tradeevent 
   ORDER BY _block_number_ DESC 
   LIMIT 10"

# AMM Buy イベント
docker exec pump-unified-postgres psql -U dev -d main -c \
  "SELECT pool, \"user\", base_amount_out, quote_amount_in, timestamp 
   FROM ammbuyevent 
   ORDER BY _block_number_ DESC 
   LIMIT 10"

# 新規トークン作成
docker exec pump-unified-postgres psql -U dev -d main -c \
  "SELECT name, symbol, mint, \"user\" 
   FROM createevent 
   ORDER BY _block_number_ DESC 
   LIMIT 10"

テーブルスキーマ

tradeevent

カラム説明
mintVARCHARトークンアドレス
sol_amountNUMERICSOL量
token_amountNUMERICトークン量
is_buyBOOLEAN購入フラグ
userVARCHARユーザーアドレス
timestampBIGINTタイムスタンプ
virtual_sol_reservesNUMERIC仮想SOLリザーブ
virtual_token_reservesNUMERIC仮想トークンリザーブ
trx_hashVARCHARトランザクションハッシュ
block_numberNUMERICブロック番号

ammbuyevent / ammsellevent

カラム説明
poolVARCHARプールアドレス
userVARCHARユーザーアドレス
base_amount_out/inNUMERICベーストークン量
quote_amount_in/outNUMERICクオートトークン量(SOL)
lp_feeNUMERICLP手数料
protocol_feeNUMERICプロトコル手数料
coin_creator_feeNUMERICクリエイター手数料
timestampBIGINTタイムスタンプ

Substreams Registry への公開

source .substreams.env
substreams publish pump-unified-substreams-v0.1.0.spkg
  1. https://substreams.dev/me でトークンを取得
  2. プロンプトにトークンを貼り付け
  3. y で公開を確認

開発

プロジェクト構成

.
├── Cargo.toml                    # Rust設定
├── substreams.yaml               # Substreams設定
├── docker-compose.yml            # PostgreSQL + pgweb
├── idls/
│   ├── pump.json                 # pump.fun IDL
│   └── pump_amm.json             # Pump AMM IDL
├── proto/
│   └── program.proto             # Protobuf定義
└── src/
    ├── lib.rs                    # メインロジック
    ├── idl/
    │   └── mod.rs                # IDL宣言
    └── pb/
        └── (自動生成)

Proto再生成

buf generate proto

コードフォーマットとリント

フォーマット

# コードをフォーマット
cargo fmt

# フォーマットチェック(変更なし)
cargo fmt -- --check

# または Makefile を使用
make fmt          # フォーマット実行
make fmt-check    # フォーマットチェック

リント(Clippy)

# リント実行
cargo clippy

# リント実行(警告をエラーとして扱う)
cargo clippy -- -D warnings

# 自動修正可能な問題を修正
cargo clippy --fix --allow-dirty --allow-staged

# または Makefile を使用
make lint         # リント実行
make lint-fix     # 自動修正
make check        # フォーマットチェック + リント

コンテナ管理

# 起動
docker-compose up -d

# 停止
docker-compose down

# 完全削除(ボリュームも)
docker-compose down -v

ライセンス

MIT

Modules

Execution graph

4 modules
Show 3 dependencies
map

solana:v020:blocks_without_votes

`blocks_without_votes` allows you to consume a full Solana Block without Vote instructions (`Vote111111111111111111111111111111111111111`). If you consume it on HISTORICAL data (+1000 blocks from HEAD), you will be reading from the StreamingFast cache, thus saving costs on the amount of TB read.