Documentation
¶
Overview ¶
Command harness is a minimal tool-calling agent, built the same way as go-wiki/examples/eino-ollama-agent/main.go (github.com/cloudwego/eino's prebuilt ReAct agent: call the model -> if it asked for a tool, run the tool and feed the result back -> repeat until the model answers without a tool call), but with walletTools() (see tools.go) in place of that example's demoTools().
walletTools() gives the agent read-only visibility into this repo's real trading wallet: its Solend/Kamino lending obligations, its raw token balances, live Jupiter USD prices, and total portfolio value -- the exact queries run by hand, script by script, over the course of a live session unwinding real positions in this wallet. It does not expose any of that session's mutating actions (repay/withdraw/sweep); see walletTools' own doc comment for why.
Usage:
go run . -prompt "What obligations are currently open, and what's the wallet worth right now?"
Index ¶
- Constants
- func NewStateClient(ctx context.Context, stateURL string) (state.Client, error)
- func WalletTools(stateClient state.Client, owner sgo.PublicKey) ([]tool.BaseTool, error)
- type Base
- type BookKeeping
- type Bot
- type BotCompiler
- type BotRuntime
- type BotRuntimeManager
- type Budget
- type ChainState
- type FileStore
- type StatusType
- type TokenBalance
- type Treasury
- type Valuation
- type Wallet
Constants ¶
const DefaultWallet = "Hg2p3cfmg3dratEVy94JArTVM7KzEywgNdmFnrfhroh9"
DefaultWallet is the trading child wallet every WalletTools() query targets by default -- the same real wallet (common.DeriveChildKeyFromIndex(parentKey, 1)) this session's manual scripts (checkob, manualrepay, manualwithdraw, sweeptousdc) all operated on. Override with -wallet to point this harness at a different address without needing the fee-payer keypair at all -- every tool here is read-only, so only the public key is ever needed. Exported so other packages building on this one (e.g. hedgefund's agents) share the same default without duplicating the literal.
const SolDelta graph.Lamports = sgo.LAMPORTS_PER_SOL >> 3
Variables ¶
This section is empty.
Functions ¶
func NewStateClient ¶
NewStateClient dials the same internal state.Client/gRPC graph endpoint every other read in this codebase uses (see cmd/multimodel.go's identical stateAddr/DefaultDialer construction), given a raw -state-url flag value. Exported so other standalone entrypoints building on this package (e.g. optimizer/hedgefund's CLI) can dial the same way without duplicating this parsing.
func WalletTools ¶
WalletTools builds the read-only wallet-inspection toolkit this harness exposes to the agent, distilled directly from the ad hoc Go scripts run by hand during this session's live unwind of a real Solana trading wallet (checkob/main.go, the balance checks around the sweep-to-USDC step, and the portfolio-value computation) -- see demoTools() in go-wiki/examples/eino-ollama-agent/main.go for the shape this mirrors (utils.InferTool + a plain Go function per tool).
Every tool here is READ-ONLY: it queries live on-chain/off-chain state and never signs or sends anything. The real manual-repair actions from that session (hand-built Kamino/Solend repay/withdraw instructions, sweeping dust tokens to USDC via Jupiter) are deliberately NOT exposed as callable tools here -- those move real money, and in the session they were only ever run after an explicit, per-action human go-ahead in conversation ("go ahead and build it", "go ahead and send it"). Wiring them into a freely-callable agent tool would remove that human gate entirely; this harness intentionally stops at "let the model see what a human would see," not "let the model act."
Types ¶
type BookKeeping ¶
type BookKeeping interface {
// take a snapshot of all token positions and market into an accounting book
Snapshot(Treasury) error
// Profit and Loss for a wallet
ProfitChild(start time.Time, finish time.Time, valuationMint sgo.PublicKey, childID sgo.PublicKey) (child float64, err error)
// Profit and Loss for the parent and aggregate the net income from child wallets
ProfitParent(start time.Time, finish time.Time, valuationMint sgo.PublicKey) (parentOnly float64, overall float64, err error)
}
type Bot ¶
type BotCompiler ¶
type BotRuntime ¶
type BotRuntime interface {
Status() StatusType
// set the budget in raw units of the Solpipe market mint over some slot count
Budget(amount uint64, slot graph.Slot)
BotList() []Bot
}
type BotRuntimeManager ¶
type BotRuntimeManager interface {
// Connect to a remote Bot runtime
Connect(ctx context.Context, pipelineID sgo.PublicKey) (BotRuntime, error)
}
BotRuntimeManager manages endpoints to Catscope WASM runtimes via Bot Solpipe market place.
type Budget ¶
type Budget interface {
ID() sgo.PublicKey
Pubkey() sgo.PublicKey
// if the target falls below SolDelta, top up the account
SetSOL(budget graph.Lamports)
// send money to a wallet
Fund(mint sgo.PublicKey, amount uint64)
// sweep token funds, leave minAmount in account
Sweep(mint sgo.PublicKey, minAmount uint64)
// Close all token accounts, close all protocol positions; sweep funds back to parent; Use Jupiter to power sweeps.
Close() error
// SetPositionCloser registers the callback Close() invokes first, to
// unwind whatever protocol-specific positions (lending deposits,
// perps, LP, etc.) this child wallet holds, before its resulting
// SOL/SPL token balances get swept back to the parent. The treasury
// package has no protocol-specific knowledge of its own -- these
// positions live entirely in each running bot instance's own
// on-chain state -- so whoever owns that context (typically the
// brain module driving this child's bot instance) must supply it.
// Close only sweeps SOL/token balances, skipping this step entirely,
// if nothing has been registered.
SetPositionCloser(closer func(ctx context.Context) error)
}
type ChainState ¶
type ChainState interface {
Base
// Database accesses the underlying database
Database() *store.DB
// Access an account
Account(sgo.PublicKey) graph.Account
}
ChainState maintains pool, dex data relevant for compiling static information into trading bots.
type FileStore ¶
type StatusType ¶
type StatusType = uint8
const ( StatusTypeOffline StatusType = 0 StatusTypeNonbidder StatusType = 1 StatusTypeBidder StatusType = 1 )
type Treasury ¶
type Treasury interface {
// Parent public key that distributes funds
Parent() Wallet
Children() []sgo.PublicKey
// Child derives a child key; this is for observing the current balances
Child(childID sgo.PublicKey) Wallet
// SOLBalance returns the current SOL balance in lamports
SOLBalance() uint64
// TokenBalance returns the current balance of tokens
TokenBalance() map[sgo.PublicKey]uint64
// manage funds via budget
Budget(childID sgo.PublicKey) Budget
}
type Valuation ¶
type Valuation struct {
Valuation float64
Token TokenBalance
}
Source Files
¶
- bot.go
- chainstate.go
- file.go
- harness.go
- tools.go
- treasury.go