drift

package
v0.4.20 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package drift preloads Drift v2 SpotMarket accounts (global market data only -- User, the per-wallet position account, is not fetched here since there is no bounded set to bulk-load, and PerpMarket is skipped since it has no mint/vault of its own -- perp markets settle in the program's quote asset).

Index

Constants

This section is empty.

Variables

View Source
var DiscSpotMarket = [8]byte{100, 177, 8, 107, 168, 65, 65, 39}

Discriminator for the Anchor SpotMarket account type.

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

Functions

func ExportJSON

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

ExportJSON writes every tracked Drift spot market to path as a JSON array of SpotMarket values (its own existing json tags) -- the same real query loadSpotMarkets 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.

Types

type Drift

type Drift struct {
	SpotMarkets []*SpotMarket
	// contains filtered or unexported fields
}

Drift holds all Drift v2 SpotMarket accounts loaded at startup.

func Create

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

Create queries the Drift v2 program at depth 1 (program → spot market) and collects all spot market accounts, persisting results to db (drift_spot_market). If db already has spot markets from a previous run, they're loaded back instead of re-fetching, unless force is true.

func (*Drift) Find

func (d *Drift) Find(marketID sgo.PublicKey) *SpotMarket

Find looks up a spot market by its pubkey.

func (*Drift) String

func (d *Drift) String() string

type SpotMarket

type SpotMarket struct {
	Pubkey sgo.PublicKey `json:"pubkey"`
	Mint   sgo.PublicKey `json:"mint"`
	Vault  sgo.PublicKey `json:"vault"`
}

SpotMarket is the parsed state of a Drift v2 SpotMarket account.

func (*SpotMarket) String

func (m *SpotMarket) String() string

Source Files

  • drift.go
  • event.go
  • export.go
  • print.go
  • schema.go
  • spot_market.go
  • store.go

Jump to

Keyboard shortcuts

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