lasersell-sdk
Rust SDK for the LaserSell API.
Full documentation: docs.lasersell.io/api/sdk/rust
Modules
exit_api: Build unsigned buy/sell transactions.stream: Exit Intelligence Stream client, protocol types, and session helpers.tx: Sign, encode, and submit Solana transactions.retry: Shared retry helpers.
Install
Build a sell transaction
use ;
use SecretString;
let client = with_api_key?;
let request = BuildSellTxRequest ;
let response = client.build_sell_tx.await?;
println!;
Stream + auto-sell flow
Important: Connect the stream before submitting a buy transaction. See docs.lasersell.io/api/exit-api/buy for details.
use ;
use ;
use ServerMessage;
use ;
use SecretString;
use read_keypair_file;
let keypair = read_keypair_file?;
let http = builder.no_proxy.build?;
let client = new;
let configure = StreamConfigure ;
let mut session = connect.await?;
while let Some = session.recv.await
Strategy options
The strategy_config_from_optional helper builds a StrategyConfigMsg from optional fields. At least one exit condition must be enabled: take profit, stop loss, trailing stop, or deadline timeout.
use strategy_config_from_optional;
// Take profit at 20%, stop loss at 10%, trailing stop at 5%
let strategy = strategy_config_from_optional;
Trailing stop locks in profits by tracking a high-water mark. When the position's profit drops by the configured percentage of entry cost from its peak, an exit is triggered. For example, with trailing_stop_pct = 5.0 and an entry of 100 SOL: if profit peaks at 30 SOL, an exit triggers when profit falls below 25 SOL.
Sell on graduation
Automatically exit a position when its token graduates from a bonding curve to a full DEX (e.g. Pump.fun to PumpSwap). Enable by setting sell_on_graduation on the strategy config:
use StrategyConfigMsg;
let strategy = StrategyConfigMsg ;
When a graduation event is detected the server sells the position on the new market and reports "graduation" as the exit reason.
Update wallets mid-session
Add or remove wallets without reconnecting:
session.sender.update_wallets.await?;
The server diffs the new list against the current set and registers/unregisters accordingly.
RPC endpoint
The SDK ships with the Solana public mainnet-beta RPC as a default so you can get started immediately:
let target = default_rpc;
A private RPC is highly recommended for production — the public endpoint is rate-limited and unreliable under load. Free private RPC tiers are available from Helius and Chainstack, among others:
let target = Rpc ;
Examples
See examples/ for runnable programs:
examples/build_buy.rs: Build unsigned buy txexamples/build_sell.rs: Build unsigned sell txexamples/build_and_send_sell.rs: Build, sign, and submit sell txexamples/auto_sell.rs: Stream listener that signs and submits exits
Error types
ExitApiError: API transport and response errorsTxSubmitError: Transaction signing and submission errors
Both implement std::error::Error and can be matched by variant for structured error handling.