Documentation
¶
Overview ¶
Package leveragedloopv1 is the Go-side orchestrator for leveragedloopv1 -- Phase 2 of catscope-rust-bot's leveraged_yield_farming_plan.md: a single, conservative jitoSOL-collateral/USDC-debt leverage loop on Kamino, manual/explicit trigger only. A direct copy of package testperpv1's orchestration shape (same allocation/upload/handshake/ wallet-init flow, only MODE=leveragedloopv1 selected at upload time), minus the target-allocation plumbing testperpv1 carries for the basis-trade strategy -- this mode has no use for it.
It implements the brain.Brain interface and is responsible for:
- Allocating a slot on a Catscope/Solpipe validator pipeline (bid = 0, free tier).
- Uploading a WASM bot image to the validator with MODE=leveragedloopv1.
- Completing the handshake with the running bot instance.
- Sending a child keypair to the bot via stdin -- this mode's Rust side (catscope-rust-bot/src/brain/leveragedloopv1) signs the real Kamino deposit/borrow/withdraw/repay transactions its evaluate() state machine builds.
- Sending TriggerOpen/TriggerClose to the running bot on request (see eval.go's SendTriggerOpen/SendTriggerClose) -- nothing opens or closes a real position without one of these being called explicitly.
Deliberately a **separate bot mode and Kamino obligation** from testperpv1 -- see catscope-rust-bot's src/brain/leveragedloopv1/mod.rs doc comment for why.
Index ¶
- Constants
- Variables
- func DoEchoRequest(payload string) catmsg.FixedPair
- func DoLstApy(mint sgo.PublicKey, stakingApy float64) catmsg.FixedPair
- func DoTriggerClose() catmsg.FixedPair
- func DoTriggerCloseAllBasisPositions() catmsg.FixedPair
- func DoTriggerEnableBasisTrading() catmsg.FixedPair
- func DoTriggerOpen(notionalUSD float64) catmsg.FixedPair
- func DoTriggerOpenAuto(notionalUSD float64) catmsg.FixedPair
- func DoTriggerRecoverToken(mint sgo.PublicKey) catmsg.FixedPair
- func DoTriggerRedepositUsdc(notionalUSD float64) catmsg.FixedPair
- func DoTriggerTestBatch() catmsg.FixedPair
- func DoTriggerTestBundler() catmsg.FixedPair
- func DoWallet(key sgo.PrivateKey) catmsg.FixedPair
- type Configuration
- type Hook
Constants ¶
const ( KeyFlagEchoRequest uint8 = 1 KeyFlagEchoResponse uint8 = 2 KeyFlagWallet uint8 = 3 KeyFlagTriggerOpen uint8 = 4 KeyFlagTriggerClose uint8 = 5 KeyFlagTriggerRecoverToken uint8 = 6 KeyFlagTriggerRedepositUsdc uint8 = 7 KeyFlagTriggerTestBundler uint8 = 8 KeyFlagTriggerTestBatch uint8 = 9 KeyFlagLstApy uint8 = 10 KeyFlagTriggerOpenAuto uint8 = 11 KeyFlagTriggerEnableBasisTrading uint8 = 12 KeyFlagTriggerCloseAllBasisPositions uint8 = 13 // KeyFlagCommonAccountUsage is shared across every brain/* package // (not just this one) -- see the doc comment above. KeyFlagCommonAccountUsage uint8 = 200 )
Variables ¶
ErrBotNotConnectedYet is returned by the Send* trigger methods below when `hs.instance` hasn't been set yet -- see their shared doc comment on `nilInstance` for why this check exists and how callers should react to it.
Functions ¶
func DoLstApy ¶
DoLstApy builds the wire message for a real annualized LST staking-yield update (fraction, e.g. 0.073 for 7.3%/yr) for one liquid-staking-token, keyed by its real mint pubkey rather than a symbol -- see KeyFlagLstApy's doc comment above for why.
func DoTriggerClose ¶
DoTriggerClose builds the wire message requesting the bot deleverage and close its current position.
func DoTriggerCloseAllBasisPositions ¶
DoTriggerCloseAllBasisPositions builds the wire message force-closing every currently-open basis-trade position, independent of the cycle's own logic -- see KeyFlagTriggerCloseAllBasisPositions's doc comment above.
func DoTriggerEnableBasisTrading ¶
DoTriggerEnableBasisTrading builds the wire message opting into the real Phoenix-perp-funding-vs-Kamino-rate basis trade -- a one-time enable, see KeyFlagTriggerEnableBasisTrading's doc comment above.
func DoTriggerOpen ¶
DoTriggerOpen builds the wire message requesting the bot open a real leveraged position, sized at notionalUSD.
func DoTriggerOpenAuto ¶
DoTriggerOpenAuto builds the wire message for a real TriggerOpenAuto -- same notional-USD payload as DoTriggerOpen, but the bot picks the LST candidate itself via its own Time-Expanded DAG.
func DoTriggerRecoverToken ¶
DoTriggerRecoverToken builds the wire message requesting the bot swap its entire real balance of mint back to USDC, independent of the loop's phase.
func DoTriggerRedepositUsdc ¶
DoTriggerRedepositUsdc builds the wire message requesting the bot swap notionalUSD of USDC to jitoSOL and deposit it as additional Kamino collateral, independent of the loop's phase.
func DoTriggerTestBatch ¶
DoTriggerTestBatch builds the wire message requesting the bot send two separate, real, deliberately inert transactions via the generic transactionprocessor::batch host import (not send_bundler_pair's durable-nonce pair).
func DoTriggerTestBundler ¶
DoTriggerTestBundler builds the wire message requesting the bot send a trivial, real Astralane dual-transaction bundle -- proves the pipeline end-to-end without risking a real trading operation on it.
func DoWallet ¶
func DoWallet(key sgo.PrivateKey) catmsg.FixedPair
Types ¶
type Hook ¶
type Hook interface {
brain.Brain
SendTriggerOpen(notionalUSD float64) error
SendTriggerOpenAuto(notionalUSD float64) error
SendTriggerEnableBasisTrading() error
SendTriggerCloseAllBasisPositions() error
SendTriggerClose() error
SendTriggerRecoverToken(mint sgo.PublicKey) error
SendTriggerRedepositUsdc(notionalUSD float64) error
SendTriggerTestBundler() error
SendTriggerTestBatch() error
SendBundlerTipUpdate(update bundler.TipUpdate) error
}
Hook is brain.Brain plus this mode's own explicit trigger senders -- returned instead of a bare brain.Brain so cmd/leveragedloop.go can call SendTriggerOpen/SendTriggerClose on the same instance it hands to mothership.Create (a Hook value is itself a valid brain.Brain, since this interface embeds it).
func Create ¶
func Create(ctx context.Context, cancel context.CancelCauseFunc, parentKey sgo.PrivateKey, config *Configuration, db *sql.DB) (Hook, error)
Create creates a leveragedloopv1 gRPC event hook. db is the already-open prefetch.db connection (see store.DB.Raw()) -- unused by this mode's Go side today (no persistence needed for a one-shot trigger, unlike testperpv1's target allocation), kept for signature parity with every other bot mode's Create.
Source Files
¶
- eval.go
- init.go
- instance.go
- leveragedloopv1.go
- message.go