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

# Execution Modes

> How orders reach the chain: relayer (gasless) vs direct.

Set once via `AVANTIS_EXECUTION` or `AsyncAvantis(execution=...)`. Method calls are identical in both modes.

|                     | `relayer` (default)                                      | `direct`                    |
| ------------------- | -------------------------------------------------------- | --------------------------- |
| Gas                 | Paid by Avantis (gasless)                                | You pay (needs ETH on Base) |
| Requirements        | Signing key only (see note below for trader-key signing) | `rpc_url` + ETH             |
| Transport           | Signed intents / EIP-7702 relays                         | EIP-1559 via your RPC       |
| Works with API keys | Yes                                                      | Yes (delegated actions)     |

<Note>
  Relayer-mode actions that ride your EIP-7702 smart account (limit orders,
  margin, approvals, delegate registration, …) sign an authorization over your
  EOA's account nonce. A delegate/API key is a fresh EOA, so the SDK needs no
  RPC at all; that is the normal setup. Signing with **your wallet key directly**
  requires `rpc_url` / `AVANTIS_RPC_URL` (any Base endpoint, e.g.
  `https://mainnet.base.org`) to read that nonce; the SDK raises a clear
  `ConfigError` if it's missing.
</Note>

## Relayer mode

Sub-routes, chosen automatically per action:

* **Batched market**: market opens/closes and increases submit a signed EIP-712 intent — plus, from the high-level methods, an optional pre-signed EIP-7702 transaction (the server picks which mechanism executes) — to the batched-market service, which executes with a fresh price per attempt and streams the order lifecycle back (accepted → initiated → executed/canceled). Receipt `route` is `batched-market`, with `tracking_id` (lifecycle replay handle) and `order_id` (on-chain id) filled in. A protocol-declined fill (`MarketOrderCanceled`, e.g. slippage) raises `RelayError`. Intent-only submission (no EIP-7702 leg) is the [market-maker fast path](/advanced/mm-fast-path).
* **Price triggers**: full-position TP/SL updates are signed as EIP-712 intents and submitted to the core API price-triggers endpoint, which executes the operator entry point itself. Receipt `route` is `price-triggers`. This same path is used in direct mode (there is no public contract entry point).
* **Passthrough**: limit orders, margin, approvals, claims, LP, and referral are built as transactions and relayed through your EIP-7702 smart account. Receipt `route` is `relayer-passthrough`.
* **TWAP API**: TWAP open/close/cancel are signed intents submitted to the TWAP service, which sends the registration transaction itself. Receipt `route` is `twap-api`.

Every signed intent is digest-verified locally before submission; see [Security](/advanced/security).

## Direct mode

The SDK fetches calldata from the tx-builder API, signs an EIP-1559 transaction, and broadcasts through your `rpc_url`. Receipt `route` is `rpc`, and `tx_hash` is available immediately.

```python theme={null}
client = AsyncAvantis(execution="direct", rpc_url="https://mainnet.base.org")
```

When trading with an API key in direct mode, calls are wrapped as delegated actions on-chain, and the delegate needs ETH for gas.

<Note>
  `update_tp_sl` is the one exception: v2 has no public contract entry point for it, so it always routes through the relayer even in direct mode.
</Note>

## Choosing

* **Relayer** for almost everyone: no ETH, no nonce management, and no RPC when using a delegate/API key.
* **Direct** if you must control broadcasting: your own RPC/builder, custom gas strategy, or no dependency on Avantis infrastructure for submission.

Latency-sensitive? Stay on relayer and use the [market-maker fast path](/advanced/mm-fast-path) to remove HTTP round-trips from order building.
