The Stablecoin Conversion endpoint enables you to convert between different stablecoins across various blockchain networks. This endpoint handles cross-chain conversions, currency exchanges, and network transfers seamlessly through Devdraft’s unified infrastructure.

Endpoint Details

  • Method: POST
  • URL: /api/v0/transfers/stablecoin-conversion
  • Content-Type: application/json

Authentication

This endpoint requires API key authentication using both:
  • x-client-key: Your application’s client key
  • x-client-secret: Your application’s client secret

Request Body

{
  "sourceWalletId": "550e8400-e29b-41d4-a716-446655440000",
  "destinationWalletId": "660f9500-f30c-52e5-b827-557766551111",
  "sourceNetwork": "ethereum",
  "destinationNetwork": "solana",
  "sourceCurrency": "usdc",
  "destinationCurrency": "usdc",
  "amount": 1000.50
}

Parameters

ParameterTypeRequiredDescription
sourceWalletIdstringYesThe ID of your source wallet
destinationWalletIdstringYesThe ID of your destination wallet
sourceNetworkstringYesSource blockchain network
destinationNetworkstringYesDestination blockchain network
sourceCurrencystringYesSource stablecoin currency
destinationCurrencystringYesDestination stablecoin currency
amountnumberYesAmount to convert

Supported Networks

  • Ethereum (ethereum)
  • Solana (solana)
  • Base (base)
  • Polygon (polygon)
  • Arbitrum (arbitrum)
  • Optimism (optimism)
  • Avalanche C-Chain (avalanche_c_chain)

Supported Stablecoins

  • USDC (usdc) - Available on all networks
  • EURC (eurc) - Available on Ethereum, Solana
  • USDT (usdt) - Available on Ethereum, Polygon, Avalanche

Conversion Types

Convert USDC from Ethereum to USDC on Solana
  • Fastest conversion type
  • Minimal fees
  • No currency exchange rate risk

Response

Success Response (201 Created)

{
  "id": "tc_1234567890abcdef",
  "state": "processing",
  "conversion_type": "cross_chain_conversion",
  "source": {
    "wallet_id": "550e8400-e29b-41d4-a716-446655440000",
    "network": "ethereum",
    "currency": "usdc",
    "amount": "1000.50",
    "address": "0x742d35Cc6Ff82a8C2D8D1Da9da17c7eDfD5bE0a3"
  },
  "destination": {
    "wallet_id": "660f9500-f30c-52e5-b827-557766551111",
    "network": "solana",
    "currency": "usdc",
    "estimated_amount": "998.75",
    "address": "7xKXKRoBrJgCXVb2KhxZZzPHxYMJ4DpHWGQ8RvxS6JEq"
  },
  "exchange_rate": {
    "rate": "1.0000",
    "source_currency": "usdc",
    "destination_currency": "usdc",
    "rate_expires_at": "2024-01-20T10:35:00Z"
  },
  "fees": {
    "network_fee_source": "2.50",
    "network_fee_destination": "0.01",
    "conversion_fee": "0.8",
    "developer_fee": "8.00",
    "total_fees": "11.31"
  },
  "estimated_completion": "2024-01-20T10:33:00Z",
  "transaction_hashes": {
    "source_tx": null,
    "destination_tx": null
  },
  "created_at": "2024-01-20T10:30:00Z",
  "updated_at": "2024-01-20T10:30:00Z"
}

Response Fields

FieldTypeDescription
idstringUnique conversion identifier
statestringConversion state (processing, completed, failed)
conversion_typestringType of conversion being performed
sourceobjectSource wallet and transaction details
destinationobjectDestination wallet and estimated amounts
exchange_rateobjectCurrent exchange rate information
feesobjectBreakdown of all fees
estimated_completionstringEstimated completion timestamp
transaction_hashesobjectBlockchain transaction hashes (when available)

Conversion Process

1. Rate Quote and Validation

When you submit a conversion request:
  • System validates wallet ownership and balances
  • Retrieves current exchange rates (if needed)
  • Calculates all fees and estimated amounts
  • Reserves funds from source wallet

2. Cross-Chain Execution

For cross-chain conversions:
  • Initiates withdrawal from source network
  • Routes through Devdraft’s liquidity pools
  • Executes currency conversion (if needed)
  • Deposits to destination network

3. Completion and Settlement

Once conversion completes:
  • Funds appear in destination wallet
  • Transaction hashes are recorded
  • Conversion receipt is generated
  • State is updated to completed

Conversion States

StateDescriptionNext Action
processingConversion is being executedMonitor for completion
completedConversion successfulCheck destination wallet
failedConversion failedCheck failure reason, retry
refundedFailed conversion, funds returned to sourceFunds back in source wallet

Fee Structure

  • Source network fee: Gas/transaction fee on source blockchain
  • Destination network fee: Gas/transaction fee on destination blockchain
  • Variable by network: Ethereum fees higher than Solana
  • Same currency conversions: 0.1% - 0.3%
  • Cross-currency conversions: 0.3% - 0.8%
  • Based on liquidity: Lower fees for high-liquidity pairs
  • Standard rate: 0.8% of conversion amount
  • Calculated on source amount: Before other fees
  • Transparent pricing: No hidden fees

Exchange Rates

Exchange rates are fetched in real-time from multiple sources:
  • Major cryptocurrency exchanges
  • DeFi liquidity pools
  • Aggregated pricing feeds
  • Updated every 30 seconds

Example Requests

curl -X POST "https://api.devdraft.ai/api/v0/transfers/stablecoin-conversion" \
  -H "Content-Type: application/json" \
  -H "x-client-key: your_client_key_here" \
  -H "x-client-secret: your_client_secret_here" \
  -d '{
    "sourceWalletId": "550e8400-e29b-41d4-a716-446655440000",
    "destinationWalletId": "660f9500-f30c-52e5-b827-557766551111",
    "sourceNetwork": "ethereum",
    "destinationNetwork": "solana",
    "sourceCurrency": "usdc",
    "destinationCurrency": "usdc",
    "amount": 1000.50
  }'

Error Responses

{
  "statusCode": 400,
  "message": "Insufficient balance in source wallet",
  "error": "Bad Request"
}

Advanced Features

  • Convert multiple amounts in a single request
  • Optimize fees across multiple conversions
  • Atomic execution for related conversions
  • Set future execution times
  • Dollar-cost averaging strategies
  • Automated recurring conversions
  • Set target exchange rates
  • Automatic execution when rates hit
  • SMS and email notifications
  • Automatic rebalancing between networks
  • Optimize for lowest fees
  • Smart routing through best liquidity pools

Use Cases

Portfolio Rebalancing

Automatically rebalance stablecoin holdings across networks

Arbitrage Opportunities

Take advantage of price differences between networks

Gas Optimization

Move funds to networks with lower transaction fees

Multi-Currency Treasury

Manage treasury across different stablecoins and networks

Cross-Border Payments

Convert currencies for international transactions

DeFi Strategy Execution

Position funds across networks for DeFi opportunities

Best Practices

1

Monitor Network Conditions

Check gas prices and network congestion before conversions
2

Consider Timing

Execute conversions during low-traffic periods for better rates
3

Use Rate Protection

Lock in favorable rates for time-sensitive conversions
4

Batch When Possible

Combine multiple conversions to reduce overall fees
5

Monitor Completion

Use webhooks to track conversion progress automatically
  • GET /api/v0/wallets - List your Devdraft wallets
  • GET /api/v0/transfers/{id} - Check conversion status
  • GET /api/v0/exchange-rates - Get current exchange rates
  • POST /api/v0/transfers/direct-wallet - Create wallet-to-wallet transfer