> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b3os.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Hyperliquid Close Position

Close an open perpetual position on Hyperliquid by placing a reduce-only IOC order at market price with slippage. Automatically determines side and size from current position. Ideal for: stop-loss execution, taking profits, and emergency position exits.

![Hyperliquid Close Position logo](https://cdn.b3.fun/hyperliquid-logo.png)
Catalog action Hyperliquid wallet

Close an open perpetual position on Hyperliquid by placing a reduce-only IOC order at market price with slippage. Automatically determines side and size from current position. Ideal for: stop-loss execution, taking profits, and emergency position exits.

**Review wallet and value movement**

This action can require a wallet connector, gas, token movement, or an external side effect. Test with simulation or a controlled amount before using it in a live workflow.

## At a Glance

| Field | Value |
| --- | --- |
| Action ID | `hyperliquid-close-position` |
| Category | Hyperliquid |
| Connector | `wallet` |
| Requires gas | No |
| Funds movement | None declared |
| Tags | `hyperliquid`, `perps`, `position`, `trade`, `trading` |

## Payload Schema

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `dex` | `string` | No | HIP-3 DEX name for TradFi markets. Omit for standard crypto perps. xyz = trade.xyz \(stocks, indices, commodities\), flx = flx.finance, vntl = vntl.exchange |
| `coin` | `string` | Yes | Asset symbol to close position for \(e.g., BTC, ETH for crypto; TSLA, SP500 for HIP-3 DEX\) |
| `slippageBps` | `number` | No | Slippage tolerance in basis points \(default 100 = 1%\). Price is adjusted from mid to ensure fill. |

## Result Schema

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | `string` | Yes | Close outcome |
| `coin` | `string` | No | Asset symbol |
| `closedSize` | `string` | No | Size that was closed |
| `avgPrice` | `string` | No | Average fill price |
| `side` | `string` | No | Side of the closing order \(buy to close short, sell to close long\) |
| `oid` | `number` | No | Hyperliquid order ID |
| `cloid` | `string` | No | Client order id attached to the close order \(0x + 32 hex\). Use to cancel or reconcile. |

## Examples

**Workflow node**

```json
{
  "type": "hyperliquid-close-position",
  "payload": {
    "coin": "example-coin"
  },
  "children": [],
  "connector": {
    "type": "wallet",
    "id": "conn_wallet"
  }
}
```
  **Test with API**

```bash
curl -X POST "https://api.b3os.org/v1/actions/hyperliquid-close-position/test" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "inputs": {
    "coin": "example-coin"
  }
}'
```

**Use expressions for dynamic values**

Payload fields can use workflow expressions such as `{{$trigger.body.amount}}`, `{{$nodes.fetch.result.price}}`, and `{{$props.asset}}` when the value should come from a trigger, prior node, or reusable workflow prop.