For the complete documentation index, see llms.txt. This page is also available as Markdown.

Quick Start

Place your first trade on AFX DEX in 5 minutes.

This guide uses the Testnet environment. All operations are free -- use faucet_claim to get test funds.

Prerequisites

Two Ethereum wallets are required:

Master Wallet

Controls funds and permissions.

Used to sign approveAgent and withdraw.

Agent Wallet

Handles day-to-day trading.

Used to sign placeOrder, replaceOrder, placeBracketOrder, cancelOrder, setLeverage, etc.

Store private keys in environment variables. The Python SDK loads keys from the environment and does not accept private keys in public client constructors.

export AFX_MASTER_PRIVATE_KEY="0xYOUR_MASTER_PRIVATE_KEY"
export AFX_AGENT_PRIVATE_KEY="0xYOUR_AGENT_PRIVATE_KEY"

On mainnet, the minimum deposit is 10 USDC and the minimum withdrawal is 2 USDC. Testnet examples use faucet funds instead of real deposits.

Install Python SDK

The official Python SDK is maintained in afx-dex/afx-python-sdk. Do not download dex_client.py, dex.proto, or dex_pb2.py from these docs.

git clone https://github.com/afx-dex/afx-python-sdk.git
cd afx-python-sdk
python3 -m pip install -e .

The SDK vendors the generated protobuf module under afx.protos, so no manual protobuf compilation is required.

Runnable examples for this flow:

First Trade

1

Initialize the client

2

Claim testnet funds

Get 500 USDC from the testnet faucet. Signed by the Master wallet.

3

Authorize the agent wallet

The Master wallet grants the Agent wallet permission to trade until the authorization expires.

4

Query available symbols

Use the returned code value when placing orders. Do not hardcode product codes or leverage values from examples, because markets and risk parameters can change.

5

Place a limit order

Signed by the Agent wallet. This places a buy order far below market price so it won't fill immediately.

Subscribe to Market Data

Connect to real-time orderbook updates via WebSocket.

What's Next

Last updated