a2a_swap_sdk/lib.rs
1//! A2A-Swap Rust SDK
2//!
3//! Agent-native constant-product AMM client for Solana.
4//! Any Rust agent can swap, provide liquidity, and query pool state
5//! with zero boilerplate — no Anchor dependency required.
6//!
7//! # Quick Start
8//!
9//! ```rust,no_run
10//! use a2a_swap_sdk::{A2ASwapClient, SimulateParams, SwapParams};
11//! use solana_sdk::{pubkey::Pubkey, signature::Keypair};
12//! use std::str::FromStr;
13//!
14//! #[tokio::main]
15//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
16//! let client = A2ASwapClient::devnet();
17//! let keypair = Keypair::new(); // use your agent's funded keypair
18//!
19//! let sol = Pubkey::from_str("So11111111111111111111111111111111111111112")?;
20//! let usdc = Pubkey::from_str("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")?;
21//!
22//! // 1. Simulate first to check the trade
23//! let sim = client.simulate(SimulateParams {
24//! mint_in: sol, mint_out: usdc, amount_in: 1_000_000_000,
25//! }).await?;
26//! println!("Estimated out: {} price_impact: {:.2}%", sim.estimated_out, sim.price_impact_pct);
27//!
28//! // 2. Execute with 0.5% max slippage
29//! let result = client.convert(&keypair, SwapParams {
30//! mint_in: sol,
31//! mint_out: usdc,
32//! amount_in: 1_000_000_000,
33//! max_slippage_bps: 50,
34//! }).await?;
35//! println!("Swapped! tx: {}", result.signature);
36//!
37//! Ok(())
38//! }
39//! ```
40//!
41//! # Feature Overview
42//!
43//! | Method | Description |
44//! |--------|-------------|
45//! | [`A2ASwapClient::create_pool`] | Create a new pool for a mint pair |
46//! | [`A2ASwapClient::provide_liquidity`] | Deposit tokens, receive LP shares |
47//! | [`A2ASwapClient::convert`] | Atomic token swap |
48//! | [`A2ASwapClient::simulate`] | Off-chain fee + slippage breakdown |
49//! | [`A2ASwapClient::pool_info`] | Pool reserves, price, fee rate |
50//! | [`A2ASwapClient::my_positions`] | All LP positions for an owner |
51//! | [`A2ASwapClient::my_fees`] | Aggregated claimable fees |
52
53pub mod client;
54pub mod error;
55pub mod instructions;
56pub mod math;
57pub mod state;
58pub mod types;
59
60pub use client::A2ASwapClient;
61pub use error::{Error, Result};
62pub use types::*;