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.
Using AI to code? Add the LaserSell MCP server to your editor so your AI assistant can search LaserSell documentation in real time.
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.
Liquidity snapshots (Tier 1+)
Professional and Advanced tier subscribers receive real time liquidity snapshots alongside PnL updates. Each snapshot contains slippage bands and a liquidity trend indicator. See the full announcement. StreamSession caches the latest snapshot per position:
let bands = session.get_slippage_bands;
let max_tokens = session.get_max_sell_at_slippage; // 5% slippage
let trend = session.get_liquidity_trend; // "growing" | "stable" | "draining"
Partial sell
Build a sell transaction for a subset of a position's tokens using the PositionHandle from any StreamEvent:
let response = client.build_partial_sell_tx.await?;
Combine with slippage bands to sell the maximum amount within your desired price impact.
Exit ladder
Sell partial amounts at multiple profit thresholds:
use StrategyConfigBuilder;
use TakeProfitLevelMsg;
let strategy = new
.stop_loss_pct
.take_profit_levels
.build;
Liquidity guard
Prevent exits into thin liquidity:
let strategy = new
.target_profit_pct
.stop_loss_pct
.liquidity_guard
.build;
Breakeven trail
A trailing stop that activates at breakeven:
let strategy = new
.target_profit_pct
.stop_loss_pct
.breakeven_trail_pct
.build;
Per-position strategy override
Override the global strategy for a single position:
session.sender.update_position_strategy?;
Wallet registration
All wallets must be registered before connecting to the Exit Intelligence Stream:
use prove_ownership;
// 1. Prove ownership (local Ed25519 signature)
let proof = prove_ownership;
// 2. Register with the API
client.register_wallet.await?;
// 3. Connect with registered wallet (convenience method)
let session = stream_client.connect_with_wallets.await?;
Watch wallets (copy trading)
Mirror trades from external wallets:
session.sender.update_watch_wallets?;
Priority lanes
Split the stream into high-priority and low-priority channels. Exit signals flow through the high-priority channel while PnL updates and liquidity snapshots flow through the low-priority channel:
let connection = connect.await?;
let lanes = connection.into_lanes; // low-priority channel buffer size
RPC endpoint
The SDK ships with the Solana public 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.