Skip to main content

Crate cotyledon

Crate cotyledon 

Source
Expand description

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.

use cotyledon::prelude::*;

#[sprout::program]
pub mod my_bot {
    pub async fn tick(ctx: Ctx) -> Result<()> {
        let _price = ctx.price("SOL").await?;
        Ok(())
    }
}

Modules§

plugins
Official plugins. Each is opt-in behind a cargo feature:
prelude
Glob-import this in a sprout: use cotyledon::prelude::*;
sprout
The #[sprout::program] attribute macro, namespaced so it reads naturally.

Structs§

Ctx
Handle to the engine. Every method is executed by the engine on the sprout’s behalf; the sprout has no direct access to keys, network, or storage. Cheap to copy.
Event
A trigger event delivered to a handler, carrying the typed payload T.
Log
Logging. Messages are written to the sprout’s stdout/stderr, which the engine captures and stores — so ctx.log().info(..) and a plain println!(..) are equivalent. Logging is deliberately not a first-class engine call.
Metric
Metrics the platform charts for the sprout.
Receipt
The result of submitting a transaction.
Rpc
Submits transactions to the chain through the engine.
State
A small key/value store scoped to the sprout. Values are JSON-serialized.
Trade
A trade to record on the sprout’s activity feed. Build with Trade::buy / Trade::sell and pass to Ctx::emit.
Usd
A US-dollar amount.
Wallet
The sprout’s custodial wallet. Signing happens in the engine; the private key never enters the sandbox.

Enums§

Error
A sprout error.
Side
Trade direction.

Type Aliases§

Result
Convenience alias — handlers return Result<()>.