xSwap
xSwap
xSwap
  • Introduction
    • Overview
    • Terminology
    • Concepts
    • Contracts
  • Tokenomics
    • Token Utilities
    • Fees and Incentives
    • Token Distribution
    • Token Sale
    • veModel
  • Developers
    • Tech Overview Smart Contracts
      • Router
      • Factory
      • Pair
      • Error
    • API
Powered by GitBook
On this page
  • API Endpoints
  • Swap Operations
  • Overview Operations
  1. Developers

API

The xSwap API provides developers with access to crucial functionalities within the xSwap platform, facilitating seamless integration with external applications and services.

API Endpoints

Swap Operations

1. Get Swap Route

GET /swap/route

Calculates the optimal route for swapping tokens.Query Parameters:

  • token0 (Address): Address of the initial token

  • token1 (Address): Address of the target token

  • amount_in (Integer): Amount of input token (must be > 0)

Responses:

  • 200: Successfully returns route information

{
    "path": ["token0_address", "intermediate_token", "token1_address"],    
    "amount_out": "estimated_output_amount"  
}
  • 404: Path not found

2. Get Swap Execution Info

GET /swap/info

Retrieves detailed swap execution information including estimated outputs.Query Parameters:

  • token0 (Address): First token address

  • token1 (Address): Second token address

  • amount_in (Integer): Input amount (must be > 0)

  • to (Address): Recipient address

  • slippage (Float, optional): Slippage percentage (0-1, default: 0.05)

  • deadline (Integer, optional): Transaction deadline

Responces:

  • data: Swap execution calldata as a string.

  • transferAddress: Target address for token transfer.

  • transferValue: Value of the transfer.

  • approvalAddress: Address for approval if needed.

  • estimateTransferSeconds: Estimated time for completion in seconds.

  • estimateAmount: Expected amount from the swap.

  • hopsCount: Number of intermediary hops in the swap.

  • fee: Detailed information on fees.


Overview Operations

3. Get Liquidity Pairs

GET /overview/pairs

Retrieves all token pairs with optional filtering.Query Parameters:

  • filter_by_token (Array, optional): Filter by token address or symbol

  • filter_by_pair (Array, optional): Filter by pair address

  • blacklist (Boolean, optional): Include blacklisted pairs (default: false)

4. Get Available Tokens

GET /overview/tokens

Retrieves all available tokens.Query Parameters:

  • filter_by_token (Array, optional): Filter by token address

  • blacklist (Boolean, optional): Include blacklisted tokens (default: false)

5. Get Token Price

GET /overview/token/price

Get the USD price of a token.Query Parameters:

  • address (Address): Token address


PreviousError

Last updated 4 months ago