Skip to main content
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.
ScenarioswapDirectEnabledswapRouteEnabled
Direct deposit onlytruefalse
Swap deposit onlyfalsetrue
Both modes availabletruetrue

Using swap mode

Set mode to swap in your deposit request and provide the input token the user wants to deposit with.
curl -X POST "https://earn.turtle.xyz/v1/actions/deposit/{opportunityId}" \
  -H "X-API-Key: sk_live_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "walletAddress": "0xUserWalletAddress",
    "depositAmount": "1000000",
    "depositToken": "0xInputTokenAddress",
    "chainId": "1",
    "distributor_id": "your-distributor-id",
    "mode": "swap",
    "slippageBps": 50
  }'

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%)
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.