Documentation
¶
Overview ¶
Package cpmm tracks cpmm
Index ¶
- Constants
- Variables
- func Download(parentCtx context.Context, stateClient state.Client, db *sql.DB, ...) error
- func ExportJSON(db *sql.DB, path string) error
- func ReadPools(db *sql.DB, fn func(*PoolRow) bool) error
- func ReadPoolsByMints(db *sql.DB, mintA, mintB sgo.PublicKey, fn func(*PoolRow) bool) error
- type AmmConfig
- type Configuration
- type PoolRow
- type PoolState
- type Query
- type Summary
Constants ¶
const ( PoolStateBodySize = 629 AmmConfigBodySize = 228 )
Body sizes (excluding the 8-byte Anchor discriminator).
const OldSlot = 8 * 60 * 60 * 25 / 10
8 hours
const SevenDaysOfSlots = 7 * 24 * 60 * 60 * 25 / 10 // 1,512,000 slots
SevenDaysOfSlots assumes ~400ms/slot (2.5 slots/sec), the same fallback bot/state/clock.go itself uses before real slot-timing data arrives.
Variables ¶
var ( DiscPoolState = [8]byte{247, 237, 227, 245, 215, 195, 222, 70} DiscAmmConfig = [8]byte{218, 244, 33, 104, 203, 203, 43, 111} )
Anchor discriminators: sha256("account:<TypeName>")[0..8]
var ProgramID = sgo.MustPublicKeyFromBase58("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C")
var Schema string
Functions ¶
func Download ¶
func ExportJSON ¶ added in v0.4.16
ExportJSON writes every liquid raydium_cpmm_pool row (joined with its fee config, same filter ReadPools/TopPools already apply) to path, so catscope-rust-bot's build.rs can read this file instead of opening prefetch.db directly. No cap: a real prefetch.db has ~1,200 rows passing this filter.
func ReadPools ¶ added in v0.4.16
ReadPools calls fn for each liquid CPMM pool (lp_supply > 0, both vault balances non-zero). Iteration stops early if fn returns false.
Types ¶
type AmmConfig ¶
type AmmConfig struct {
Bump uint8
DisableCreatePool bool
Index uint16
TradeFeeRate uint64
ProtocolFeeRate uint64
FundFeeRate uint64
CreatePoolFee uint64
ProtocolOwner sgo.PublicKey
FundOwner sgo.PublicKey
CreatorFeeRate uint64
}
AmmConfig mirrors the Raydium CPMM AmmConfig struct (repr(C, packed), 228 bytes after discriminator).
type Configuration ¶
type Configuration struct{}
Configuration is the result of a completed CPMM pool download.
type PoolRow ¶ added in v0.4.16
type PoolRow struct {
Pubkey sgo.PublicKey `json:"pubkey"`
AmmConfig sgo.PublicKey `json:"amm_config"`
Token0Mint sgo.PublicKey `json:"token0_mint"`
Token1Mint sgo.PublicKey `json:"token1_mint"`
Token0Vault sgo.PublicKey `json:"token0_vault"`
Token1Vault sgo.PublicKey `json:"token1_vault"`
LpSupply uint64 `json:"lp_supply"`
Token0Balance uint64 `json:"token0_balance"`
Token1Balance uint64 `json:"token1_balance"`
TradeFeeRate uint64 `json:"trade_fee_rate"`
}
PoolRow is a flat view of a CPMM pool joined with its fee config. Json tags let this struct be exported directly (see export.go) instead of via a separate JSON-shaped type.
type PoolState ¶
type PoolState struct {
AmmConfig sgo.PublicKey
PoolCreator sgo.PublicKey
Token0Vault sgo.PublicKey
Token1Vault sgo.PublicKey
LpMint sgo.PublicKey
Token0Mint sgo.PublicKey
Token1Mint sgo.PublicKey
Token0Program sgo.PublicKey // SPL Token or Token-2022 program
Token1Program sgo.PublicKey
ObservationKey sgo.PublicKey
AuthBump uint8
Status uint8 // bitmask: deposit | withdraw | swap
LpMintDecimals uint8
Mint0Decimals uint8
Mint1Decimals uint8
LpSupply uint64
ProtocolFeesToken0 uint64
ProtocolFeesToken1 uint64
FundFeesToken0 uint64
FundFeesToken1 uint64
OpenTime uint64
RecentEpoch uint64
CreatorFeeOn uint8
EnableCreatorFee bool
CreatorFeesToken0 uint64
CreatorFeesToken1 uint64
}
PoolState mirrors the Raydium CPMM PoolState struct (repr(C, packed), 629 bytes after discriminator). Source: https://github.com/raydium-io/raydium-cp-swap/blob/master/programs/cp-swap/src/states/pool.rs
type Query ¶ added in v0.4.16
type Query struct {
// contains filtered or unexported fields
}
func CreateQuery ¶ added in v0.4.16
CreateQuery prepares the top-pools-by-liquidity statement against raydium_cpmm_pool. Callers wrap the result as one dispatch case of a single, consolidated "get top pools" tool (see prefetch/prompttool.go) rather than exposing their own separate tool.
Source Files
¶
- cpmm.go
- event.go
- export.go
- query.go
- read.go
- schema.go