Perpetuals Agent
The Perpetuals Agent opens, manages and closes leveraged perpetual positions on decentralised orderbooks. V1 ships with Hyperliquid; the venue abstraction is ready for dYdX v4, GMX and Vertex as future implementations.
Architecturally separate from the Trading Agent because the risk model is different: positions persist between runs, leverage multiplies losses, liquidation can wipe collateral, and funding rates accumulate while open. Treasury (Bit2Me CEX), Trading (spot DEX), and Perpetuals (perp DEX) are the three orthogonal money-moving templates.
Setup
- Wallet — the agent’s bound Sigil wallet IS the Hyperliquid account. Address-based auth, no API key to create.
- Operator funds the account — send USDC on Arbitrum to
Hyperliquid’s bridge (
0x2Df1c51E09aECF9cacB7bc98cB1742757f163dF7). Funds appear in the wallet’s Hyperliquid balance after Arbitrum confirmation. Minimum ~5 USDC. Sigil does not auto-deposit in V1; the agent operates inside whatever margin you put there. - TEE mode required — the agent signs Hyperliquid action
payloads with the TEE-held private key. Org
signing_modemust betee. The TEE service learns no Hyperliquid specifics — the agentrun computes the EIP-712 digest and the TEE signs it as a plainraw_digest.
Configuration
| Field | Type | Notes |
|---|---|---|
allowed_markets | string[] | ["BTC-USD", "ETH-USD", ...]. Hyperliquid’s universe is ~100 perp markets; whitelist what the agent may trade. |
allowed_sides | string[] | ["long"], ["short"], or both. Long-only is safer to reason about. |
max_leverage | int 1-50 | Hard cap. Recommend 3-5x for production agents. |
max_position_size_usd | string | Notional cap per single open. |
max_total_exposure_usd | string | Sum of notional across all open positions on the venue. |
max_open_volume_per_day_usd | string | Rolling-24h cap on new opens. Closes don’t count. |
require_stop_loss | bool | When true (recommended), opens without SL are refused. |
min_distance_to_liquidation_pct | number | Refuse to open if liquidation price would land within X% of current. 0 disables. |
max_funding_rate_bps_against | number | Refuse to open when funding rate against your side exceeds this in bps/hr. |
builder_code | { address, fee_tenths_bp } | Customer’s builder code (see below). Empty = Sigil platform default. |
Tools
Read (always available, no policy gate):
| Tool | Returns |
|---|---|
perps_get_market(market) | Mid + mark + hourly funding rate (bps) + open interest + venue max leverage. |
perps_get_position(market?) | Open positions with size, entry, PnL, margin used, leverage, liquidation price. |
perps_get_account() | Total equity, available margin, total exposure. |
perps_get_funding_history(market, hours) | Recent hourly funding rates (1-168h lookback). |
Write (policy-gated server-side):
| Tool | Action |
|---|---|
perps_open_position(market, side, size_usd, leverage, stop_loss_price?, take_profit_price?, reason) | Opens via Ioc market-like order with optional SL/TP trigger orders attached. |
perps_close_position(market, size_usd?, reason) | Reduce-only Ioc. Omit size_usd to fully close. |
perps_adjust_stop_loss(market, new_stop_loss_price) | Tighten the SL (move closer to current price). Loosening refused. |
perps_cancel_stop_loss(market) | Refused when require_stop_loss=true. |
A refusal by policy returns ErrToolNotInvocable with the reason —
the LLM sees the error and adapts; it cannot bypass.
Workflow the agent follows
The system prompt requires this discipline before every open:
perps_get_market(market)→ current funding + mid price.perps_get_position(market)→ check existing exposure (no hedge mode in V1; close first if already long/short the opposite way).perps_get_account()→ confirmavailable_margin_usdcovers it.- Compute the liquidation price; reduce leverage if too close.
- Verify funding rate against your side is within
max_funding_rate_bps_against. perps_open_positionwith explicitstop_loss_pricewhenrequire_stop_loss=true.
Builder code
Hyperliquid forwards a configurable fee per trade to a builder
address. By default the agent uses Sigil’s platform builder code.
Set builder_code.address + builder_code.fee_tenths_bp in the
agent config to redirect that revenue to your own address — you keep
100% of the builder fees your agent generates.
Sigil’s default rate is competitive with industry frontends; you can
match or undercut. Fee is in tenths of a basis point: 5 means 0.05%
on each trade in addition to Hyperliquid’s protocol fees.
Audit trail
Every open / close / SL adjust writes a row to
agent_perps_position_events. The portal’s Positions tab on the
agent detail renders the timeline newest-first. Live state (PnL,
liquidation price, margin) always comes from Hyperliquid in real
time — Sigil never caches venue state.