Transforms Kamino events into SQL database changes for PostgreSQL or ClickHouse. Tables: kamino_lend_events, kamino_liquidity_events, kamino_vault_events, kamino_multiply_events
Output
sf.substreams.sink.database.v1.DatabaseChanges
Inputs

Package ref
kamino-finance-events@v2.0.1Run package
CLI
Run db_out from the command line.
substreams run kamino-finance-events@v2.0.1 db_out -e solana --start-block -1substreams auth or directly on thegraph.market (see docs).README
Comprehensive Substreams package for indexing all Kamino Finance protocol activity on Solana - with stores and SQL sink support.
sf.solana.type.v1.Block
|
v
+-------------------+
| map_kamino_events | Extract ALL Kamino events from 4 programs
+--------+----------+
|
+----+----+--------------+
v v v
+--------+ +----------+ +--------------+
|store_ | |store_ | |db_out |
|reserves| |user_ | |(SQL sink) |
| | |positions | | |
+--------+ +----------+ +--------------+
| Module | Type | Description |
|---|---|---|
map_kamino_events | Map | Extracts and decodes all Kamino instructions using real Anchor discriminators |
store_reserves | Store | Tracks reserve metadata (mints, markets) by reserve address |
store_user_positions | Store | Tracks user deposit/borrow positions per reserve |
db_out | Map (Sink) | Outputs DatabaseChanges for PostgreSQL/ClickHouse via substreams-sink-sql |
# Stream events (GUI mode)
substreams gui ./substreams.yaml map_kamino_events -s 300000000 -t +100
# Stream events (JSON output)
substreams run ./substreams.yaml map_kamino_events \
-e mainnet.sol.streamingfast.io:443 \
-s 300000000 -t +1000 -o jsonl
# Run SQL sink to PostgreSQL
substreams-sink-sql setup "psql://user:pass@localhost:5432/kamino?sslmode=disable" ./kamino-finance-events-v2.0.0.spkg
substreams-sink-sql run "psql://user:pass@localhost:5432/kamino?sslmode=disable" ./kamino-finance-events-v2.0.0.spkg
| Program | ID | Events |
|---|---|---|
| klend (Lending) | KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD | deposit, withdraw, borrow, repay, liquidate, flash_borrow, flash_repay, deposit_and_collateralize, withdraw_and_redeem |
| Liquidity | E35i5qn7872eEmBt15e5VGhziUBzCTm43XCSWvDoQNNv | deposit, withdraw, invest, divest, rebalance, swap |
| kVault | kvauTFR3qESFtbxNsJnCU5yCCGPKGastMCHSsXzkvba | deposit, withdraw, invest, divest |
| kFarms | FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr | init_farm, refresh_farms, init_obligation_farms |
db_outThe db_out module writes to 4 tables:
kamino_lend_events - All lending operations with user, reserve, amountskamino_liquidity_events - Liquidity pool operationskamino_vault_events - Vault deposit/withdraw operationskamino_multiply_events - Farm/multiply operationsSee schema.sql for the full schema with indexes.
# Prerequisites: Rust, substreams CLI, buf CLI
rustup target add wasm32-unknown-unknown
# Clone
git clone https://github.com/PaulieB14/Kamino-Substreams.git
cd Kamino-Substreams
# Build
substreams build
# Visualize module graph
substreams graph
# Test with small block range
substreams run ./substreams.yaml map_kamino_events -s 300000000 -t +100
kamino-finance-events v2.0.0store_reserves for tracking reserve metadatastore_user_positions for tracking user deposit/borrow positionsdb_out SQL sink with PostgreSQL schema[lib] crate-type cdylib (was incorrectly [[bin]])MIT
Modules
Transforms Kamino events into SQL database changes for PostgreSQL or ClickHouse. Tables: kamino_lend_events, kamino_liquidity_events, kamino_vault_events, kamino_multiply_events
Output
sf.substreams.sink.database.v1.DatabaseChanges
Inputs
Extracts and decodes all Kamino Finance protocol events from Solana blocks. Monitors 4 Kamino programs using real Anchor instruction discriminators: - klend (KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD): Lending operations - Liquidity (E35i5qn7872eEmBt15e5VGhziUBzCTm43XCSWvDoQNNv): Liquidity management - kVault (kvauTFR3qESFtbxNsJnCU5yCCGPKGastMCHSsXzkvba): Vault strategies - kFarms (FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr): Farm rewards Parses real amounts from instruction data (u64 LE after 8-byte discriminator). Handles both top-level and inner (CPI) instructions.
Output
kamino.v1.KaminoEventsInputs
Tracks Kamino lending reserve metadata by reserve address. Stores lending market association, mint addresses, and cumulative stats.
Store value
proto:kamino.v1.ReserveInfoUpdate policy
set
Inputs
Tracks user lending positions (deposits and borrows) per reserve. Key format: {user}:{reserve}
Store value
proto:kamino.v1.UserPositionUpdate policy
set
Inputs