Skip to main content

Place Trading Orders

Execute trading orders on supported exchanges. Each exchange has its own endpoint with specific requirements.

Supported Exchanges

ExchangeEndpointSymbol FormatNotes
AsterPOST /api/trading/aster/ordersBTCUSDTRequires x-wallet-id header
HyperliquidPOST /api/trading/hyperliquid/ordersBTCRequires x-wallet-id header
LighterPOST /api/trading/lighter/ordersUSDCRequires API credentials as query params
AvantisClient-side executionETH, BTC, SOLOn-chain via wallet signing (Base network)
Lighter DEX Requirement: Before using Lighter, you must:
  1. Create an account on Lighter DEX
  2. Deposit funds on Lighter
  3. Generate API keys from Lighter dashboard
  4. Provide credentials as query parameters

Aster - Place Order

Execute orders on Aster exchange for perpetual futures trading.

Endpoint

POST /api/aster/perp/:walletId/order

Path Parameters

ParameterTypeRequiredDescription
walletIdstringYesWallet ID (UUID)

Request Body

{
  "symbol": "BTCUSDT",
  "side": "BUY",
  "type": "MARKET",
  "quantity": "0.001",
  "positionSide": "BOTH"
}

Request Parameters

FieldTypeRequiredDescription
symbolstringYesTrading pair (e.g., “BTCUSDT”)
sidestringYes”BUY” (open LONG/close SHORT) or “SELL” (open SHORT/close LONG)
typestringYesOrder type: “MARKET”, “LIMIT”, “STOP_MARKET”, “TAKE_PROFIT_MARKET”
quantitystringYesBase asset quantity
pricestringNoRequired for LIMIT orders
positionSidestringNo”BOTH” (one-way mode, default), “LONG”, or “SHORT” (hedge mode)
reduceOnlybooleanNoPrevent increasing exposure
timeInForcestringNo”GTC” (default), “IOC”, or “FOK”

Order Types

  • MARKET - Execute immediately at best price
  • LIMIT - Execute only at specified price
  • STOP_MARKET - Stop loss (market execution)
  • TAKE_PROFIT_MARKET - Take profit (market execution)

Position Sides

  • BOTH - One-way mode (default) - single position per symbol
  • LONG - Long position (hedge mode)
  • SHORT - Short position (hedge mode)

Time in Force

  • GTC - Good Till Cancel (default)
  • IOC - Immediate or Cancel
  • FOK - Fill or Kill

Example Request

curl -X POST https://api.tide.ag/api/aster/perp/ee337309-3e77-4278-b21a-4681468168ba/order \
  -H "Content-Type: application/json" \
  -d '{
    "symbol": "BTCUSDT",
    "side": "BUY",
    "type": "MARKET",
    "quantity": "0.001",
    "positionSide": "BOTH"
  }'

Success Response

{
  "success": true,
  "data": {
    "orderId": 9884649221,
    "symbol": "BTCUSDT",
    "status": "NEW",
    "clientOrderId": "6D52PQwRlg0PcdHz5ttkgN",
    "price": "0",
    "avgPrice": "0.0000",
    "origQty": "0.001",
    "executedQty": "0",
    "cumQty": "0",
    "cumQuote": "0",
    "timeInForce": "GTC",
    "type": "MARKET",
    "reduceOnly": false,
    "closePosition": false,
    "side": "BUY",
    "positionSide": "BOTH",
    "stopPrice": "0",
    "workingType": "CONTRACT_PRICE",
    "priceProtect": false,
    "origType": "MARKET",
    "updateTime": 1764640797006
  }
}

Hyperliquid - Place Order

Execute orders on Hyperliquid exchange for perpetual futures trading.

Endpoint

POST /api/trading/hyperliquid/orders

Headers

HeaderValueRequired
x-wallet-idWallet ID (UUID)Yes
Content-Typeapplication/jsonYes

Request Body

{
  "userId": "a1e82339-29f8-41a6-a468-ce8d268a3261",
  "symbol": "BTC",
  "side": "SELL",
  "type": "MARKET",
  "quantity": "0.01",
  "price": "87131.0",
  "reduceOnly": false
}

Request Parameters

