polar_bear_rig_onchain/lib.rs
1//! # polar-bear-rig-onchain
2//!
3//! **Polar Bear (🍨)** - rig-onchain-kit agent demonstrating Solana on-chain
4//! operations with `SignerContext` task-local signer isolation.
5//!
6//! Technology Lead: Murtaza Ali Imtiaz (July 2019 – present).
7//!
8//! ## Pipeline
9//!
10//! ```text
11//! ┌─────────────────────────────────────────────────────────────┐
12//! │ polar-bear-rig-onchain │
13//! ├──────────┬──────────────────────┬────────────────────────── ┤
14//! │ onchain │ agent │ config │
15//! │ signer │ SolanaBalanceTool │ Config::from_env() │
16//! │ balance │ JupiterQuoteTool │ ANTHROPIC_API_KEY │
17//! │ jupiter │ SignerIsolationTool │ WALLET_ADDRESS │
18//! │ types │ build_onchain_agent │ SOLANA_RPC_URL │
19//! └──────────┴──────────────────────┴───────────────────────────┘
20//! ```
21//!
22//! ## Full pipeline
23//!
24//! 1. **`SignerContext`** ([`onchain::signer`]) - a random ephemeral keypair is bound to the
25//! current Tokio task via `tokio::task_local!`. The `onchain::signer::SignerGuard` RAII wrapper
26//! guarantees the context is evicted even if the task panics.
27//! 2. **Balance query** ([`onchain::balance`]) - Solana devnet RPC `get_balance` call; returns
28//! lamports and SOL denomination.
29//! 3. **Jupiter quote** ([`onchain::jupiter`]) - read-only GET to the Jupiter V6 `/quote` endpoint;
30//! `dry_run = true` is baked in and a runtime `assert!` prevents any accidental swap execution.
31//! 4. **Isolation log** ([`onchain::signer`]) - `SignerContext::snapshot()` emits an
32//! [`onchain::signer::SignerSnapshot`] for the Reactor GUI audit trail.
33//!
34//! ## Quick start
35//!
36//! ```text
37//! cp .env.example .env # set ANTHROPIC_API_KEY
38//! cargo run --release -- --mode full --wallet <DEVNET_ADDRESS> --amount 0.1
39//! ```
40
41pub mod agent;
42pub mod config;
43pub mod onchain;