Open or close a perps position
swop_perps_orderOpen or close a Hyperliquid perpetual position for the linked user, within their margin and leverage caps set in the Swop app. The cap is MARGIN per position (e.g. $25) with a leverage ceiling (e.g. 5x) — so $25 at 5x controls ~$125 of exposure. TWO-STEP like swop_send: call WITHOUT confirm to preview (coin, direction, margin, leverage, resulting exposure, mark price); ALWAYS show the user the leverage and exposure and get explicit confirmation; then call again with previewId and confirm: true. reduceOnly:true closes/reduces an existing position. Over-cap or no delegation returns a Swop-app approval link. Perps are leveraged and can be liquidated — make the risk clear to the user.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coin | Yes | Perp market symbol, e.g. "BTC", "ETH", "SOL" | |
| confirm | No | true ONLY after the user confirmed the preview (with leverage + exposure shown) | |
| leverage | Yes | Leverage multiplier (capped by the user's setting and the market max) | |
| direction | Yes | long = buy/up, short = sell/down | |
| marginUsd | Yes | Margin (collateral) in USD to commit | |
| previewId | No | From the preview step | |
| reduceOnly | No | true to close/reduce an existing position instead of opening |