store

package
v0.4.19 Latest Latest
Warning

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

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

Documentation

Overview

Package store persists prefetched on-chain data to a local SQLite database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateSQL

func ValidateSQL(query string) error

Types

type DB

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

DB wraps a SQLite connection and owns the schema lifecycle.

func Open

func Open(path string) (*DB, error)

Open opens (or creates) the SQLite database at path and applies the Raydium schema.

func (*DB) Close

func (s *DB) Close() error

Close closes the underlying database connection.

func (*DB) DB

func (s *DB) DB() *sql.DB

DB returns the underlying *sql.DB for passing directly to sub-packages.

func (*DB) FilePath

func (s *DB) FilePath() string

DB returns the underlying *sql.DB for passing directly to sub-packages.

func (*DB) Query

func (d *DB) Query(
	ctx context.Context,
	query string,
	args []any,
) ([]map[string]any, error)

Query runs a caller-supplied, read-only SQL statement against the database and returns each row as a column-name-keyed map. ValidateSQL gates this to SELECT-only (no INSERT/UPDATE/DELETE/DDL/etc.) since, unlike every other method on DB, the query string itself is not a fixed literal in this codebase -- see e.g. the pnl agent's text-to-SQL node, which hands this a model-generated query.

func (*DB) Raw

func (s *DB) Raw() *sql.DB

Raw exposes the underlying *sql.DB for packages under prefetch/ whose store functions operate on a raw connection rather than this wrapper (e.g. perpfunding.SetTargetAllocation).

func (*DB) Schema

func (s *DB) Schema(ctx context.Context) (string, error)

func (*DB) WriteRaydiumAmm

func (s *DB) WriteRaydiumAmm(list []*raydiumamm.Summary) error

WriteRaydiumAmm upserts all AMM v4 pool summaries. Summary carries only vault pubkeys and balances; fee/market fields are omitted because AMM full-download is currently disabled in raydium.Create.

func (*DB) WriteRaydiumClmm

func (s *DB) WriteRaydiumClmm(list map[sgo.PublicKey]*clmm.Amm) error

WriteRaydiumClmm upserts all CLMM configs and pools.

Source Files

  • db.go
  • raydium.go

Jump to

Keyboard shortcuts

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