Skip to main content

Overview

GweAI’s Trading interface provides a professional-grade platform for buying and selling cryptocurrencies with real-time price charts, order placement, and trade history.
All trading occurs on Base Sepolia Testnet with gas fees paid in USDC. The platform uses verified smart contracts for secure transactions.

Accessing the Trading Page

1

Navigate to Markets

Click Markets in the navigation menu
2

Select a Trading Pair

Choose a pair from the list (e.g., BTC/USDC, ETH/USDC)
3

Connect Wallet

Click Connect Wallet to enable trading
4

Start Trading

Place buy or sell orders using the order panel

Trading Interface Components

Market List View

Before entering a specific pair, you’ll see the market overview:

Live Prices

Real-time prices from CoinGecko API

24h Change

Price movement percentage

Volume

Trading volume in USD

Sparkline Charts

Mini price history visualization

Trading Pair Selection

Supported trading pairs:
PairTokenMarket Cap Rank
BTC/USDCBitcoin#1
ETH/USDCEthereum#2
XRP/USDCRipple#3
BNB/USDCBNB Chain#4
SOL/USDCSolana#5
DOGE/USDCDogecoin#6
ADA/USDCCardano#7
TRX/USDCTRON#8
AVAX/USDCAvalanche#9
TON/USDCToncoin#10

Trading Page Layout

Left Panel: Order Placement

Order placement panel
The order panel allows you to:
  1. Toggle Buy/Sell - Switch between buying and selling
  2. Enter Amount - Specify quantity in USDC or token amount
  3. View Estimates - See estimated output before execution
  4. Place Order - Execute the trade

Right Panel: TradingView Chart

Integrated TradingView widget provides:
  • Real-time candles from major exchanges
  • Technical indicators (moving averages, RSI, etc.)
  • Drawing tools for analysis
  • Multiple timeframes (1m, 5m, 1h, 1d, etc.)
// TradingView integration from TradingPage.tsx
widget = new window.TradingView.widget({
  symbol: 'BINANCE:BTCUSDC',  // Auto-switches based on pair
  interval: 'D',
  theme: 'dark',
  style: '1',  // Candlestick
  toolbar_bg: '#000000',
  enable_publishing: false,
  allow_symbol_change: true
});

Bottom Panel: Trade History

Your personal trade history shows:
  • Price at execution
  • Amount traded
  • Total value in USDC
  • Time of transaction
  • Type (Buy/Sell)
  • Transaction Hash with explorer link

Placing Orders

Buy Order Flow

1

Select Buy

Click the Buy button in the order panel
2

Enter USDC Amount

Type the amount of USDC you want to spendExample: 100 (for $100 worth)
3

Review Estimate

The panel shows estimated token amount you’ll receive:
Spending: 100 USDC
Receiving: ~0.0022 BTC
Price: $45,454.55 per BTC
Slippage: 0.5%
4

Confirm Transaction

Click Buy BTC buttonYour wallet will prompt for approval
5

Transaction Processing

Wait for blockchain confirmation (typically 2-5 seconds on Base Sepolia)
6

Success

Trade appears in your historyBalance updates automatically

Sell Order Flow

1

Select Sell

Click the Sell button in the order panel
2

Enter Token Amount

Type the amount of tokens to sellExample: 0.5 (for 0.5 SOL)Or click MAX to sell entire balance
3

Review Estimate

See USDC you’ll receive:
Selling: 0.5 SOL
Receiving: ~69.50 USDC
Price: $139 per SOL
Slippage: 0.5%
4

Confirm & Execute

Click Sell SOL → Approve in wallet
5

Receive USDC

USDC appears in your wallet after confirmation

Order Execution Details

Smart Contract Integration

Trades execute through the verified Router contract:
// From BuyPanel.tsx
const txHash = await executeSwap({
  tokenInAddress: USDC_ADDRESS,
  tokenOutAddress: tokenAddress,
  amountIn: usdcAmount,
  tokenInDecimals: 6,  // USDC decimals
  tokenOutDecimals: tokenDecimals,
  slippageBps: 50  // 0.5% slippage
});

Transaction Steps

