Overview
The Crocante Swap feature allows you to instantly convert one cryptocurrency to another without leaving the platform. The swap functionality uses theSwapModal component and integrates with the useSwapData and useTokenSwap hooks for real-time conversion rates and execution.
Accessing the Swap Feature
Click Swap
Click the Swap button (identified by the swap icon) to open the swap modal. This button is managed by the
SwapAction component.Performing a Token Swap
Step-by-Step Swap Process
Select Source Token
In the Send field, choose the cryptocurrency you want to convert from. The dropdown shows:
- Token symbol and name
- Token icon
- Your available balance for that token
useSwapData which fetches available balances via useAvailables.Select Destination Token
In the Receive field, select the cryptocurrency you want to receive. Only compatible conversion pairs are shown based on
useConversionPairs data.Enter Amount
Type the amount you want to swap in the Send field. You can:
- Manually enter an amount
- Click MAX to use your full available balance
- Click MIN to use the minimum swap amount (if applicable)
Review Conversion
As you type, the Receive field automatically calculates the amount you’ll receive using real-time conversion rates from
useTokenSwap.The conversion uses the convertTo function:Review Fees
Below the Swap button, you’ll see the transaction fee displayed:The fee is calculated as:
Understanding Conversion Rates
Real-Time Rate Updates
The swap modal uses theuseTokenSwap hook to provide:
- Live Conversion Rates: Fetched from
/api/conversion-pairsendpoint - Bidirectional Conversion: Calculate from source-to-destination or destination-to-source
- Automatic Recalculation: Rates update when you switch tokens or change focus between fields
The conversion rate automatically refreshes at intervals defined by
POLL_AVAILABLES_INTERVAL to ensure you always get current market rates.Conversion Functions
Two conversion functions are available:convertTo(value): Converts from source token to destination tokenconvertFrom(value): Converts from destination token back to source token
Swap Token Direction
Reverse the Swap
You can quickly reverse the swap direction without re-entering amounts:Click Swap Direction Button
Click the circular button with the arrow icon between the Send and Receive fields.
The swap direction button shows different icons:
- Arrow Down: Default state
- Arrow Up-Down: On hover, indicating the swap action
Validation and Requirements
Swap Conditions
The Swap button is only enabled when ALL conditions are met:- Valid Amount: Amount is greater than zero and within your available balance
- Minimum Amount: Meets the minimum swap amount (
minAmount) if specified - Different Tokens: Source and destination tokens are different
- Commission Rate Available: Fee structure is loaded
- Conversion Rate Available: Live rates are fetched successfully
Validation Checks
TheuseValueVerifier hook validates your input:
- Minimum: Cannot be below the minimum swap amount
- Maximum: Cannot exceed your available balance
- Non-Zero: Must enter an amount greater than zero
Swap Fees
Fee Structure
Crocante charges a commission on each swap:- Fee Display: Shown below the Swap button in the destination token
- Fee Calculation:
commissionRate × swap amount - Fee Token: Always charged in the destination (receive) token
The fee percentage varies by token pair. Check the fee display before confirming your swap.
Advanced Features
Dual Input Editing
You can edit either the Send or Receive field:- Edit Send Amount
- Edit Receive Amount
When you edit the Send field:
- Type your desired send amount
- The Receive field automatically calculates what you’ll get
- Fees are deducted from the receive amount
inputReceiveFocused state to determine which calculation to perform.
Quick Amount Selection
MAX Button
Click MAX in the Send field to use your entire available balance for the swap.
MIN Button
Click MIN (when available) to set the minimum required swap amount.
Conversion Pairs
Supported Pairs
The available conversion pairs are determined by:- Backend Configuration:
/api/conversion-pairsendpoint - Dynamic Loading: Pairs update based on platform liquidity
- Token Availability: You can only swap tokens you currently hold
useConversionPairs hook fetches available pairs:
If a destination token is not showing in the dropdown, that conversion pair may not be currently supported or available.
Transaction Processing
Swap Status Indicators
Best Practices
Check Rates
Compare the conversion rate with external markets to ensure competitive pricing.
Review Fees
Always check the fee amount before confirming your swap - it varies by token pair.
Sufficient Balance
Ensure you have enough balance to cover both the swap amount and any fees.
Network Updates
After swapping, allow a moment for your portfolio balances to refresh.
Troubleshooting
Swap Button Disabled
Check these conditions:- Amount is greater than zero
- Amount doesn’t exceed available balance
- Source and destination tokens are different
- Amount meets minimum swap requirement
- Conversion rates have loaded (no loading spinner)
Conversion Pair Not Available
- Try swapping through an intermediate token (e.g., BTC → USDC → ETH)
- Check if the destination token is currently supported
- Contact support if a previously available pair is missing
Incorrect Amounts Displayed
- Wait for conversion rates to load (indicated by loading spinner)
- Refresh the page to reload latest rates
- Check if you’re editing the correct field (Send vs. Receive)
Swap Failed
- Verify you have sufficient balance
- Ensure your session hasn’t expired
- Check network connectivity
- Try again in a few moments
- Contact support if the issue persists
Related Resources
Managing Assets
View your portfolio and monitor balances after swapping
Deposit & Withdrawal
Add more funds to swap or withdraw converted assets
