LogoLogo
  • Introduction to Unizen
    • Unizen Overview
      • Unizen Liquidity Distribution Mechanism (ULDM)
        • ULDM Performance
      • Unizen Interoperability Protocol (UIP)
        • LayerZero
        • DeBridge
        • Stargate
        • Celer
        • Axelar
        • Thorchain
    • Unizen Dashboard
      • General
      • Portfolio
      • History
    • Unizen Trade
      • Fees
    • Unizen Explore
      • Unizen Omni-Chain Data Pool
    • Unizen Earn
  • ZCX
    • Token Utility
    • Tokenomics
  • API - Introduction
    • Introduction
    • Before you get started
      • Understanding Price Impact and Price Slippage in Token Swaps
      • Token Allowance Management for Non-updatable Allowance Tokens
      • Tokens with taxes
      • Wrapping and Unwrapping Native Tokens
      • Quote expiration deadline
    • Security Best Practices for Integrating Unizen
      • Why disable CORS
      • How to integrate with a reverse proxy
    • Version 2 of our smart contracts
      • Migration to smart contract v2
  • API - GET STARTED
    • QuickStart guide
    • Swagger
    • Information endpoints
      • GET /trade/v1/info/chains
      • GET /trade/v1/info/sources
      • GET/v1/info/cross-providers
      • GET /trade/v1/info/token/search
      • GET /v1/info/token/popular
      • GET /trade/v1/info/token/{chainId}/{tokenAddress}
      • GET /trade/v1/info/tokenLogo/{chainId}/{tokenAddress}
      • GET /info/thorchain-inbound-address
      • GET /trade/v1/info/tx/{txHash}
      • GET /trade/v1/info/trade/{chainId}/{txHash}
      • GET /trade/v1/info/trades
    • Approval
      • GET /trade/v1/{chainId}/approval/spender
      • GET /trade/v1/{chainId}/approval/transaction
      • GET /trade/v1/{chainId}/approval/allowance
    • Single-Chain Swap
      • GET /trade/v1/{chainId}/quote/single
      • GET /trade/v1/{chainId}/swap/single
      • Send transaction in evm chains
      • Send transaction in Solana
    • Cross-Chain Swap
      • GET /trade/v1/{chainId}/quote/cross
      • GET /trade/v1/{chainId}/swap/cross
      • Send transaction
    • Gasless orders
      • POST /trade/v1/gasless/typed-data
      • POST /v1/gasless/estimate
      • POST /v1/gasless/create
      • POST /v1/gasless/cancel
      • GET /trade/v1/gasless/status/{orderId}
      • GET /v1/gasless/orderByAddress/{address}
    • UTXO Assets and Cosmos Swap
      • GET /trade/v1/{chainId}/quote/cross 1
      • GET /trade/v1/{chainId}/swap/cross
      • Sending transactions
    • Efficient Quote Retrieval with Batch Processing
      • GET /trade/v1/{chainId}/batch_quote/single
    • Error Messages
  • GASLESS TRADES
    • Obtaining gasless quotes
    • Gas estimation
    • Executing the trade
    • Following the orders
  • On-Chain Contracts - Get Started
    • Integration with Unizen Contracts for Token Swapping
    • Registering Errors on Smart Contract Calls
  • PERMIT2
    • What is Permit2?
    • Usage in our api
  • WIDGET - Get Started
    • Embed the Unizen Widget
    • Playground
  • Other
    • Smart Contracts
    • Security Audits
    • Roadmap
  • links
    • Unizen
    • Marketing Website
    • Medium
    • Twitter
    • Discord
    • Telegram
Powered by GitBook
On this page

Was this helpful?

  1. API - Introduction
  2. Before you get started

Tokens with taxes

For tokens subject to taxes, specific adaptations are essential in trading workflows:

  1. Disable Exact Out Feature:

    • Disable the exact out feature for these tokens since they are predominantly traded with the exact in trade type. Trade involving taxed tokens and using Exact Out will result in an error message.

  2. Increase Slippage:

    • Elevate the slippage tolerance to compensate for reduced proceeds when selling taxed tokens.

    • Recommend increasing slippage directly on the UI when dealing with taxed tokens, with adjustments corresponding to the tax rates.

    • Dynamically adjust slippage based on the tax amount provided for each token in the trade to ensure successful transactions despite the tax implications (we provide a recommended slippage on each quote, as we describe at the end of this article)

Tax Information is included in Quotes Endpoint and Information Endpoints:

Tax details for each token involved in a trade are included in the quotes endpoint response. Attributes such as buyTax and sellTax for each tokenFrom and tokenTo are present in the information, facilitating users' understanding of tax implications and aiding informed decision-making.

For instance, when querying the quotes endpoint, the UI should will return tax-related information for each token involved, such as buyTax and sellTax. Additionally, the UI should dynamically adapt the slippage settings based on the tax amount associated with each token, promoting seamless trading experiences despite tax considerations.

"tokenFrom": {
      "name": "ZCX",
      "symbol": "ZCX",
      "decimals": 18,
      "contractAddress": "0xc52c326331e9ce41f04484d3b5e5648158028804",
      "chainId": 1,
      "buyTax": 0,
      "sellTax": 0
    }

You can also find the tax information in the endpoints that return information about tokens (popular tokens, search, token information).

A recommended slippage value is included with each quote

We’ve added a recommendedSlippage field, allowing you to see the suggested slippage for a specific token pair. By default, the recommended slippage is set to 0.5%. However, if token taxes apply, this value may be adjusted to prevent failed trades caused by insufficient amounts.

Setting the Appropriate Slippage Before Requesting a Quote

To ensure a correct slippage value before making a quote request, you can calculate it directly using the token information, rather than waiting for a recommendation from the API. The process involves checking the tax information for both the token you are sending (tokenFrom) and the token you are receiving (tokenTo):

  1. Check Token Taxes:

    • For the tokenFrom, you need to inspect the sellTax.

    • For the tokenTo, look at the buyTax.

  2. Calculate Slippage:

    • If either token has taxes applied, you can calculate a proper slippage based on the sum of the buy and sell taxes. For example:

    const tokenToHasTax = tokenToBuyTax > 0;
    const isNeedOneTimeSlippage = tokenFromHasTax || tokenToHasTax;
    const recommendedSlippage = isNeedOneTimeSlippage 
        ? 0.5 + (tokenFromSellTax + tokenToBuyTax) * 100 
        : defaultSlippage;
    • If taxes are present, the slippage should be set higher to account for these fees, starting with a base value of 0.5% plus the combined taxes from both tokens. If no taxes are applied, the default slippage is used.

By calculating slippage this way, you ensure that your transaction has enough tolerance to account for token taxes and prevent failed swaps. In the example code, the slippage increases by adding the tax percentages to a base of 0.5% when taxes are applied.

PreviousToken Allowance Management for Non-updatable Allowance TokensNextWrapping and Unwrapping Native Tokens

Last updated 6 months ago

Was this helpful?