Skip to main content

Overview

A decentralized exchange protocol for seamless token swaps on Paxeer Network with real-time price feeds and WebSocket support.

Swap Fee

0.3%

Supported Tokens

12 Tokens

Real-time Prices

WebSocket

Quick Start

1

API Base URL

https://dex-api.paxeer.app
2

WebSocket URL

wss://dex-api.paxeer.app:3001
3

Test Connection

curl https://dex-api.paxeer.app/api/health

Key Features

Get live price updates via REST API or WebSocket for all supported tokens.
Only 0.3% swap fee (30 basis points) on all token exchanges.
Battle-tested vault and oracle contracts for secure swaps.
Simple REST API, WebSocket support, and clear documentation.

REST API

Endpoints

GET /api/health

Check API health status and service availability.
cURL
curl https://dex-api.paxeer.app/api/health
Response
{
  "status": "ok",
  "timestamp": 1693234567890
}

Rate Limits

  • 100 requests per minute per IP
  • Responses include cache information
  • No authentication required

WebSocket API

Connection

Connect to the WebSocket server for real-time price updates:
const ws = new WebSocket('wss://dex-api.paxeer.app:3001');

ws.onopen = () => {
  console.log('Connected to PaxDex');
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  if (data.type === 'price_update') {
    console.log('Price update:', data.data);
  }
};

ws.onerror = (error) => {
  console.error('WebSocket error:', error);
};

ws.onclose = () => {
  console.log('Disconnected from PaxDex');
};

Message Format

Price update messages follow this format:
{
  "type": "price_update",
  "data": {
    "0x96465d06640aff1a00888d4b9217c9eae708c419": {
      "symbol": "WBTC",
      "price": 45230.50,
      "change24h": 2.45,
      "timestamp": 1693234567890
    }
  }
}

React Hook Example

usePaxDexPrices.ts
import { useState, useEffect } from 'react';

export const usePaxDexPrices = () => {
  const [prices, setPrices] = useState({});
  const [isConnected, setIsConnected] = useState(false);

  useEffect(() => {
    const ws = new WebSocket('wss://dex-api.paxeer.app:3001');
    
    ws.onopen = () => setIsConnected(true);
    
    ws.onmessage = (event) => {
      const message = JSON.parse(event.data);
      if (message.type === 'price_update') {
        setPrices(prev => ({ ...prev, ...message.data }));
      }
    };

    ws.onclose = () => setIsConnected(false);

    return () => ws.close();
  }, []);

  return { prices, isConnected };
};

Smart Contracts

Deployed Contracts

Vault Contract

0x49B0f9a0554da1A7243A9C8ac5B45245A66D90ff
View on Explorer →

Oracle Contract

0x6e5da6d7a89c6B7cB0e5c64fcf326292F76A0352
View on Explorer →

Swap Function

function swapExactTokensForTokens(
  address _tokenIn,
  address _tokenOut,
  uint256 _amountIn,
  uint256 _minAmountOut
) external

Fee Constants

uint256 public constant SWAP_FEE_BPS = 30;      // 0.3%
uint256 public constant BPS_DENOMINATOR = 10000; // 100%
Fee calculation: 30 / 10000 = 0.003 = 0.3%

Implementation Example

import { ethers } from 'ethers';

const VAULT_ADDRESS = '0x49B0f9a0554da1A7243A9C8ac5B45245A66D90ff';
const VAULT_ABI = [/* ... */];

async function swap(tokenInAddress, tokenOutAddress, amountIn, minAmountOut) {
  const signer = await provider.getSigner();
  const vault = new ethers.Contract(VAULT_ADDRESS, VAULT_ABI, signer);

  // 1. Approve token spending
  const tokenIn = new ethers.Contract(tokenInAddress, ERC20_ABI, signer);
  const approveTx = await tokenIn.approve(VAULT_ADDRESS, amountIn);
  await approveTx.wait();

  // 2. Execute swap
  const swapTx = await vault.swapExactTokensForTokens(
    tokenInAddress,
    tokenOutAddress,
    amountIn,
    minAmountOut
  );
  
  const receipt = await swapTx.wait();
  console.log('Swap completed:', receipt.hash);
}

Supported Tokens

All tokens are deployed on Paxeer Network (Chain ID: 229)
TokenNameAddressDecimals
WBTCWrapped Bitcoin0x96465d06640aff1a00888d4b9217c9eae708c4198
wstETHWrapped stETH0xeb2c4ae6fe90f9bf25c94269236cb5408e00e18818
WETHWrapped Ethereum0xd0c1a714c46c364dbdd4e0f7b0b6ba5354460da718
USDTTether USD0x2a401fe7616c4aba69b147b4b725ce48ca7ec6606
USDCUSD Coin0x29e1f94f6b209b57ecdc1fe87448a6d085a78a5a6
Click on any address to view the token contract on PaxeerScan.

Integration Example

Here’s a complete example of integrating PaxDex into your dApp:
import { useWriteContract, useReadContract } from 'wagmi';
import { parseEther } from 'viem';

const VAULT_ADDRESS = '0x49B0f9a0554da1A7243A9C8ac5B45245A66D90ff';

function SwapComponent() {
  const { writeContract } = useWriteContract();

  async function handleSwap(tokenIn, tokenOut, amount, minAmountOut) {
    // First approve
    await writeContract({
      address: tokenIn,
      abi: ERC20_ABI,
      functionName: 'approve',
      args: [VAULT_ADDRESS, amount],
    });

    // Then swap
    await writeContract({
      address: VAULT_ADDRESS,
      abi: VAULT_ABI,
      functionName: 'swapExactTokensForTokens',
      args: [tokenIn, tokenOut, amount, minAmountOut],
    });
  }

  return (
    <button onClick={() => handleSwap(...)}>
      Swap Tokens
    </button>
  );
}

Error Handling

Common errors and their solutions:
Make sure to approve the Vault contract before swapping:
await tokenIn.approve(VAULT_ADDRESS, amountIn);
Increase the minAmountOut parameter or wait for better market conditions.
The pool may not have enough liquidity for your swap. Try a smaller amount.
Your swap would significantly impact the price. Consider splitting into smaller swaps.

Resources