ULDM Performance

Challenging The Leading DEX Aggregators

This study was conducted April 4, 2023

Abstract In this study, we put Unizen Trade's unique liquidity distribution mechanism (ULDM) to the test against leading decentralized exchange (DEX) aggregators 1inch and Paraswap. By simulating 37 random trades across 7 different blockchains, we demonstrate the efficiency and cost-effectiveness of Unizen Trade as compared to its competitors.

Introduction Decentralized exchanges (DEXs) have gained immense popularity in recent years as an alternative to traditional centralized exchanges. With the rising interest in DEXs, the competition among DEX aggregators has also intensified. 1inch, and Paraswap are among the leading DEX aggregators, each offering distinct features and benefits to their users. In this article, we compare the performance of Unizen Trade, powered by its unique liquidity distribution mechanism ("ULDM"), against 1inch and Paraswap through a series of simulated trades.

None of the trades nor networks was hand picked, nor has the data been manipulated in anyway to accommodate biases.

Methodology We conducted a comparison by writing the below script that generated 37 random trades on 7 different blockchains, using an input amount of $10,000. The trades were executed across all platforms, and the results were recorded to evaluate the performance of Unizen Trade, 1inch, and Paraswap.

async function main() {
    const X = parseInt(prompt("Enter number of tokens in dataset to be considered "));

    const rawData = fs.readFileSync('tokenlist.json');
    const jsonData = JSON.parse(rawData);
    const tokenList = jsonData.tokens;

    const randomTokens = getRandomTokens(tokenList, X);

    for (let i = 0; i < randomTokens.length - 1; i++) {
        const tokenIn = randomTokens[i].address;
        const tokenOut = randomTokens[i + 1].address;
        const chainId = 1;

        const tokenInDetails = await getTokenDetails(tokenIn, chainId);
        const amountIn = new BigNumber(10000).dividedBy(tokenInDetails.price).multipliedBy(new BigNumber(10).pow(tokenInDetails.decimals)).toFixed(0);

        const result = await getQuotes(tokenIn, tokenOut, amountIn, chainId);
        console.log(`Swapping 10,000 USD worth of ${tokenList.find(token => token.address === tokenIn).symbol} tokens to ${tokenList.find(token => token.address === tokenOut).symbol} will get you:`);
        console.log(`ZCX: ${result.zcx}`);
        console.log(`Paraswap: ${result.paraswap}`);
        console.log(`1inch: ${result.oneInch}`);
    }
}

function getRandomTokens(tokenList, X) {
    const randomTokens = [];

    for (let i = 0; i < X; i++) {
        const randomIndex = Math.floor(Math.random() * tokenList.length);
        randomTokens.push(tokenList[randomIndex]);
    }

    return randomTokens;
}

async function getTokenDetails(tokenAddress, chainId) {
    const apiUrl = ``;
    const response = await axios.get(apiUrl);
    const data = response.data;

    return {
      decimals: data.decimals,
      price: data.price
    };
}

async function getQuotes(tokenIn, tokenOut, amountIn, chainId) {
  const paraswapUrl = `https://apiv5.paraswap.io/prices`;
  const oneInchUrl = `https://api.1inch.io/v5.0/${chainId}/quote`;
  let chainIdToRPC = new Map();

  chainIdToRPC.set(1, "");
  chainIdToRPC.set(137, "");
  chainIdToRPC.set(56, "");
  chainIdToRPC.set(43114, "");
  chainIdToRPC.set(42161, "");
  chainIdToRPC.set(10, "");
  chainIdToRPC.set(250, "");

  const tradeParams = {
    tokenIn: tokenIn,
    tokenOut: tokenOut,
    slippage: 0.03,
    chainId: chainId,
    inNative: false,
    outNative: false,
    deadline: 1679649641,
    isVIP: true,
    amount: amountIn,
  };
  const dexAggr = new DexAggregatorSDK(chainIdToRPC, undefined);
  // fetching zcx quotes
  let uzParams = dexAggr.getBestQuoteCall(
    tradeParams,
    false,
    undefined,
    undefined,
    false,
    true,
    false,
  );
  
  // fetching paraswap
  const paraswapParams = new URLSearchParams({
    srcToken: tokenIn,
    destToken: tokenOut,
    amount: amountIn,
    side: 'SELL',
    network: chainId,
    srcDecimals: 18,
    destDecimals: 18
  });
  // fetching 1inch
  const oneInchParams = new URLSearchParams({
    fromTokenAddress: tokenIn,
    toTokenAddress: tokenOut,
    amount: amountIn
  });
  const paraswapRequest = fetch(`${paraswapUrl}?${paraswapParams}`).then(response => response.json());
  const oneInchRequest = fetch(`${oneInchUrl}?${oneInchParams}`).then(response => response.json());

  const [uzResult, paraswapResult, oneInchResult] = await Promise.all([
    uzParams,
    paraswapRequest,
    oneInchRequest,
  ]);
  // splitting trade for zcx quotes
  let paramsSplit = await dexAggr.getBestQuoteCall(
    tradeParams,
    false,
    undefined,
    undefined,
    false,
    true,
    true,
    uzResult
  );
  let tot = new BigNumber(0)
  for (let i = 0; i < paramsSplit.length; i++) {
    tot = tot.plus(new BigNumber(paramsSplit[i].actualQuote));
  }
  console.log(uzResult[0].actualQuote, tot.toFixed(0))
  const results = {
    tokenIn: tokenIn,
    tokenOut: tokenOut,
    amountIn: amountIn,
    timestamp: Math.floor(Date.now() / 1000),
    chainId: chainId,
    zcx: BigNumber.max(uzResult[0].actualQuote, tot).toFixed(0),
    paraswap: paraswapResult.priceRoute == undefined ? undefined : paraswapResult.priceRoute.destAmount,
    oneInch: oneInchResult.toTokenAmount,
  };
  return results;
}

Results The results of the trades indicate a clear advantage for Unizen Trade, thanks to its in-house produced ULDM. In many instances, Unizen Trade outperformed its competitors by a significant margin, with better exchange rates and improved efficiency. The table below summarizes the results of the trades across all platforms:

Percentage Difference in Amount Returned

For a clearer and more comprehensive representation of the data, we calculated the percentage differences in the amount returned for each trade. These percentages highlight the extent to which trades executed using Unizen Trade's engine outperformed or underperformed compared to those conducted on 1inch and Paraswap.

The formula used to calculate the difference in percentage can be seen below.

To avoid errors by zero division, one was used instead to represent the output whenever a zero output was returned. These occurrences are notable where the percentages are very excessive.

The instances where Unizen returns higher amounts compared to its competitors are color-coded in green. Cases with minimal differences in the amounts returned are highlighted in orange. For situations where the competition returns significantly larger amounts, the color red is employed to visually represent these instances.

Conclusion

This analysis showcases the efficacy of Unizen Trade's distinctive liquidity distribution mechanism (ULDM) in delivering a superior trading experience when compared to prominent DEX aggregators like 1inch and Paraswap. By optimally distributing trades across a diverse range of decentralized liquidity pools, Unizen Trade can offer more competitive rates and enhanced efficiency, rendering it an attractive option for traders seeking optimal outcomes for their transactions.

Nevertheless, it is important to note that the trades evaluated in this study were randomly generated, and certain DEX aggregators may outperform others for specific trading pairs under different circumstances. Both 1inch and Paraswap are innovative solutions that offer additional benefits and serve thousands of DeFi traders worldwide. This study was conducted as a competitive analysis to provide deeper insights into ULDM's performance in real-world situations.

Last updated