Welcome to another episode of our educational series “Wavelength Explained”. Last time, we went over how Stable Pools work and why they are such a must-have for any serious DeFi protocol.
Today, we are taking a deep dive into Wavelength’s Smart Order Router (SOR), an often overlooked, but crucial, component of the DeFi protocols — DEXs in particular. Without it, trading cryptocurrencies in a decentralized manner (through DEXs) would be a much less efficient practice. In fact, having a SOR is imperative to realize our team’s vision for Wavelength. Moreover, SORs are also present on the backends of Traditional Financial markets to optimize trading activity. Of course, DeFi protocols use an adaptation of SOR technology.
Smart Order Router (SOR)
A Smart Order Router is an algorithmic process used in decentralized trading platforms that looks for and assesses available liquidity. The objective of the SOR is to find the optimal path to get a trade executed. It takes advantage of opportunities across all of the Wavelength pools through a set of advanced algorithms.
In DeFi, before the existence of the SOR, the growing number of Liquidity Pools caused liquidity to be fragmented which in turn resulted in assets trading at different prices in different protocols. The Smart Order Router came to tackle this fragmentation issue by analyzing alternative routes to execute swaps and following the one that offers less slippage. Furthermore, the optimal route may sometimes entail “hopping” across multiple Liquidity Pools. In practice, it will break down a user’s trade into smaller ones if such a route is the one that offers the best prices.
If it sounds somewhat confusing, do not worry, we will now compare the SOR with a traditional Automated Market Maker (AMM) would use.
Imagine the following environment.
1) A user wishes to trade $USDC 1,000 for $VLX;
2) There are three liquidity pools containing $VLX, including a pool of $USDC-$VLX;
3) The deepest pool is the $VLX-$USDC one.
4) The AMM uses a traditional router, not a SOR.
As a traditional AMM router should do, the router will pick the deepest Liquidity Pool and execute the trade through it. In this scenario, the trade will be carried out using only the $USDC-$VLX pool, which may not be the actual optimal route.
However, if the AMM in question implements a SOR, it will find the most capital efficient path, break the trade down into smaller ones, utilize all of the pools necessary, and that way access all of the protocol’s liquidity. The result is the one already mentioned above, less slippage/price impact.
Further insight into the inner workings of the SOR
As represented above, the optimization mechanism finds the optimal path in the set of Wavelength pools with the best output after taking gas costs into account.
The SOR will go through the list of all pools with the two tokens a user wishes to trade and then perform an optimization across all pools for the best overall price. This takes into account all slippage and gas costs that the users will incur.
Finally, the swap steps are bundled and sent to the Vault as a batchSwap to be automatically executed.
To get the best price for a trader, the SOR is designed to create an arbitrage-free state between the paths it uses. What this means is that each hop the SOR takes needs to provide the same spot price after the swap has been completed.
Implementing the SOR on Wavelength
From the get-go, it was very clear for the team that Wavelength had to implement a SOR.
Looking further down the line, as the variety of Wavelength Pools increases, the SOR becomes more powerful since it has more and more pools at its disposal. In fact, it will ensure that any trade can be executed no matter how exotic the trading pair is. Also, any custom pool on Wavelength will be able to use the SOR.
In this post, we explored the Smart Order Router and the advantages it brings to Wavelength and its users. We hope this article has expanded your DeFi knowledge and got you excited to both use Wavelength and read our upcoming educational pieces! As always, do not forget to regularly check all our social channels in order to stay up to date on all things Wavelength and Velas.
This article and any information contained in it are subject to Legal Notice. Please carefully review the Legal Notice as it contains important legal information, limitations, and restrictions relating to the information that we provide, third-party resources, and forward-looking statements.”