Skip to main content

Human units everywhere

Every SDK method takes and returns human units. 100 means 100 USDC, 10 means 10x leverage, prices are plain decimals (3500.5). The SDK handles all on-chain scaling (1e6 for USDC, 1e10 for prices/leverage). Pass strings for exact decimals (collateral="100.25").

Two time bases

Keys: trader vs API key (delegate)

  • Trader key: your wallet’s own key. Can do everything.
  • API key (delegate): a separate key registered to your wallet with one signature (generate one with the Avantis API Key Generator). Can trade, but can never withdraw funds, approve USDC, add delegates, or act on caller-scoped surfaces (referral, claims, LP vault).
Set AVANTIS_TRADER_ADDRESS when using an API key; leave it unset when using the trader key directly. See Delegates.

Execution routes

The default is the relayer, which is gasless: no ETH, no RPC. execution="direct" signs and broadcasts EIP-1559 transactions through your own rpc_url instead. Full details in Execution modes. One exception: update_tp_sl is intent-only in v2 and always goes through the relayer, even in direct mode.

Pairs

Every method accepts a symbol or a pair index interchangeably: "ETH/USD", "eth-usd", or 1.

Receipts and fills

Write methods return an ExecutionReceipt: wait=True (default) follows the order until it settles or relay_poll_timeout_s elapses. On the batched-market route the receipt IS fill-aware: success means the terminal MarketOrderExecuted event arrived, and a protocol-declined fill raises RelayError. On the other relayer routes the receipt confirms your transaction landed, not that the operator filled the order.
For position-level confirmation, poll client.account.positions() after a short delay, or subscribe to the order event stream.

Errors

Every failure raises a typed exception from avantis_trader_sdk.errors. See Errors.