Documentation
¶
Overview ¶
Package clmm tracks clmm
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
- type Amm
- type AmmConfig
- type Configuration
- type DynamicFeeInfo
- type PoolRow
- type PoolState
- type PoolStateWithToken
- type Query
- type RewardInfo
- type U128
Constants ¶
const ( PoolStateBodySize = 1536 AmmConfigBodySize = 109 )
Body sizes (excluding the 8-byte Anchor discriminator).
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 -- see OldSlot in raydium/cpmm for the established precedent of this convention.
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("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK")
var Schema string
Functions ¶
func Download ¶
func ExportJSON ¶ added in v0.4.16
ExportJSON writes every liquid raydium_clmm_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 ~17,900 rows passing this filter, small enough to export in full -- unlike raydium_amm_pool's ~602K (see amm.embedCap's doc comment).
Types ¶
type Amm ¶ added in v0.4.16
type Amm struct {
Config *AmmConfig
MPool map[sgo.PublicKey]*PoolStateWithToken
}
Amm bundles a parsed AmmConfig with the pools discovered under it. Only referenced by the (currently unpopulated) Configuration type below -- event.go's eventHandler stopped using this shape once pool/vault bookkeeping moved to DB-backed lookups (see isConfigFresh/isPoolFresh/ findPoolByVault).
type AmmConfig ¶
type AmmConfig struct {
Bump uint8
Index uint16
Owner sgo.PublicKey
ProtocolFeeRate uint32
TradeFeeRate uint32
TickSpacing uint16
FundFeeRate uint32
FundOwner sgo.PublicKey
}
AmmConfig mirrors the Raydium CLMM AmmConfig struct (repr(C, packed), 109 bytes after discriminator).
type Configuration ¶
Configuration is the result of a completed CLMM pool download.
type DynamicFeeInfo ¶
type DynamicFeeInfo struct {
FilterPeriod uint16
DecayPeriod uint16
ReductionFactor uint16
DynamicFeeControl uint32
MaxVolatilityAccumulator uint32
TickSpacingIndexReference int32
VolatilityReference uint32
VolatilityAccumulator uint32
LastUpdateTimestamp uint64
}
DynamicFeeInfo mirrors the Raydium CLMM DynamicFeeInfo struct (repr(C, packed), 80 bytes).
type PoolRow ¶ added in v0.4.16
type PoolRow struct {
Pubkey sgo.PublicKey `json:"pubkey"`
TokenMint0 sgo.PublicKey `json:"token_mint0"`
TokenMint1 sgo.PublicKey `json:"token_mint1"`
TokenVault0 sgo.PublicKey `json:"token_vault0"`
TokenVault1 sgo.PublicKey `json:"token_vault1"`
Token0Balance uint64 `json:"token0_balance"`
Token1Balance uint64 `json:"token1_balance"`
TradeFeeRate uint32 `json:"trade_fee_rate"`
}
PoolRow is a flat view of a CLMM 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 {
Bump uint8
AmmConfig sgo.PublicKey
Owner sgo.PublicKey
TokenMint0 sgo.PublicKey
TokenMint1 sgo.PublicKey
TokenVault0 sgo.PublicKey
TokenVault1 sgo.PublicKey
ObservationKey sgo.PublicKey
MintDecimals0 uint8
MintDecimals1 uint8
TickSpacing uint16
Liquidity U128
SqrtPriceX64 U128
TickCurrent int32
FeeGrowthGlobal0X64 U128
FeeGrowthGlobal1X64 U128
ProtocolFeesToken0 uint64
ProtocolFeesToken1 uint64
Status uint8
FeeOn uint8
RewardInfos [3]RewardInfo
FundFeesToken0 uint64
FundFeesToken1 uint64
OpenTime uint64
RecentEpoch uint64
DynamicFeeInfo DynamicFeeInfo
}
PoolState mirrors the Raydium CLMM PoolState struct (repr(C, packed), 1536 bytes after discriminator). Source: https://github.com/raydium-io/raydium-clmm/blob/master/programs/amm/src/states/pool.rs
type PoolStateWithToken ¶
type PoolStateWithToken struct {
Info *PoolState
TokenVault0 *sgotkn.Account
TokenVault1 *sgotkn.Account
}
PoolStateWithToken bundles a parsed pool state with its fetched vault balances.
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_clmm_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 -- keeps the model from having to choose between many near-identical per-DEX tools.
type RewardInfo ¶
type RewardInfo struct {
RewardState uint8
OpenTime uint64
EndTime uint64
LastUpdateTime uint64
EmissionsPerSecondX64 U128
RewardTotalEmitted uint64
RewardClaimed uint64
TokenMint sgo.PublicKey
TokenVault sgo.PublicKey
Authority sgo.PublicKey
RewardGrowthGlobalX64 U128
}
RewardInfo mirrors the Raydium CLMM RewardInfo struct (repr(C, packed), 169 bytes).
Source Files
¶
- clmm.go
- event.go
- export.go
- query.go
- read.go
- schema.go