SW4P Documentation
Browse documentation
Limit Orders

Limit Orders

This is an integration reference. The production backend and execution workers are currently in maintenance; do not fund or submit a live order from these examples.

Limit orders let a wallet schedule a USDC -> Solana-token purchase that fills when the Jupiter oracle price is at or below the target price.

Product Surface

The desktop app exposes Limit Orders from the Start Menu and desktop. It lets users:

  • choose the pre-funded Solana/WaaS funding source
  • choose the output token pair
  • set USDC amount and target price
  • set an expiry time
  • list open and closed orders
  • edit active orders
  • cancel active orders

The UI uses wallet JWT auth because orders are user-owned. The public API-key SDK clients use the /sdk/v2/orders/limit routes, which resolve the API key owner before creating or listing orders.

Current execution is intentionally restricted to source_chain: "SOL". Orders must be funded from the user's pre-funded WaaS Solana USDC balance. EVM funding rails are not advertised for limit orders until a real deposit/bridge readiness path exists.

TypeScript SDK

ts
const order = await client.createLimitOrder({
  source_chain: "SOL",
  token_out: "CQwwRomsuWsUCPYomZmRnwMns4ZCTASc31ExMvSysAF2",
  token_out_symbol: "555",
  amount_usdc: 100,
  target_price: 0.0055,
  expires_at: new Date(Date.now() + 7 * 86400_000).toISOString(),
});

await client.updateLimitOrder(order.id, {
  amount_usdc: 125,
  target_price: 0.005,
});

const orders = await client.listLimitOrders();
await client.cancelLimitOrder(order.id);

Rust SDK

rust
let order = client.create_limit_order(&CreateLimitOrderParams {
    source_chain: Some("SOL".to_string()),
    token_out: "CQwwRomsuWsUCPYomZmRnwMns4ZCTASc31ExMvSysAF2".to_string(),
    token_out_symbol: Some("555".to_string()),
    amount_usdc: 100.0,
    target_price: 0.0055,
    expires_at: Some("2026-04-30T00:00:00Z".to_string()),
}).await?;

client.update_limit_order(&order.id, &UpdateLimitOrderParams {
    amount_usdc: Some(125.0),
    target_price: Some(0.005),
    ..Default::default()
}).await?;

let orders = client.list_limit_orders().await?;
client.cancel_limit_order(&order.id).await?;

Backend Lifecycle

The limit_orders table records:

  • source chain
  • target token mint and optional symbol
  • USDC amount
  • target price
  • last observed oracle price
  • expiry
  • fill transaction hash and output amount
  • status: ACTIVE, FILLING, FILLED, CANCELLED, or EXPIRED

The worker polls Jupiter price API every 30 seconds for active, unexpired orders. On each cycle it records the latest oracle price. If the price is at or below target and execution is enabled, it atomically claims the row as FILLING, resolves the user's WaaS Solana wallet, and uses the shared Jupiter swap path.

Execution Gate

Production execution is gated by two environment variables:

bash
FEATURE_LIMIT_ORDERS_EXECUTION=true
LIMIT_ORDERS_DEVNET_VALIDATED=true

Without both flags, the worker still updates oracle prices and expires orders, but it will not submit swaps. Keep the flags off until the current deployment has passed the devnet validation script and the token route is tradable through the configured Jupiter environment.

API Routes

Wallet JWT routes:

  • POST /v1/orders/limit
  • GET /v1/orders/limit
  • PATCH /v1/orders/limit/:id
  • DELETE /v1/orders/limit/:id

API-key SDK routes:

  • POST /sdk/v2/orders/limit
  • GET /sdk/v2/orders/limit
  • PATCH /sdk/v2/orders/limit/:id
  • DELETE /sdk/v2/orders/limit/:id