Idea and algorithms behind CrowdSwap Best-Price-Routing (BPR) – It´s all about Transparency

formulars-best-price-routing

Solving existing Crypto challenges like

  • High transaction fees
  • Complexity
  • User-friendliness
  • Transparency

is essential for the future and acceptance of DeFi. CrowdSwap is confident that these can be improved or solved with CrowdSwap technologies.

Best-Price-Routing – why? And what does it mean?

 

The Search App searches for the best price for a specific token pair in the complete DeFi Space. The search takes place cross-chain and is only limited by the integration of the different DEXes. The best-price algorithm finds the best price for the token pair and considers all collateral costs. These costs are:

  • Fees of the DEXes 
  • Transaction costs of the execution of the smart contracts (swap)
  • Prices of the bridge transfer (network transfer).

 The best price per token, including all collateral costs, is created and presented to the user in ascending order. The determination of the price bases on the following formula:

𝑃𝑃(𝑎𝑎𝑎𝑎𝑎𝑎)𝑡𝑡 =   M(p + F) + C / M

The total cost price of a DEX is calculated from the number of tokens M multiplied by the token price p, added by the fees F of the DEX. The total is added by the cost C of the transactions for executing the smart contracts. Price per token is the result divided by the number of M.

The number of tokens M is determined from the exchange volume underlying the search. By default, this is set to $500 but can be changed in the settings. The number of tokens is equal to the quotient of exchange volume V and price added with fees.

𝑀 =  V / p + F

Where f is the product of price and fees as a percentage.

𝐹 = 𝑝 𝑓%

The Best-Price-Routing search result display presents the user with a clear ranking reduced to price and shows the number of tokens the user will receive after an exchange to the exchange volume. Furthermore, the user can view price details for each total price to understand the pricing.

Many DEXes use different functions of their smart contracts to execute the same TokenSwaps. Here, the internal routing is not always the same, resulting in higher transaction costs for the user. CrowdSwap analyzes the smart contracts of the connected DEXes and always executes the swap via the most lucrative and shortest path. 

In addition to the price, the user also sees the percentage of ancillary costs in the swap volume. The overall price per token (including all ancillary costs) allows the user to quickly decide which DEX is the most efficient for the desired swap.

CrowdSwap determines the transaction costs by an empirical analysis of the on-chain data. Here, the mean values of all functions’ gas consumption are determined and multiplied by the calculation’s current gas costs.

G = current gas cost

It´s all about Transparency

 

Most DEXes focus on swapping from token A to token B based on their liquidity pools. CrowdSwap Best-Price-Routing (BPR) emphasizes transparency of the best route for the swap, the fee structure, and the swap side costs. 

The best route for the swap is not always the one that the DEXes suggest as the best price. Many transactions of arbitrage traders show that there are more optimal routes in certain market phases, which have the most significant advantages for the user. 

CrowdSwap transparently displays all routes of the compared DEXes. The best price algorithm ensures that the best route of each DEX is found. The goal is always the best price, including all additional costs. No other criteria, such as pool ratio, pool health, volume or TVL, play a role. Our focus is exclusively on the price advantage of our users.

Why and how did we get there?

 

The fee structure is not always easy to understand. While the DEXes display the fees, they are usually shown in token form rather than US dollars. These numbers bring confusion as to the magnitude of the costs. For swaps over multiple LPs, the fees of 0.3%, for example, accrue numerous times. I.e., for a value of 1000$ over two LPs there is not 3$ but 6$. It also happens that different pools charge different fees. In the new V3 of Uniswap the prices go from 0.05% – 1%, depending on the pool. CrowdSwap always displays the fees of the swap in US dollars to be compared to each other.

The swap charges are not displayed on most DEXes because they are a network problem and not of the DEXes themselves. We agree with this only to the extent that it makes no difference on a DEX. However, if the user can choose, he would probably use the exchange platform with the lowest incidental costs. 

Concerning the ancillary costs, we will only assume the transaction costs here. Considerable differences can arise due to different smart contracts. Furthermore, the tokens involved also influence the gas costs and thus on the transaction costs. Optimizing smart contracts can therefore lead to significant savings. Providers are working on this with varying degrees of success.

However, it is not always the case that the DEX with the higher ancillary costs also always have a worse price after CrowdSwap representation. Sometimes the pure swap prices are so reasonable that even higher ancillary costs still achieve the best overall price. So we take all costs into account to make sure the user is paying the best price per token.

With the Best-Price-Routing Search App CrowdSwap shows maximum transparency when comparing the best routes of different DEXes. The prices of the DEXes have been created based on the best routes from a provider perspective. On-Chain data analysis provides the exact ancillary transaction costs based on historical gas costs for the swaps across the routes shown. If CrowdSwap finds a better route, it offers an additional entry in the search results.