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

# Swap Mode

> How to deposit tokens that are not the vault native deposit token.

Swap mode lets users deposit any supported input token into a vault even if it is not the vault's native deposit token. The API routes the swap through a DEX automatically before depositing.

## Detecting availability

Check `swapDirectEnabled` and `swapRouteEnabled` on the opportunity object to determine which modes are available.

| Scenario             | `swapDirectEnabled` | `swapRouteEnabled` |
| -------------------- | ------------------- | ------------------ |
| Direct deposit only  | `true`              | `false`            |
| Swap deposit only    | `false`             | `true`             |
| Both modes available | `true`              | `true`             |

## Using swap mode

Set `mode` to `swap` in your deposit request and provide the input token the user wants to deposit with.

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST "https://earn.turtle.xyz/v1/actions/deposit/{opportunityId}" \
    -H "X-API-Key: sk_live_xxxxx" \
    -H "Content-Type: application/json" \
    -d '{
      "userAddress": "0xYourWalletAddress",
      "tokenIn": "0xInputTokenAddress",
      "amount": "1000000",
      "distributorId": "your-distributor-id",
      "mode": "swap",
      "slippageBps": 100
    }'
  ```

  ```typescript TypeScript theme={null}
  const opportunityId = '550e8400-e29b-41d4-a716-446655440000';
  const response = await fetch(
    `https://earn.turtle.xyz/v1/actions/deposit/${opportunityId}`,
    {
      method: 'POST',
      headers: { 'X-API-Key': 'sk_live_xxxxx', 'Content-Type': 'application/json' },
      body: JSON.stringify({
        userAddress: '0xYourWalletAddress',
        tokenIn: '0xInputTokenAddress',
        amount: '1000000',
        distributorId: 'your-distributor-id',
        mode: 'swap',
        slippageBps: 100,
      }),
    }
  );
  const action = await response.json();
  ```
</CodeGroup>

## slippageBps

The `slippageBps` parameter controls the maximum acceptable slippage for the swap in basis points.

* **Default:** `50` (0.5%)
* **Recommended range:** `50` to `200` (0.5% to 2%)
* Increase for volatile pairs or low liquidity routes
* Maximum recommended is `200` (2%)

<Note>
  The `GET /v1/route` endpoint is deprecated and has been removed. Swap routing is handled automatically when `mode=swap` is set on the deposit request.
</Note>
