Documentation
¶
Overview ¶
Package obligation records this bot's own Solend/Kamino lending obligation state (deposits/borrows, across multimodelv1's pair/ directional/hawkes trade types, since removed) into prefetch.db, the same skip-if-unchanged shape optimizer/prefetch/pnl uses for wallet token balances -- see this package's schema.sql for the real motivation (there was previously no way to see this state without manually deriving each obligation's address and parsing its raw account bytes).
Index ¶
- Variables
- func Address(owner sgo.PublicKey, protocol Protocol, id uint8) (sgo.PublicKey, error)
- func KaminoObligationAddress(owner sgo.PublicKey, id uint8) (sgo.PublicKey, error)
- func RecordIfChanged(db *sql.DB, s Snapshot) (bool, error)
- func SolendObligationAddress(owner sgo.PublicKey, id uint8) (sgo.PublicKey, error)
- type CurrentEntry
- type Entry
- type Parsed
- type Protocol
- type Snapshot
- type TradeType
Constants ¶
This section is empty.
Variables ¶
var KaminoMainMarket = sgo.MustPublicKeyFromBase58("7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF")
KaminoMainMarket is the single lending market every tracked trade type's Kamino obligation lives in -- see catscope-rust-bot's kamino::KAMINO_MAIN_MARKET (src/trader/dex/kamino.rs).
var Schema string
var TrackedObligations = []struct { TradeType TradeType Protocol Protocol ID uint8 }{ {TradePair, ProtocolSolend, 1}, {TradePair, ProtocolKamino, 2}, {TradeDirectional, ProtocolSolend, 2}, {TradeDirectional, ProtocolKamino, 3}, {TradeHawkes, ProtocolSolend, 3}, {TradeHawkes, ProtocolKamino, 4}, }
TrackedObligation is one (protocol, trade_type) obligation this bot's multimodelv1 mode (since removed) may have bootstrapped -- its id mirrored the exact PAIR_*_OBLIGATION_ID/DIRECTIONAL_*_OBLIGATION_ID/ HAWKES_*_OBLIGATION_ID constants multimodelv1's Rust side used to define. Kept as a fixed table rather than deleted -- any obligation multimodelv1 actually opened on-chain is real and still needs tracking by this exact id regardless of whether the Rust side that opened it still exists.
Functions ¶
func Address ¶
Address resolves a TrackedObligation entry's real on-chain address for owner.
func KaminoObligationAddress ¶
KaminoObligationAddress mirrors catscope-rust-bot's kamino:: obligation_pda: seeds `[[0], [id], owner, lending_market, default, default]` (tag=0, standard single-market-slot obligation; seed1/seed2 always the default/all-zero pubkey for every obligation this bot creates -- see obligation_pda's own doc comment in kamino.rs).
func RecordIfChanged ¶
RecordIfChanged inserts a new snapshot for (wallet, protocol, trade_type, reserve, kind) only if its amount differs from the most recently recorded one (or none exists yet). Returns whether a row was actually inserted.
Types ¶
type CurrentEntry ¶
type CurrentEntry struct {
Protocol Protocol
TradeType TradeType
Kind string
Reserve sgo.PublicKey
Amount uint64
Time time.Time
}
CurrentEntry is one (protocol, trade_type, reserve, kind)'s most recently recorded amount -- the "as of now" obligation state.
func Current ¶
Current returns wallet's most recent recorded amount for every (protocol, trade_type, reserve, kind) combination ever seen -- a flat "current obligation state" snapshot, not a timeseries. A reserve whose most recent recorded amount is 0 (fully withdrawn/repaid) is still included; callers that only want real open positions should filter Amount > 0 themselves.
type Entry ¶
type Entry struct {
Reserve sgo.PublicKey
// Amount is the raw on-chain unit for this (protocol, kind) --
// see schema.sql's own doc comment for the exact convention per
// protocol/kind combination.
Amount uint64
}
Entry is one deposit or borrow line inside a parsed obligation.
type Parsed ¶
Parsed is one obligation account's real deposits/borrows.
func ParseKamino ¶
ParseKamino mirrors catscope-rust-bot's kamino::parse_kamino_obligation. Deposits are raw cToken units (NOT yet converted to underlying -- see this package's schema.sql doc comment). Borrows are SF-scaled in the source account; this converts them (/2^60) before returning.
func ParseSolend ¶
ParseSolend mirrors catscope-rust-bot's solend::parse_obligation. Deposits are raw underlying-token units (no WAD conversion). Borrows are WAD-scaled in the source account; this converts them (/1e18) before returning, same convention parse_obligation itself uses.
type Snapshot ¶
type Snapshot struct {
Time time.Time
Wallet sgo.PublicKey
Protocol Protocol
TradeType TradeType
ObligationID uint8
Kind string // "deposit" or "borrow"
Reserve sgo.PublicKey
Amount uint64
}
Snapshot is one (protocol, trade_type, reserve, kind) observation.
type TradeType ¶
type TradeType string
TradeType is which strategy an obligation belongs to -- pair/ directional/hawkes were multimodelv1's trade types (since removed); kept here because a real obligation any of them opened on-chain still needs tracking by its exact id regardless of whether the Rust side that opened it still exists.
Source Files
¶
- address.go
- parse.go
- schema.go
- store.go