FieldTypeRequiredDescription
userIdstringYesUser’s wallet ID or address
symbolstringYesAsset symbol (e.g., “BTC”, “ETH”, “HYPE”)
sidestringYes”BUY” or “SELL”
typestringYes”MARKET” or “LIMIT”
quantitystringYesBase asset quantity
pricestringYesPrice for the order
reduceOnlybooleanNoPrevent increasing exposure (default: false)
Hyperliquid uses simple asset symbols like BTC, ETH, HYPE. The price field should be provided for both MARKET and LIMIT orders.

Example Request

curl -X POST https://api.tide.ag/api/trading/hyperliquid/orders \
  -H "x-wallet-id: a1e82339-29f8-41a6-a468-ce8d268a3261" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "a1e82339-29f8-41a6-a468-ce8d268a3261",
    "symbol": "BTC",
    "side": "SELL",
    "type": "MARKET",
    "quantity": "0.01",
    "price": "87131.0",
    "reduceOnly": false
  }'

Success Response

{
  "success": true,
  "data": {
    "orderId": "255730787458",
    "status": "FILLED",
    "symbol": "BTC",
    "side": "SELL",
    "type": "MARKET",
    "price": "87131.0",
    "quantity": "0.01",
    "filledQuantity": "0.00157",
    "timestamp": 1764688069312
  },
  "timestamp": 1764688069314
}

Lighter - Place Order

Execute orders on Lighter DEX using API credentials from your Lighter account.

Endpoint

POST /api/trading/lighter/orders

Query Parameters (Required)

These credentials must be obtained from your Lighter DEX account dashboard.
ParameterTypeRequiredDescription
apiKeyPrivateKeystringYesYour Lighter API key private key (hex format)
apiKeyIndexnumberYesAPI key index from Lighter
accountIndexnumberYesYour Lighter account index

Full Example URL

POST /api/trading/lighter/orders?apiKeyPrivateKey=539ef81cacb...&apiKeyIndex=5&accountIndex=316225

Request Body

{
  "userId": "0x07943f0f79097572451601e768c329a2765f2ea2",
  "symbol": "USDC",
  "side": "BUY",
  "type": "MARKET",
  "quantity": "1.1",
  "price": "1",
  "reduceOnly": true
}

Request Parameters

FieldTypeRequiredDescription
userIdstringYesUser’s wallet address
symbolstringYesToken symbol (e.g., “USDC”)
sidestringYes”BUY” or “SELL”
typestringYes”MARKET” or “LIMIT”
quantitystringYesBase asset quantity
pricestringNoRequired for LIMIT orders
reduceOnlybooleanNoPrevent increasing exposure
Lighter uses spot token symbols like “USDC”. Quantity is in base asset units.

Example Request

curl -X POST "https://api.tide.ag/api/trading/lighter/orders?apiKeyPrivateKey=539ef81cacb...&apiKeyIndex=5&accountIndex=316225" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "0x07943f0f79097572451601e768c329a2765f2ea2",
    "symbol": "USDC",
    "side": "BUY",
    "type": "MARKET",
    "quantity": "1.1",
    "price": "1",
    "reduceOnly": true
  }'

Success Response

{
  "success": true,
  "orderId": "948233341",
  "status": "submitted",
  "adapter": "lighter",
  "timestamp": 1698840000000
}

Avantis - Place Order (Client-Side Execution)

Avantis trades are executed client-side via on-chain transactions on the Base network. Unlike other exchanges, orders are not routed through the Tide backend — the frontend signs and submits transactions directly to Avantis smart contracts.
Avantis execution uses client-side wallet signing via the useAvantisTrade React hook. The Tide backend provides data only (positions, orders, history, balances). Trade execution happens on-chain.

Open Position

useAvantisTrade().openPosition({
  symbol: "ETH",                    // Pair from PAIR_INDEX_MAP
  direction: "LONG",                // "LONG" or "SHORT"
  positionSizeUsd: "100.00",        // Collateral in USDC
  leverage: 10,                     // See leverage rules below
  openPrice: "3420.50",             // Required for all order types
  orderType: "MARKET",              // MARKET, LIMIT, STOP_LIMIT, or MARKET_ZERO_FEE
  slippagePercent: 0.3,             // Default: 0.3
  tp: "4000",                       // Take-profit price (optional)
  sl: "3000"                        // Stop-loss price (optional)
})
// Returns: { txHash, symbol, direction, size, leverage }

