Graph Protocol Indexer
A Graph Protocol subgraph that indexes all pool creation events, swaps, deposits, and withdrawals on Base Mainnet and Base Sepolia testnet.
LSSVM Subgraph
Graph Protocol subgraph for indexing LSSVM (Liquidity-Sensitive Single-Variant Market) pools on Base.
Contracts Indexed
Primary Contract: LSSVMPairFactory
- Address:
0xF6B4bDF778db19DD5928248DE4C18Ce22E8a5f5e - Network: Base Mainnet
- Start Block: 38239761
Events Indexed
Factory Events:
NewERC721Pair- When a new ERC721 pool is createdNewERC1155Pair- When a new ERC1155 pool is createdERC20Deposit- ERC20 token deposits into poolsNFTDeposit- NFT deposits into poolsERC1155Deposit- ERC1155 token deposits into pools
Pair Events (dynamically indexed):
SwapNFTInPair- NFTs swapped into pool (buy)SwapNFTOutPair- NFTs swapped out of pool (sell)SpotPriceUpdate- Spot price changesTokenDeposit/TokenWithdrawal- Token liquidity changesNFTWithdrawal- NFT withdrawalsDeltaUpdate- Bonding curve delta changesFeeUpdate- Fee changesAssetRecipientChange- Asset recipient changes
Setup
- Install dependencies:
npm install
- Generate TypeScript types:
npm run codegen
- Build the subgraph:
npm run build
Deployment
Deploy to The Graph Studio (Hosted Service)
- Create a subgraph on The Graph Studio
- Get your deployment key
- Deploy:
npm run deploy
Deploy Locally
- Start a local Graph node (see Graph Node docs)
- Create the subgraph:
npm run create-local
- Deploy:
npm run deploy-local
Schema
The subgraph indexes:
- Pool entities - All pool configurations and current state
- Swap entities - All buy/sell transactions
- Deposit entities - All deposits (NFTs, tokens, ERC1155)
- Withdrawal entities - All withdrawals
Query Examples
# Get all pools for a specific NFT contract
{
pools(where: { nftContract: "0x..." }) {
id
spotPrice
poolType
currentNFTBalance
currentTokenBalance
}
}
# Get all swaps for a pool
{
swaps(where: { pool: "0x..." }, orderBy: timestamp, orderDirection: desc) {
id
type
tokenAmount
nftIds
timestamp
}
}
Development
npm run codegen- Generate types from schema and ABIsnpm run build- Build the subgraphnpm run deploy- Deploy to The Graph Studionpm test- Run tests (if configured)