Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.meteora.ag/llms.txt

Use this file to discover all available pages before exploring further.

The public damm-v2-go repository provides Go examples for reading DAMM v2 state with solana-go. Treat it as example code for account reads, deserialization, and selected low-level instructions rather than a full transaction SDK.

Setup

git clone https://github.com/MeteoraAg/damm-v2-go.git
cd damm-v2-go
go mod tidy
Before running examples, set the RPC endpoint and addresses in the example file you are using. Some examples also require uncommenting the local main() function.
go run examples/get_pool.go

Available Examples

ExampleUse
get_pool.goFetch and deserialize a pool account
get_position.goFetch and deserialize a position account
get_positions_by_user.goResolve position NFTs and fetch positions for a wallet
get_user_position_by_pool.goFilter a user’s positions by pool
get_all_position_nft_account_by_owner.goRead position NFT token accounts by owner
get_unclaim_reward.goCalculate unclaimed reward information
claim_position_fee.goExample transaction flow for claiming position fees
The Go constants include the public DAMM v2 program ID:
const DammV2ProgramID = "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"

Helpers And Validation

HelperUse
DerivePoolAuthorityPDA()Derives the pool_authority PDA
DeriveEventAuthorityPDA()Derives the __event_authority PDA used by event CPI instructions
DerivePositionPDA(positionNft)Derives the position PDA from the position NFT mint
GetPool(ctx, pool, rpcClient)Fetches and deserializes a pool after checking the Anchor discriminator
GetPosition(ctx, position, rpcClient)Fetches and deserializes a position after checking the Anchor discriminator
GetPositionsByUser(ctx, rpcClient, user)Resolves position NFTs, derives position PDAs, fetches positions, and sorts by total liquidity
ClaimPositionFee(...)Builds a low-level claim-fee instruction including event CPI accounts

Integration Notes

TopicGuidance
Account validationExample readers check Anchor discriminators before deserializing pool and position data.
Position ownershipUser-position lookup starts from Token 2022 position NFT accounts owned by the wallet.
Transaction buildersPrefer the TypeScript SDK unless you are comfortable maintaining low-level Go instruction builders from the IDL.
Module pathThe local go.mod currently uses a different module path than the public repository name. Check upstream before importing it as a library.
State freshnessFetch pool accounts directly for transaction-critical reads; use the API for discovery and chart data.
Event CPI accountsLow-level instructions that emit events need event_authority and the program account in the expected account order.
For custom Go clients, generate from the public cp_amm IDL and cross-check account layouts against Accounts.