Request Parameters

FieldTypeRequiredDescription
symbolstringYesAsset symbol (e.g., “ETH”, “BTC”, “SOL”) from the pair index map
directionstringYes"LONG" or "SHORT"
positionSizeUsdstringYesCollateral amount in USDC
leveragenumberYesLeverage multiplier (see limits below)
openPricestringYesPrice for the order (required for all types)
orderTypestringYes"MARKET", "LIMIT", "STOP_LIMIT", or "MARKET_ZERO_FEE"
slippagePercentnumberNoSlippage tolerance (default: 0.3%)
tpstringNoTake-profit price
slstringNoStop-loss price

Order Types

On-chain ValueTypeDescription
0MARKETExecute at current price with slippage tolerance
1STOP_LIMITTrigger at stop price, execute as limit
2LIMITExecute only at specified price or better
3MARKET_ZERO_FEEZero-fee market order (ETH, BTC, SOL only, 75-250x leverage)

Leverage Limits

Order TypePairsMinMax
MARKETAll1x50x (ETH/BTC: 75x)
LIMITAll1x50x (ETH/BTC: 75x)
STOP_LIMITAll1x50x (ETH/BTC: 75x)
MARKET_ZERO_FEEETH, BTC, SOL only75x250x

Precision

ValueDecimals
Price / Leverage / SL / TP / Slippage1e10
USDC amounts6
Min notional (after leverage)$100

Supported Pairs

SymbolIndexSymbolIndexSymbolIndex
ETH0BTC1SOL2
ARB3OP4DOGE5
AVAX6LINK7AAVE8
MKR9NEAR10MATIC11
CRV12UNI13ATOM14
LTC15FIL16TRX17
XRP18BNB19WIF20
PEPE21USDC22STRK23
SUI24SEI25TIA26
INJ27BONK28JUP29
W30ENA31ETHFI32
PYTH33JTO34BLUR35
ZK36BRETT37TURBO38
FLOKI39LQTY40ONDO41
REZ42ETHBTC43SHIB44
XLM45HYPE46APT47
TRUMP48PENDLE49EIGEN50

Contract Addresses (Base Mainnet)

ContractAddress
Trading0x44914408af82bC9983bbb330e3578E1105e11d4e
TradingStorage0x8fE524Ca4AD62aF3E5b3808680e8b5c7822A134E
USDC0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913

Error Responses

400 Bad Request - Missing Parameters

{
  "success": false,
  "error": "Missing required parameters",
  "timestamp": 1698840000000
}

400 Bad Request - Invalid Order Type

{
  "success": false,
  "error": "Invalid order type. Must be MARKET or LIMIT",
  "timestamp": 1698840000000
}

401 Unauthorized - Missing Wallet ID

{
  "success": false,
  "error": "Missing x-wallet-id header",
  "timestamp": 1698840000000
}

403 Forbidden - Invalid API Credentials (Lighter)

{
  "success": false,
  "error": "Invalid API credentials",
  "timestamp": 1698840000000
}

500 Internal Server Error

{
  "success": false,
  "error": "Failed to place order",
  "timestamp": 1698840000000
}

Order Types

Market Orders

Execute immediately at the best available price.
{
  "type": "MARKET",
  "quantity": "0.1"
}

Limit Orders

Execute only at the specified price or better.
{
  "type": "LIMIT",
  "quantity": "0.1",
  "price": "50000"
}

Important Notes

Lighter API Credentials: Never expose your Lighter API credentials in client-side code. Always make requests from your secure backend server.
Wallet ID Header: For Aster and Hyperliquid, you must include the x-wallet-id header with your server wallet ID.
Reduce Only: Set reduceOnly: true to ensure orders only close existing positions and don’t open new ones.
Symbol Formats:
  • Aster: BTCUSDT, ETHUSDT
  • Hyperliquid: BTC, ETH, HYPE (simple asset symbols)
  • Lighter: USDC, USDT
  • Avantis: ETH, BTC, SOL (simple asset symbols, mapped to pair index)