# Execution (/scripting-v2/furge/execution)



## Supported actions [#supported-actions]

| Exchange                           | Actions                                                                             | Historical simulation                                    |
| ---------------------------------- | ----------------------------------------------------------------------------------- | -------------------------------------------------------- |
| Hyperliquid perps / BULK           | `ctx.trade`, `ctx.order`, `ctx.cancel`; compatible position/order operations        | Supported with a compatible historical price source      |
| Hyperliquid Spot                   | `ctx.order`, `ctx.cancel`; no leverage                                              | Compatible simulator/source required                     |
| [Pacifica](/scripting-v2/pacifica) | Perpetual `ctx.trade`; spot/perpetual `ctx.order`, `ctx.cancel`                     | Compatible historical source/simulator required          |
| HyperLink                          | Perp/Spot routing using Hyperliquid data                                            | Compatible simulator/source required                     |
| Ascend / Montra                    | Exact-input `ctx.buy` and `ctx.sell` for HYPE pairs on Elysium mainnet              | Data analysis only                                       |
| [Nest](/scripting-v2/furge/nest)   | `ctx.buy`, `ctx.sell`, Classic deposits and withdrawals, concentrated range actions | Sandbox startup precheck; no contract-history simulation |

## Which account is used? [#which-account-is-used]

Configure trading accounts in **Accounts**. Ascend and Montra scripts sign with the **Elysium Automated Trading Wallet** on chain 99901. Fund it with the input asset and native HYPE for gas. Furge charges 2% on these script swaps in addition to the pool fee. The trade and Furge fee settle in one transaction. See [Token launches and market info](/scripting-v2/furge/sources/launches) for launch-driven scripts.

Nest scripts use the **HyperEVM Automated Trading Wallet** on HyperEVM mainnet. See [Nest Scripts](/scripting-v2/furge/nest) for wallet setup and actions.

A read-only script does not need a funded trading account. Never put secrets in Python source or logs.

## Perpetual orders [#perpetual-orders]

Inside `on_data`, after reading a matching market source, an explicit trade request looks like this:

```python
reference = ctx.trade({
    "exchange": "hyperliquidf",
    "symbol": "BTC",
    "position": "open-long",
    "margin": 10,
    "leverage": 1,
    "order": {"type": "market"},
    "max_slippage_bps": 50,
})
```

**This can place a real order in a live deployment.** It is an API illustration, not a complete strategy. Do not call it on every event without an intentional condition and duplicate guard.

The local return is `{"id": "ord_..."}`: accepted for processing, **not a confirmed fill**. Use `on_execution(ctx)` to inspect lifecycle events. An opening request needs exactly one of base `size` or quote `margin`. `50` bps means `0.5%`.

Raw `ctx.order` requests name `side` (`buy`/`sell`) instead of a position transition. Limit orders require a tick-aligned price. Cancelling an order does not close a filled position.

```python
reference = ctx.order({
    "exchange": "hyperliquidf",
    "symbol": "BTC",
    "side": "buy",
    "size": 0.001,
    "order": {"type": "limit", "price": 80500, "tif": "alo"},
})
```

This also returns `{"id": "ord_..."}`. The price is illustrative, not a current quote. Use `account` to name a configured account; omission selects `main`. HyperLink uses `hyperlinkf` for perps or `hyperlink` for Spot and is mainnet-only.

Cancel a managed order using that **local** ID, not an exchange order ID:

```python
ctx.cancel({"order": reference["id"]})
```

The cancellation return confirms queuing, not the venue outcome. Do not add `exchange`; it is resolved from the referenced order. Inspect `ctx.execution` in `on_execution(ctx)` for fills, cancellation results, or rejections. Market orders accept one slippage unit (`max_slippage_bps` or decimal `max_slippage`), not both; limit orders use their explicit price instead.

## Contract swaps [#contract-swaps]

Use `ctx.buy` to spend quote assets or `ctx.sell` to sell base tokens. Include the execution exchange, market, and amount as a decimal string.

```python
operation = ctx.buy({
    "exchange": "montra",
    "market": "<token-address>",
    "amount": "0.01",
    "slippage_bps": 50,
    "max_gas": "0.0001",
    "key": "first-buy",
})
```

Replace the placeholder with the Montra token address. The example spends 0.01 units of the pool’s quote asset. Call `ctx.sell` with the amount of base tokens to sell. See [Nest Python actions](/scripting-v2/nest#typed-execution-actions) for HyperEVM swaps.

A returned operation/reference is not final settlement. Follow confirmation:

```python
def on_execution(ctx):
    event = ctx.execution
    if event["type"] == "contract.confirmed":
        print("Confirmed", event["key"], event["data"]["result"])
    elif event["type"] == "contract.failed":
        print("Failed", event["data"]["result"])
```

For a computed exchange such as `launch["exchange"]`, list the allowed venues in `script["execution_venues"]`. For example, use `["ascend", "montra"]` for a script that can trade either venue. This applies to `ctx.buy`, `ctx.sell`, `ctx.trade`, and `ctx.order`. Data subscriptions grant read access only.

Reusing the same key and request does not create a second action within that job. A timeout does not prove failure: inspect status and account activity before resubmitting. Use a new key only for a new intended action.

## Stop and verify [#stop-and-verify]

Deployments can use real funds. Review before starting. Closing the page does not stop a job; **Stop** prevents further script execution but does not cancel resting orders, close positions, or reverse broadcast transactions.

[Monitor your job](/scripting-v2/furge/monitoring) and inspect its account after stopping.
