Skip to main content

Overview

The Yativo Crypto swap feature allows you to exchange one token for another across supported chains. Use the sandbox to test the full swap lifecycle — getting quotes, executing swaps, and checking swap status — without spending real funds. Sandbox base URL: https://crypto-sandbox.yativo.com/api/
Swap rates in the sandbox are simulated. They reflect approximate market conditions but are not live market prices. Do not use sandbox swap rates for financial calculations.

Get a Swap Quote

Before executing a swap, request a quote to see the expected output amount, rate, and fees.
GET https://crypto-sandbox.yativo.com/api/swap/quote
from_chain
string
required
The source blockchain. Example: solana, ethereum, polygon.
from_token
string
required
The token to swap from. Example: SOL, ETH, USDC.
to_chain
string
required
The destination blockchain. Can be the same as from_chain for same-chain swaps.
to_token
string
required
The token to receive. Example: USDC, SOL.
amount
number
required
The input amount to swap.
curl -X GET 'https://crypto-sandbox.yativo.com/api/swap/quote?from_chain=solana&from_token=SOL&to_chain=solana&to_token=USDC&amount=1' \
  -H 'Authorization: Bearer YOUR_SANDBOX_TOKEN'
{
  "status": "success",
  "data": {
    "quote_id": "quote_sandbox_01HX9KZMB3F7VNQP8R2WDGT200",
    "from_chain": "solana",
    "from_token": "SOL",
    "from_amount": 1.0,
    "to_chain": "solana",
    "to_token": "USDC",
    "to_amount": 174.82,
    "exchange_rate": 174.82,
    "fee": 0.87,
    "fee_token": "USDC",
    "fee_percentage": 0.5,
    "price_impact": 0.02,
    "quote_valid_until": "2026-03-25T11:03:00Z",
    "estimated_execution_time_seconds": 30,
    "network": "devnet"
  }
}
Quotes expire quickly (typically 60–120 seconds). If the quote expires before you execute, request a new quote.

Execute a Swap

Execute a swap using a previously obtained quote.
POST https://crypto-sandbox.yativo.com/api/swap/execute
quote_id
string
required
The quote ID obtained from the quote endpoint.
from_wallet_id
string
required
The wallet ID to deduct the source tokens from.
to_wallet_id
string
required
The wallet ID to credit the destination tokens to.
slippage_tolerance
number
Maximum acceptable price slippage as a percentage. Default: 1.0 (1%). If actual slippage exceeds this, the swap will fail.
curl -X POST 'https://crypto-sandbox.yativo.com/api/swap/execute' \
  -H 'Authorization: Bearer YOUR_SANDBOX_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "quote_id": "quote_sandbox_01HX9KZMB3F7VNQP8R2WDGT200",
    "from_wallet_id": "wlt_sandbox_01HX9KZMB3F7VNQP8R2WDGT012",
    "to_wallet_id": "wlt_sandbox_01HX9KZMB3F7VNQP8R2WDGT010",
    "slippage_tolerance": 1.0
  }'
{
  "status": "success",
  "data": {
    "swap_id": "swp_sandbox_01HX9KZMB3F7VNQP8R2WDGT300",
    "quote_id": "quote_sandbox_01HX9KZMB3F7VNQP8R2WDGT200",
    "from_chain": "solana",
    "from_token": "SOL",
    "from_amount": 1.0,
    "to_chain": "solana",
    "to_token": "USDC",
    "expected_to_amount": 174.82,
    "status": "processing",
    "tx_hash": "5yMq8rLmKv3xFjNw4aBcYhUeT8sGkZoP2iMnDuWr5CxPQRSTUVWXYZAB",
    "network": "devnet",
    "created_at": "2026-03-25T11:02:00Z"
  }
}

Get Swap Status

Check the status of an executed swap.
GET https://crypto-sandbox.yativo.com/api/swap/{swapId}
swapId
string
required
The swap ID returned when the swap was executed.
curl -X GET 'https://crypto-sandbox.yativo.com/api/swap/swp_sandbox_01HX9KZMB3F7VNQP8R2WDGT300' \
  -H 'Authorization: Bearer YOUR_SANDBOX_TOKEN'
{
  "status": "success",
  "data": {
    "swap_id": "swp_sandbox_01HX9KZMB3F7VNQP8R2WDGT300",
    "from_chain": "solana",
    "from_token": "SOL",
    "from_amount": 1.0,
    "to_chain": "solana",
    "to_token": "USDC",
    "expected_to_amount": 174.82,
    "actual_to_amount": 174.79,
    "actual_exchange_rate": 174.79,
    "fee_charged": 0.87,
    "slippage": 0.017,
    "status": "completed",
    "tx_hash": "5yMq8rLmKv3xFjNw4aBcYhUeT8sGkZoP2iMnDuWr5CxPQRSTUVWXYZAB",
    "network": "devnet",
    "created_at": "2026-03-25T11:02:00Z",
    "completed_at": "2026-03-25T11:02:35Z"
  }
}

List Swap History

Retrieve a list of all swaps for your sandbox account.
GET https://crypto-sandbox.yativo.com/api/swap
limit
integer
Results per page. Default: 20.
offset
integer
Pagination offset. Default: 0.
status
string
Filter by status: pending, processing, completed, failed.
curl -X GET 'https://crypto-sandbox.yativo.com/api/swap?limit=10&status=completed' \
  -H 'Authorization: Bearer YOUR_SANDBOX_TOKEN'
{
  "status": "success",
  "data": {
    "swaps": [
      {
        "swap_id": "swp_sandbox_01HX9KZMB3F7VNQP8R2WDGT300",
        "from_token": "SOL",
        "from_chain": "solana",
        "from_amount": 1.0,
        "to_token": "USDC",
        "to_chain": "solana",
        "actual_to_amount": 174.79,
        "status": "completed",
        "created_at": "2026-03-25T11:02:00Z"
      }
    ],
    "total": 1,
    "limit": 10,
    "offset": 0
  }
}

Swap Status Values

StatusDescription
pendingSwap has been submitted, awaiting processing.
processingSwap is in progress — tokens are being exchanged.
completedSwap completed successfully. Destination tokens credited.
failedSwap failed. Source tokens are returned (minus any gas fees).
refundedSwap was refunded due to failure. Check refund_tx_hash if applicable.

Testing Scenarios

Set slippage_tolerance to 0.0 (no tolerance). In an active testnet environment, this may trigger a slippage exceeded error:
curl -X POST 'https://crypto-sandbox.yativo.com/api/swap/execute' \
  -H 'Authorization: Bearer YOUR_SANDBOX_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "quote_id": "quote_sandbox_01HX9KZMB3F7VNQP8R2WDGT200",
    "from_wallet_id": "wlt_sandbox_01HX9KZMB3F7VNQP8R2WDGT012",
    "to_wallet_id": "wlt_sandbox_01HX9KZMB3F7VNQP8R2WDGT010",
    "slippage_tolerance": 0.0
  }'
Wait for a quote to expire (typically 60–120 seconds after retrieval) before executing, to validate your application handles the QUOTE_EXPIRED error.
Attempt to swap more than your available balance to test the INSUFFICIENT_BALANCE error handling in your application.
After a swap completes, verify the balance update by calling GET /wallets/{walletId} on both the source and destination wallets. The source balance should decrease and the destination balance should increase by the swap amounts.