sanctum

package
v0.4.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package sanctum preloads Sanctum S Controller LST pool state.

Index

Constants

This section is empty.

Variables

View Source
var AssociatedTokenProgramID = sgo.MustPublicKeyFromBase58("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")

AssociatedTokenProgramID is the real SPL Associated Token Account program. Verified directly against igneous-labs/sanctum-ata-sdk (core/src/lib.rs) and a decoded live swap_exact_in transaction -- do not confuse with the visually-similar but wrong "...LJe1bxr" address that was hardcoded on the Rust side for a while (same vanity prefix, wrong tail); see catscope-rust-bot's docs/SANCTUM_ROUTING_DEBUG.md for the full story of how that bug was found.

View Source
var (
	LstStateListPDA sgo.PublicKey
)

PDAs derived from the Sanctum S Controller program. LstStateListPDA is exported so callers outside this package (e.g. prefetch/lst-yield) can read the single shared account tracking every Sanctum LST's sol_value without re-deriving the PDA themselves.

View Source
var (
	ProgramID = sgo.MustPublicKeyFromBase58("5ocnV1qiCgaQR8Jb8xWnVbApfaygJ8tNoZfgPwsgx9kx")
)
View Source
var Schema string

Functions

func ExportJSON added in v0.4.16

func ExportJSON(db *sql.DB, path string) error

ExportJSON writes every tracked Sanctum LST to path as a JSON array of LstEntry values (its own existing json tags) -- the same real query loadLsts already runs for in-process use, reused verbatim, so catscope-rust-bot's build.rs can read this file instead of opening prefetch.db directly.

func FindPoolReservesAddress added in v0.4.16

func FindPoolReservesAddress(mint sgo.PublicKey) (sgo.PublicKey, error)

FindPoolReservesAddress derives an LST's pool-reserves ATA the same way s-controller-lib's find_pool_reserves_address does: standard ATA seeds [wallet, token_program, mint] under AssociatedTokenProgramID, with wallet = the pool_state PDA -- mirrors sanctum.rs's spl_ata helper on the Rust side (now fixed to use the same correct program ID). Exported so callers outside this package (e.g. prefetch/lst-yield's generic rate fetcher) can derive an LST's reserve ATA without a live Subscribe/Hook round-trip.

Types

type LstConfig

type LstConfig struct {
	Mint               sgo.PublicKey `json:"mint"`
	SolValueCalculator sgo.PublicKey `json:"sol_value_calculator"`
	// value_calc_accounts left empty; fill manually per LST type
	ValueCalcAccounts []sgo.PublicKey `json:"value_calc_accounts"`
}

type LstEntry

type LstEntry struct {
	Mint               sgo.PublicKey `json:"mint"`
	SolValueCalculator sgo.PublicKey `json:"sol_value_calculator"`
	SolValue           uint64        `json:"sol_value"`
	// PoolState is the LST's underlying stake-pool account, needed as one
	// of the SOL-value-calculator CPI accounts for the SanctumSpl/
	// SanctumSplMulti/Spl calculator kinds (see registry.go). Zero value
	// means unknown -- either this LST's calculator kind doesn't need it
	// (Marinade/Lido/Wsol are resolved without this field, on the Rust
	// side) or the vendored registry didn't have an entry for it.
	PoolState sgo.PublicKey `json:"pool_state"`
	// Reserve is the raw token balance of this LST's pool-reserves ATA
	// (see findPoolReservesAddress), fetched live during Create. Seeds the
	// Rust side's SanctumState so spot_price() can resolve from the first
	// commit instead of waiting on a live on_token event -- see
	// SanctumLstSetup.reserve in sanctum.rs.
	Reserve uint64 `json:"reserve"`
}

LstEntry holds one LST's parsed state from the Sanctum S Controller.

func ParseLstStateList added in v0.4.16

func ParseLstStateList(data []byte) []*LstEntry

ParseLstStateList parses the lst_state_list account data into a slice of LstEntry. Each entry is lstStateSize bytes; the body starts at offset 0 (no discriminator). Exported so callers outside this package (e.g. prefetch/lst-yield's generic rate fetcher) can decode a raw account read of LstStateListPDA without going through this package's live Subscribe/Hook flow.

func (*LstEntry) String

func (e *LstEntry) String() string

type Query added in v0.4.16

type Query struct {
	// contains filtered or unexported fields
}

func CreateQuery added in v0.4.16

func CreateQuery(db *sql.DB) (*Query, error)

CreateQuery prepares the top-LSTs-by-SOL-value statement against sanctum_lst. 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.

func (*Query) TopPools added in v0.4.16

func (q *Query) TopPools(ctx context.Context, count int) (string, error)

TopPools returns up to count sanctum_lst mints, ranked by sol_value descending, as a semicolon-joined "mint=..." list.

type Sanctum

type Sanctum struct {
	Lsts []*LstEntry
}

Sanctum holds pool state and LST entries loaded at startup.

func Create

func Create(ctx context.Context, stateClient state.Client, db *sql.DB, force bool) (*Sanctum, error)

Create queries the Sanctum S Controller PDAs and parses LST entries, persisting results to db (sanctum_lst). If db already has LSTs from a previous run, they're loaded back instead of re-fetching, unless force is true.

func (*Sanctum) Args

func (s *Sanctum) Args(args []string) ([]string, error)

func (*Sanctum) Env

func (s *Sanctum) Env(mEnv map[string]string) error

func (*Sanctum) String

func (s *Sanctum) String() string

type SanctumConfiguration

type SanctumConfiguration struct {
	List []*LstConfig `json:"list"`
}

Source Files

  • event.go
  • export.go
  • loader.go
  • lst.go
  • print.go
  • query.go
  • registry.go
  • sanctum.go
  • schema.go
  • store.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL