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

# Quick Start

> Get up and running with HyperDEX API in 5 steps

# Quick Start Guide

This guide walks you through setting up your account and executing your first trade on HyperDEX. The process differs slightly depending on which exchange you want to use.

<Note>
  **Tide API access** is currently public: you do not need to generate Tide dashboard API keys to call `https://api.tide.ag`. Follow the steps below for wallets and exchange-specific setup.
</Note>

<Warning>
  **For Lighter DEX Users**: You must create an account on [Lighter DEX](https://app.lighter.xyz), deposit funds, and generate API keys directly on their platform before using HyperDEX. See [User Flow Documentation](user-flow.mdx) for details.
</Warning>

<Note>
  **For Avantis Users**: Avantis trades are executed **client-side** on the Base network. The Tide backend provides data endpoints (positions, orders, history, balances), but order execution requires wallet signing through the frontend `useAvantisTrade` hook. No server wallet or API key registration is needed — just a wallet with USDC on Base.
</Note>

## Step 1: Create a Server Wallet

Create a secure MPC-managed wallet for trading operations.

```bash theme={null}
curl -X POST https://api.tide.ag/api/wallets \
  -H "Content-Type: application/json" \
  -d '{"userId": "user_123"}'
```

**Response:**

```json theme={null}
{
  "success": true,
  "userId": "user_123",
  "address": "0x173404aAAa4d6539e2C7dbcC1931Cf41b3A3D5c7",
  "walletId": "29dd4dc0-1ff9-4df6-a19f-936f997cbc5a",
  "publicKey": "04090ce18936a64a24c48624d5734edf..."
}
```

**Save these values** - you'll need them for all subsequent operations:

* `walletId` - For API requests
* `address` - For funding the wallet
* `userId` - Alternative identifier

## Step 2: Register API Keys with Exchanges

### For Aster

```bash theme={null}
curl -X POST https://api.tide.ag/api/trading/aster/apikey \
  -H "Content-Type: application/json" \
  -d '{"walletIdOrAddress": "user_123"}'
```

### For Hyperliquid

```bash theme={null}
curl -X POST https://api.tide.ag/api/trading/hyperliquid/apikey \
  -H "Content-Type: application/json" \
  -d '{"walletIdOrAddress": "user_123"}'
```

### For Lighter

<Note>
  **Lighter is different**: Create your account and generate API keys directly on [Lighter DEX](https://app.lighter.xyz). You'll need:

  * `apiKeyPrivateKey` - Your API key private key
  * `apiKeyIndex` - API key index number
  * `accountIndex` - Your account index
</Note>

## Step 3: Fund Your Server Wallet

Transfer tokens to your server wallet address from your personal wallet:

**For Aster (BSC Network):**

* USDT (for trading)
* BNB (for gas fees)

**For Hyperliquid (Arbitrum Network):**

* USDC (for trading)
* ETH (for gas fees)

**For Avantis (Base Network):**

* USDC (for trading collateral)
* ETH (for gas fees on Base)

```bash theme={null}
# Example: Send to your wallet address
# To: 0x173404aAAa4d6539e2C7dbcC1931Cf41b3A3D5c7
# Amount: 100 USDT + 0.01 BNB (for gas)
```

## Step 4: Deposit to Exchange

### Aster Deposit

```bash theme={null}
curl -X POST https://api.tide.ag/api/trading/aster/deposit \
  -H "Content-Type: application/json" \
  -d '{
    "walletIdOrAddress": "user_123",
    "tokenSymbol": "USDT",
    "amount": "100",
    "network": "bnb"
  }'
```

### Hyperliquid Deposit

```bash theme={null}
curl -X POST https://api.tide.ag/api/trading/hyperliquid/deposit \
  -H "Content-Type: application/json" \
  -d '{
    "walletIdOrAddress": "user_123",
    "tokenSymbol": "USDC",
    "amount": "100",
    "network": "arbitrum"
  }'
```

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "txHash": "0x1234abcd...",
    "txUrl": "https://bscscan.com/tx/0x1234abcd...",
    "amount": "100",
    "token": "USDT"
  }
}
```

## Step 5: Place Your First Order

### Aster Order

```bash theme={null}
curl -X POST https://api.tide.ag/api/trading/aster/orders \
  -H "x-wallet-id: 29dd4dc0-1ff9-4df6-a19f-936f997cbc5a" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "0x173404aAAa4d6539e2C7dbcC1931Cf41b3A3D5c7",
    "symbol": "BTCUSDT",
    "side": "BUY",
    "type": "MARKET",
    "quantity": "0.001"
  }'
```

### Hyperliquid Order

```bash theme={null}
curl -X POST https://api.tide.ag/api/trading/hyperliquid/orders \
  -H "x-wallet-id: 29dd4dc0-1ff9-4df6-a19f-936f997cbc5a" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "user_123",
    "symbol": "BTC-PERP",
    "side": "BUY",
    "type": "MARKET",
    "quantity": "0.001"
  }'
```

### Lighter Order

```bash theme={null}
curl -X POST "https://api.tide.ag/api/trading/lighter/orders?apiKeyPrivateKey=YOUR_KEY&apiKeyIndex=5&accountIndex=316225" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "0x173404aAAa4d6539e2C7dbcC1931Cf41b3A3D5c7",
    "symbol": "USDC",
    "side": "BUY",
    "type": "MARKET",
    "quantity": "10"
  }'
```

### Avantis Order (Client-Side)

Avantis trades are executed on-chain from the frontend. Use the `useAvantisTrade` hook:

```typescript theme={null}
import { useAvantisTrade } from '@/hooks/useAvantisTrade';

const { openPosition } = useAvantisTrade();

await openPosition({
  symbol: "ETH",
  direction: "LONG",
  positionSizeUsd: "100.00",
  leverage: 10,
  openPrice: "3420.50",
  orderType: "MARKET",
  slippagePercent: 0.3
});
// Returns: { txHash, symbol, direction, size, leverage }
```

**Response:**

```json theme={null}
{
  "success": true,
  "orderId": "a1b2c3d4",
  "status": "submitted",
  "timestamp": 1698840000000
}
```

## Next Steps

Now that you've completed your first trade, explore:

* [**User Flow Documentation**](user-flow.mdx) - Detailed flow with diagrams
* [**Account Management**](account/create-wallet.mdx) - Wallet operations
* [**Deposits & Withdrawals**](account/deposit.mdx) - Fund management
* [**Trading Operations**](trading/open-position.mdx) - Advanced order types
* [**WebSocket Streams**](websocket.mdx) - Real-time market data

## Important Security Notes

<Warning>
  **Server-Side Only**: All wallet operations use MPC-secured server wallets. Never expose wallet credentials or API keys in client-side code.
</Warning>

<Note>
  **Lighter API Keys**: For Lighter DEX, obtain API credentials directly from their platform. These are different from your HyperDEX server wallet.
</Note>

<Tip>
  **Test Small First**: Start with small amounts to familiarize yourself with the flow before trading larger positions.
</Tip>

## Common Issues

**Insufficient Balance**

* Ensure your server wallet has both trading tokens and gas tokens
* Check balances before depositing

**Missing Wallet ID Header**

* Include `x-wallet-id` header for Aster and Hyperliquid orders
* Use the `walletId` from Step 1

**Lighter API Errors**

* Verify you created an account on Lighter DEX
* Ensure you deposited funds on Lighter platform
* Check that API credentials are correct

For more help, see the [User Flow Documentation](user-flow.mdx) with complete diagrams and troubleshooting.
