How focus1010/solana-smart-tx-stack works
Purpose and Entry Points
This is a TypeScript/Node.js Solana transaction-infrastructure stack for submitting Jito bundles, monitoring their lifecycle, and producing auditable run evidence. The main batch-run entry point is src/index.ts, which initializes the orchestrator in src/stack.ts. Reactive submission modes are driven by src/scripts/run-marinade.ts and stream trigger modules.
Orchestration and Shared Contract
Stack coordinates observation, AI decisioning, bundle construction, submission, tracking, failure recovery, and lifecycle persistence. Shared domain records—including network snapshots, decisions, failures, and lifecycle entries—cross subsystem boundaries through src/types.ts; runtime configuration and safety limits originate in src/config.ts.
• src/stack.ts
• src/types.ts
• src/config.ts
Network Observation Layer
The stack is stream-first. SlotStream consumes Yellowstone Geyser slot events, maintains separate processed/confirmed/finalized progress, reconnects with replay/backpressure support, and falls back to RPC polling if the stream is unavailable. NetworkStateObserver derives current congestion and confirmation metrics, while TipOracle obtains Jito auction tip-floor data with Solana priority-fee fallback.
• src/stream/slot-stream.ts
• src/geyser/reconnecting-stream.ts
• src/stream/network-state-observer.ts
• src/stream/tip-oracle.ts
Jito Routing and Bundle Construction
Before submission, leader-window detection determines whether a Jito-connected leader is near. The builder obtains a confirmed-commitment blockhash via its cache, applies hard tip bounds, constructs the Jito bundle and tip instruction, and passes it to the selected Jito transport (JSON-RPC or gRPC). Mainnet submission is leader-window gated unless explicitly overridden.
• src/jito/leader-window-detector.ts
• src/bundle/bundle-builder.ts
• src/bundle/bundle-submitter.ts
• src/jito/create-jito-client.ts
AI Decision and Guardrail Boundary
The agent receives a complete network snapshot and decides the tip and, after failure, retry behavior. Provider selection is isolated behind an LLM abstraction: Groq/Llama is primary and Anthropic is optional. Model outputs are not authoritative: stack/builder guardrails clamp tips and prohibit retries for non-recoverable classes such as compute or simulation failures.
• src/agent/agent.ts
• src/agent/llm-provider.ts
• src/agent/provider-factory.ts
• src/bundle/failure-classifier.ts
Submission Lifecycle and Recovery
A real Solana transaction is also sent for independently verifiable on-chain signature tracking; the Jito bundle is submitted to the block engine. CommitmentTracker resolves processed, confirmed, and finalized stages from Yellowstone events first, with RPC signature-status fallback on timeout. LifecycleTracker records timestamps, source attribution, raw bundle outcomes, decision reasoning, snapshots, and classified failures; retries re-enter the agent-driven orchestration loop with refreshed blockhashes when selected.
• src/lifecycle/commitment-tracker.ts
• src/lifecycle/lifecycle-tracker.ts
• src/bundle/failure-classifier.ts
• logs/lifecycle.json
Reactive Triggering and Interfaces
Besides fixed-count batch execution, protocol event streams can initiate submissions: Marinade staking activity and USDC/Raydium triggers feed into the same Stack execution path. A local HTTP dashboard reads lifecycle records and presents aggregated status through a static frontend.
• src/stream/marinade-event-stream.ts
• src/stream/protocol-trigger.ts
• src/dashboard/server.ts
• web/dashboard/index.html
Runtime and External Dependencies
The runtime is Node.js 20.11+ with strict TypeScript. Material external boundaries are Solana RPC/WebSocket endpoints (a dedicated provider such as Helius is recommended), Yellowstone gRPC, Jito Block Engine and tip-floor API, Groq or Anthropic APIs, and a wallet private key. Lifecycle logs are the durable local audit boundary; evidence artifacts are generated from them under evidence/.
Main entry points: stack.ts Stack orchestrator · bundle-submitter.ts Bundle submitter · slot-stream.ts SlotStream · agent.ts AI agent
Components 22
Runtime
- Batch entry
src/index.ts - Stack orchestrator · Coordinates decisioning, submission, tracking, recovery, and persistence.
src/stack.ts - Domain contracts · Snapshots, decisions, failures, and lifecycle records.
src/types.ts - Safety configuration
src/config.ts
Network observation
- SlotStream · Tracks processed, confirmed, and finalized slots with RPC fallback.
src/stream/slot-stream.ts - Reconnecting Geyser · Reconnects with replay and backpressure support.
src/geyser/reconnecting-stream.ts - Network state observer
src/stream/network-state-observer.ts - Tip oracle · Uses Jito tip floors with priority-fee fallback.
src/stream/tip-oracle.ts
Decision & bundle
- AI agent · Decides tips and retry behavior from network snapshots.
src/agent/agent.ts - LLM providers · Selects Groq/Llama or optional Anthropic.
src/agent/provider-factory.ts - Leader-window detector
src/jito/leader-window-detector.ts - Bundle builder · Caches confirmed blockhashes and enforces hard tip bounds.
src/bundle/bundle-builder.ts - Bundle submitter
src/bundle/bundle-submitter.ts - Jito client
src/jito/create-jito-client.ts - Failure classifier · Blocks retries for non-recoverable compute or simulation failures.
src/bundle/failure-classifier.ts
Lifecycle & audit
- Commitment tracker · Uses Yellowstone events first and RPC status on timeout.
src/lifecycle/commitment-tracker.ts - Lifecycle tracker · Captures outcomes, reasoning, snapshots, and failures.
src/lifecycle/lifecycle-tracker.ts - Lifecycle log
logs/lifecycle.json
Triggers & dashboard
- Marinade event stream
src/stream/marinade-event-stream.ts - Protocol triggers · USDC/Raydium activity initiates stack execution.
src/stream/protocol-trigger.ts - Local dashboard · Aggregates lifecycle records for the static frontend.
src/dashboard/server.ts - Dashboard frontend
web/dashboard/index.html
Connections 22
- Batch entry → Stack orchestrator: initializes
- Marinade event stream → Stack orchestrator: triggers
- Protocol triggers → Stack orchestrator: triggers
- Safety configuration → Stack orchestrator: limits
- Domain contracts → Stack orchestrator: shared records
- Reconnecting Geyser → SlotStream: slot events
- SlotStream → Network state observer: progress
- SlotStream → Commitment tracker: commitment events
- Network state observer → Stack orchestrator: network snapshot
- Tip oracle → Stack orchestrator: tip floor
- Stack orchestrator → AI agent: requests decision
- LLM providers → AI agent: model provider
- AI agent → Bundle builder: tip decision
- Leader-window detector → Bundle submitter: submission gate
- Bundle builder → Bundle submitter: bundle and transaction
- Bundle submitter → Jito client: submits bundle
- Bundle submitter → Commitment tracker: signature
- Commitment tracker → Lifecycle tracker: commitment stages
- Failure classifier → Stack orchestrator: retry eligibility
- Lifecycle tracker → Lifecycle log: persists evidence
- Lifecycle log → Local dashboard: reads records
- Local dashboard → Dashboard frontend: serves