Perpetuals Engine
Technical documentation for the Bond perpetuals trading system.
Architecture
The Bond perpetuals engine combines off-chain order matching with on-chain settlement. Orders are submitted via a REST API authenticated with session keys, matched by a high-performance engine, and settled on the 0G Network. Margin deposits and withdrawals are fully on-chain.
API Endpoints
Testnet REST
http://perpdex-testnet.0g.ai
Mainnet REST
https://fapi.bond.xyz
Testnet WS API
wss://perpdex-testnet.0g.ai/ws-api/v1
Mainnet WS API
wss://ws-fapi.bond.xyz/ws-fapi/v1
Testnet WS Stream
wss://perpdex-testnet.0g.ai/ws
Mainnet WS Stream
wss://fapi.bond.xyz/ws
Authentication
The trading API uses session-based authentication. A session is created by signing a message with the user's wallet. The resulting session key is used to sign all subsequent API requests using HMAC. Sessions are managed per-subaccount.
Subaccount
bond (default)
Auth Method
HMAC-signed request params
Session Init
Wallet signature → session key pair
Trading API
POST
/fapi/v1/order
Place a new order.
symbol
string
Market symbol (e.g., BTCUSDC)
side
BUY | SELL
Order direction
type
MARKET | LIMIT
Order type
quantity
string
Order size in base asset
price
string?
Required for LIMIT orders
timeInForce
GTC | IOC | FOK | GTX
Time in force (default: GTC)
newClientOrderId
string?
Client-assigned order ID
timestamp
number
Current timestamp in ms
DELETE
/fapi/v1/order
Cancel an existing order.
symbol
string
Market symbol
orderId
string
Order ID to cancel
timestamp
number
Current timestamp in ms
DELETE
/fapi/v1/openOrders
Cancel all open orders for a market.
symbol
string
Market symbol
timestamp
number
Current timestamp in ms
POST
/fapi/v1/leverage
Change leverage for a market.
symbol
string
Market symbol
leverage
number
Target leverage (integer, >= 1)
timestamp
number
Current timestamp in ms
Order Validation Rules
Each market defines validation rules for orders. These are enforced client-side before submission and server-side on receipt.
minQty
Minimum order quantity
maxQty
Maximum order quantity
stepSize
Quantity must be a multiple of this value
minPrice
Minimum limit order price
maxPrice
Maximum limit order price
tickSize
Price must be a multiple of this value
minNotional
Minimum order value (qty * price)
maxLeverage
Maximum allowed leverage for the market
On-Chain Contracts (0G Testnet)
Deposit Contract
0x7db6b56bfEE01916CAf9947414BBbc9d9E6421d7
USDC Token
0xd82C259889c73dE7DeA44672fe4A7C1Ea312B750
BTC Token
0x52aac39b828636Eb38C04BF03FE00aCFb930CCe2
Verifier Proxy
0x12244813A7f84a4e9DF405Cf0e77b977938b5AAf
Clearinghouse
0xB75d33041e714a54EC02eB3cc63aD4F7cdAc7DE0
Clearinghouse Liq
0x1f21dA17eEbFbB1A9dd0a30bbC5aFA04AB16bD56
Endpoint Proxy
0x7db6b56bfEE01916CAf9947414BBbc9d9E6421d7
Offchain Exchange
0x4877bcAAcC85486284A9318990120BcF82611c8c
Spot Engine
0xd638652Af25F154b3F66a5E05B9D1C5029E85563
Perp Engine
0x848bA0D3E981830Eb125F8140e4d869b5D7A2391
Withdraw Pool
0x7B731e80BcCfe4bcFaa65b85997828e915188D99
Market Data
Market data is available via REST (polling) and WebSocket (streaming). The WebSocket stream provides real-time order book updates, trades, klines, mark/index prices, and funding rate changes.
Source Code
On-chain contracts available at github.com/Bond-xyz/perpdex-sc-backend