cotyledon 0.1.0

Framework for writing sprouts — sandboxed, event-driven on-chain trading bots.
Documentation
//! cotyledon — the framework for writing sprouts.
//!
//! A sprout is sandboxed, event-driven trading logic. It declares its triggers
//! and wallet in `sprout.toml` and implements one handler per trigger inside a
//! `#[sprout::program]` module. Every privileged operation goes through [`Ctx`],
//! which the engine executes on the sprout's behalf — the sprout itself has no
//! keys, network, or ambient access.
//!
//! ```ignore
//! use cotyledon::prelude::*;
//!
//! #[sprout::program]
//! pub mod my_bot {
//!     pub async fn tick(ctx: Ctx) -> Result<()> {
//!         let _price = ctx.price("SOL").await?;
//!         Ok(())
//!     }
//! }
//! ```

mod ctx;
mod error;
mod host;
mod obs;
mod state;
mod types;
mod wallet;

#[cfg(target_arch = "wasm32")]
mod rt;

pub mod plugins;

/// Runtime support for the `#[sprout::program]`-generated wasm entrypoint. Not
/// a stable API — referenced only by macro output.
#[cfg(target_arch = "wasm32")]
#[doc(hidden)]
pub mod __rt {
    pub use crate::rt::*;
}

pub use ctx::{Ctx, Rpc};
pub use error::{Error, Result};
pub use obs::{Log, Metric};
pub use state::State;
pub use types::{Event, Receipt, Side, Trade, Usd};
pub use wallet::Wallet;

/// The `#[sprout::program]` attribute macro, namespaced so it reads naturally.
pub mod sprout {
    pub use cotyledon_macros::program;
}

/// Glob-import this in a sprout: `use cotyledon::prelude::*;`
pub mod prelude {
    pub use crate::sprout;
    pub use crate::{Ctx, Error, Event, Receipt, Result, Side, Trade, Usd, Wallet};

    #[cfg(feature = "jupiter")]
    pub use crate::plugins::jupiter;
    #[cfg(feature = "meteora")]
    pub use crate::plugins::meteora;
}