For First-Time Trading:The contract requests approval to spend your tokens:
// One-time unlimited approval for better UX
await walletClient.sendTransaction({
  to: tokenAddress,
  data: approveData  // approve(router, maxUint256)
});
Why? ERC-20 tokens require explicit permission for contracts to transfer them.
After Approval:The swap transaction executes:
await walletClient.sendTransaction({
  to: ROUTER_ADDRESS,
  data: swapData  // swap(tokenIn, tokenOut, amountIn, minAmountOut)
});
The router contract handles the exchange logic.
Waiting for Blockchain:
await publicClient.waitForTransactionReceipt({
  hash: txHash,
  confirmations: 2
});
Base Sepolia confirmations are typically under 5 seconds.
Automatic Refresh:
// Refreshes all token balances from wallet
await refreshBalance();

// Fetches updated trade history
refetchTrades();

Price Discovery

Real-Time Price Feeds

Prices come from multiple sources:
// Global price context (PriceContext.tsx)
const { prices, priceChanges } = useGlobalPrices();

// Fetches from CoinGecko API every 30 seconds
const fetchPrices = async () => {
  const response = await fetch(
    'https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,...&vs_currencies=usd&include_24hr_change=true'
  );
};

Slippage Protection

All trades include 0.5% slippage tolerance:
// Minimum output calculation
const expectedOut = parseUnits(quoteResult.amountOut, tokenOutDecimals);
const minAmountOut = (expectedOut * BigInt(10000 - 50)) / BigInt(10000);
// 50 basis points = 0.5%
Price Impact: Large orders may experience price impact beyond slippage. The actual execution price is determined by the AMM pool’s liquidity.

Trade History

Fetching Your Trades

The platform fetches your personal trade history from the blockchain:
// From useRecentTrades.ts
const { trades, loading } = useRecentTrades(
  tokenAddress,
  tokenSymbol,
  tokenDecimals,
  connectedAddress  // Only shows YOUR trades
);

History Display

Trade history table
Each trade shows:
  • Price (USDC): Execution price per token
  • Amount: Quantity of tokens traded
  • Total (USDC): Total transaction value
  • Time: Local timestamp
  • Type: Buy (green) or Sell (red) badge
  • Transaction: Link to Base Sepolia explorer

Pagination

  • 10 trades per page (configurable)
  • Previous/Next navigation
  • Total count display

Advanced Features

Market Sorting

On the Markets page, sort by:
  • Rank (default) - Market cap ranking
  • Price - Highest to lowest
  • 24h Change - Biggest gainers/losers
  • Volume - Most actively traded

Quick Actions

  • Click row → Opens trading page for that pair
  • Trade button → Direct access to buy/sell
  • Chart preview → Sparkline shows recent trend

Wallet Balance Display

The order panel always shows your current balance:
  • For Buy: Available USDC balance
  • For Sell: Available token balance
Balances refresh after each transaction.

Gas and Fees

Transaction Costs

Fee TypeAmountPaid In
Gas Fee~$0.01-0.50USDC
Protocol Fee0.3%Output token
SlippageUp to 0.5%Built into quote

Gas Optimization

// One-time approval reduces gas costs
// First trade: 2 transactions (approve + swap)
// Subsequent trades: 1 transaction (swap only)

Security Features

Verified Contracts

All contract addresses are verified on BaseScan

Whitelisted Tokens

Only approved tokens can be traded

Slippage Protection

Automatic limits prevent front-running

Non-Custodial

You always control your private keys

Contract Validation

// From contracts.ts - Security checks
const validation = await validateTransaction({
  contractAddress: ROUTER_ADDRESS,
  contractType: 'ROUTER',
  userAddress: address
});

if (!validation.valid) {
  throw new Error(validation.error);
}

Troubleshooting

”Insufficient Balance” Error

Cause: You don’t have enough tokens Solution:
  1. Check your balance in the Portfolio page
  2. For buy orders, ensure you have USDC
  3. For sell orders, verify token balance

”Transaction Failed” Error

Cause: Multiple possible reasons Solutions:
  • Gas: Ensure you have USDC for fees
  • Slippage: Price moved too much - try again
  • Approval: First-time trades need approval
  • Network: Check Base Sepolia status

Chart Not Loading

Cause: TradingView script timeout Solution:
  • Refresh the page
  • Check internet connection
  • Try a different browser
Retry Logic: The trading page automatically retries loading TradingView up to 3 times with 2-second delays.

Best Practices

Always review the current price and 24h change before placing orders
Currently market orders only - limit orders coming soon
Large orders may experience slippage beyond the 0.5% tolerance
Save transaction hashes for tax purposes
Start with small trades to understand the interface

Next Steps

Portfolio Tracking

Monitor your trading performance

Token Swaps

Direct token-to-token exchanges

AI Chat

Trade using natural language

DCA Investing

Automate your investments

Build docs developers (and LLMs) love