> ## 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.

# Deposit Funds

Deposit funds from your server wallet to exchange accounts. The server handles transaction signing and broadcasting using MPC-secured wallets.

<Note>
  **Minimum Deposit**: All deposits must meet the minimum amount enforced by `MINIMUM_DEPOSIT_AMOUNT`. Requests below this value return a 400 error.
</Note>

## Endpoints

| Exchange    | Endpoint                                | Description                                        |
| ----------- | --------------------------------------- | -------------------------------------------------- |
| Aster       | `POST /api/trading/aster/deposit`       | Deposits USDT on BNB Chain into the Aster exchange |
| Hyperliquid | `POST /api/trading/hyperliquid/deposit` | Transfers USDC on Arbitrum directly to Hyperliquid |

## Prerequisites

Before depositing, ensure your server wallet has:

1. **Trading tokens** (USDT, USDC) - The asset you want to deposit
2. **Gas tokens** (BNB, ETH) - Native currency for transaction fees

***

## Aster Deposit

Deposits USDT on BNB Chain to the Aster exchange. The server automatically handles token approval and deposit transactions.

### Endpoint

`POST /api/trading/aster/deposit`

### Request Body

```json theme={null}
{
  "walletIdOrAddress": "user_123",
  "tokenSymbol": "USDT",
  "amount": "100",
  "broker": 1000,
  "network": "bnb"
}
```

### Request Parameters

| Field               | Type   | Required | Description                                    |
| ------------------- | ------ | -------- | ---------------------------------------------- |
| `walletIdOrAddress` | string | Yes      | Can be userId, walletId, or wallet address     |
| `tokenSymbol`       | string | Yes      | Token to deposit (e.g., "USDT", "USDC")        |
| `amount`            | string | Yes      | Amount in token units (e.g., "100" = 100 USDT) |
| `broker`            | number | No       | Broker ID (default: 1000)                      |
| `network`           | string | Yes      | Network name ("ethereum", "arbitrum", "bnb")   |

### What Happens

1. **Balance Check** - Verifies server wallet has sufficient tokens and gas
2. **Token Approval** (if needed) - Signs and broadcasts ERC20 approve transaction
3. **Deposit Transaction** - Signs and broadcasts deposit to Aster contract
4. **Confirmation** - Waits for blockchain confirmation

### Example Request

```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"
  }'
```

```javascript theme={null}
await axios.post('https://api.tide.ag/api/trading/aster/deposit', {
  walletIdOrAddress: 'user_123',
  tokenSymbol: 'USDT',
  amount: '100',
  network: 'bnb'
});
```

### Success Response

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

### Status Codes

* `200` – Deposit completed successfully
* `400` – Missing required parameters or amount below minimum
* `500` – Server error during deposit process

***

## Hyperliquid Deposit

Transfers USDC on Arbitrum directly to Hyperliquid. The server handles transaction signing and broadcasting.

### Endpoint

`POST /api/trading/hyperliquid/deposit`

### Request Body

```json theme={null}
{
  "walletIdOrAddress": "0x90EA34C09B612AC68E696BdC7be0ED037a086E72",
  "tokenSymbol": "USDC",
  "amount": "5",
  "networkKey": "arbitrum"
}
```

### Request Parameters

| Field               | Type   | Required | Description                                |
| ------------------- | ------ | -------- | ------------------------------------------ |
| `walletIdOrAddress` | string | Yes      | Can be userId, walletId, or wallet address |
| `tokenSymbol`       | string | Yes      | Token to deposit (e.g., "USDC")            |
| `amount`            | string | Yes      | Amount in token units                      |
| `networkKey`        | string | Yes      | Network key ("arbitrum")                   |

### Example Request

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

### Success Response

```json theme={null}
{
  "success": true,
  "data": {
    "transactionId": "0x...ab4839df29",
    "status": "submitted",
    "timestamp": 1698840000000
  }
}
```

### Status Codes

* `200` – Transfer completed successfully
* `400` – Invalid payload or amount below minimum
* `500` – Broadcast failure

***

## Transfer Between Spot and Perp Accounts (Aster Only)

Move funds internally between Spot and Futures (Perp) wallets within Aster exchange.

### Endpoint

`POST /api/aster/wallet/transfer`

### Request Body

```json theme={null}
{
  "walletId": "29dd4dc0-1ff9-4df6-a19f-936f997cbc5a",
  "amount": "50",
  "asset": "USDT",
  "clientTranId": "transfer_001",
  "kindType": "SPOT_FUTURE"
}
```

### Request Parameters

| Field          | Type   | Required | Description                               |
| -------------- | ------ | -------- | ----------------------------------------- |
| `walletId`     | string | Yes\*    | Wallet ID (UUID)                          |
| `address`      | string | Yes\*    | Wallet address (if walletId not provided) |
| `amount`       | string | Yes      | Amount to transfer                        |
| `asset`        | string | Yes      | Asset symbol (e.g., "USDT")               |
| `clientTranId` | string | Yes      | Unique client transfer ID for idempotency |
| `kindType`     | string | Yes      | Transfer direction                        |

\*Either `walletId` or `address` is required

### Transfer Directions

* `SPOT_FUTURE` - Transfer from Spot → Futures
* `FUTURE_SPOT` - Transfer from Futures → Spot

### Example Request

```bash theme={null}
curl -X POST https://api.tide.ag/api/aster/wallet/transfer \
  -H "Content-Type: application/json" \
  -d '{
    "walletId": "29dd4dc0-1ff9-4df6-a19f-936f997cbc5a",
    "amount": "50",
    "asset": "USDT",
    "clientTranId": "transfer_001",
    "kindType": "SPOT_FUTURE"
  }'
```

### Success Response

```json theme={null}
{
  "success": true,
  "data": {
    "transferId": "transfer_001",
    "amount": "50",
    "asset": "USDT",
    "direction": "SPOT_FUTURE",
    "status": "completed"
  }
}
```

***

## Common Error Responses

### 400 Bad Request - Missing Parameters

```json theme={null}
{
  "error": "Missing required parameters"
}
```

### 400 Bad Request - Below Minimum

```json theme={null}
{
  "error": "Amount below minimum deposit requirement"
}
```

### 400 Unsupported Exchange

```json theme={null}
{
  "success": false,
  "error": "Deposit for exchange 'unknown' is not supported",
  "timestamp": 1700000000000
}
```

### 500 Internal Server Error

```json theme={null}
{
  "success": false,
  "error": "Failed to deposit funds",
  "timestamp": 1700000000000
}
```

***

## Supported Networks & Tokens

| Exchange    | Network         | Token | Decimals | Notes                       |
| ----------- | --------------- | ----- | -------- | --------------------------- |
| Aster       | BNB Chain (BSC) | USDT  | 18       | Automatic approval handling |
| Hyperliquid | Arbitrum        | USDC  | 6        | Direct transfer to exchange |

***

## Important Notes

<Warning>
  **Server-Side Signing**: All transactions are signed server-side using MPC-secured wallets. Never expose wallet credentials to clients.
</Warning>

<Note>
  **Automatic Approval**: The server automatically handles token approvals when needed. You don't need to manage allowances separately.
</Note>

<Tip>
  **Transaction Tracking**: Use the returned `txHash` and `txUrl` to track deposit progress on block explorers.
</Tip>

<Info>
  **Broker ID**: For Aster deposits, the broker ID defaults to 1000 if not specified.
</Info>
