Skip to main content
Alpha feature: Advanced Orders are gated and not publicly available yet. Reach out to the Mobula team to enable access for your account.
Stop Loss Advanced Orders help users protect downside without giving Mobula custody of their wallet or a reusable approval. The user deposits the exact tokenIn amount for the order, signs a canonical intent, and Mobula executes only when the fresh quote for amountRaw is less than or equal to triggerAmountOutRaw. Use this flow for Solana token stop-loss automation, SL lines on charts, protected exits, and any UX where the user wants a swap to execute only after the market falls to a defined output.

POST / GET

MethodPathPurpose
POST/api/2/swap/advanced-orders/intentBuild the canonical intent message to sign.
POST/api/2/swap/advanced-ordersCreate the signed order.
GET/api/2/swap/advanced-ordersList owner orders. Requires a read signature.
GET/api/2/swap/advanced-orders/:orderIdRead one order. Requires a read signature.
POST/api/2/swap/advanced-orders/:orderId/cancelCancel an open or triggered order.

End-to-End Flow

Advanced Orders are deposit-backed intents. The user keeps custody of their wallet keys and never gives Mobula a reusable approval, session key, or delegated signing power. The only funds Mobula can execute with are the exact tokens the user transfers to the Mobula deposit wallet for that order.
The deposited amount is held in the Mobula deposit wallet while the order is open. If the order is cancelled, expires, or cannot execute, the settlement flow refunds the confirmed deposit to the owner.
StepActorWhat happens
1IntegratorUse the Mobula-provided deposit wallet for the environment. The end user must not choose this address.
2User walletTransfer exactly amountRaw of tokenIn from ownerAddress to the Mobula deposit wallet.
3ClientCall POST /api/2/swap/advanced-orders/intent with the deposit transaction hash and all order parameters.
4Mobula APINormalizes the payload, resolves the server deposit wallet, validates addresses and amounts, then returns the canonical message to sign.
5User walletSigns the canonical message. This signature covers the chain, owner, recipient, tokens, amounts, trigger settings, expiry, deposit transaction, routing restrictions, and fees.
6ClientCall POST /api/2/swap/advanced-orders with the same fields plus intentSignature.
7Mobula APIVerifies the owner signature and stores the order idempotently by intent hash.
8Mobula workerPolls open orders every few seconds and verifies the deposit transaction on-chain. The deposit must be finalized, successful, sent by ownerAddress, sent to the Mobula deposit wallet, and match tokenIn + amountRaw.
9Mobula workerWatches swaps-stream for relevant token/pair updates. For TP/SL it pre-checks quote movement; for Triggers it confirms the configured Token Details fields through getTokenData.
10Mobula execution engineClaims the order, builds a fresh quote with the order constraints, checks minAmountOutRaw, signs only the swap transaction for the deposit wallet, and broadcasts it.
11Mobula settlementConfirms the broadcasted transaction. If filled, output funds are sent to recipientAddress. If cancelled, expired, or non-executable, the confirmed deposit is refunded to ownerAddress.

Non-Custodial Guarantees

GuaranteeHow it is enforced
Mobula cannot trade from the user’s walletThe user only signs an intent message, not a transaction spending future wallet balances.
Mobula cannot mutate the order after signingThe canonical message includes the full order payload. Changing any signed field changes the intent hash and invalidates the signature.
Mobula cannot use a different depositDeposit verification checks the exact finalized transfer: owner, deposit wallet, token, and raw amount.
Mobula cannot bypass the output guardExecution always checks the fresh quote against minAmountOutRaw before sending.
The user can exit before executionThe owner can cancel open/triggered orders with a signed cancel message. Confirmed deposits are then handled by the refund settlement flow.

Client Checklist

  1. Build and send the token transfer to the Mobula deposit wallet.
  2. Wait for the deposit transaction signature.
  3. Call POST /advanced-orders/intent.
  4. Ask the owner wallet to sign data.message.
  5. Call POST /advanced-orders with intentSignature.
  6. Poll GET /advanced-orders or GET /advanced-orders/:orderId.
  7. To cancel, sign the canonical cancel message and call POST /advanced-orders/:orderId/cancel.

Stop Loss Parameters

FieldValue
orderKindstop_loss
triggerDirectionlte
triggerAmountOutRawStop threshold.
minAmountOutRawHard execution floor. Must be <= triggerAmountOutRaw.
expiresAtFuture ISO date, max 90 days.

Stop Loss Intent Body

{
  "chainId": "solana:solana",
  "ownerAddress": "<OWNER>",
  "recipientAddress": "<OWNER>",
  "tokenIn": "<TOKEN_MINT>",
  "tokenOut": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "amountRaw": "1000000000",
  "minAmountOutRaw": "830000",
  "triggerAmountOutRaw": "850000",
  "triggerDirection": "lte",
  "orderKind": "stop_loss",
  "slippage": 2,
  "depositTransactionHash": "<DEPOSIT_TX_SIGNATURE>",
  "expiresAt": "2026-08-01T00:00:00.000Z",
  "onlyRouters": ["mobula"]
}
For lte orders, minAmountOutRaw cannot be higher than triggerAmountOutRaw.

Create a Stop Loss Order

const intent = await fetch("https://api.mobula.io/api/2/swap/advanced-orders/intent", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "x-api-key": "<YOUR_API_KEY>",
  },
  body: JSON.stringify(intentBody),
}).then((res) => res.json());

const intentSignature = await wallet.signMessage(intent.data.message);

await fetch("https://api.mobula.io/api/2/swap/advanced-orders", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "x-api-key": "<YOUR_API_KEY>",
  },
  body: JSON.stringify({ ...intentBody, intentSignature }),
});

Read

Read signatures use:
Mobula Advanced Order Read v1
{"ownerAddress":"<OWNER_ADDRESS>"}
curl "https://api.mobula.io/api/2/swap/advanced-orders?ownerAddress=<OWNER>&readSignature=<SIGNATURE>" \
  -H "x-api-key: <YOUR_API_KEY>"