How Swap works
For example, if you have 1000 USDT in the Injective network and want to exchange it for INJ tokens in the same network, you have a wide choice of different DEXes, each with different conditions. Where is the best place to exchange? Injex will find the best option available on the market. All you need to do is connect your wallet, select the asset you have, specify the amount, and choose the asset you want to receive in return. (Detailed instructions can be found on the "How to swap" page.)
Let’s consider a theoretical but realistic scenario.
How it works now: First Beta Version Operation (v1)
Scenario: 1000 USDT on the Injective network needs to be exchanged for INJ tokens at the best market rate.
An example of an algorithm that Injex would execute to solve this task:
In the current beta version (we continue to improve and optimize it), Injex creates a request to sell 1000 USDT and buy the maximum amount of INJ, sending this request to four exchanges: Helix, Astroport, Dojo, and White Whale. For these two tokens, there are direct LP pairs on all exchanges, so the results will show how many INJ tokens each exchange can offer. For example:
Helix: 35.823 INJ
Dojo: 35.743 INJ
Astroport: 31.407 INJ
White Whale: 31.863 INJ
This happens in seconds, allowing users to get up-to-date exchange rates and ratios promptly. You can find this additional information in the dropdown list on the Swap page. Notably, here Helix offers the best results - 35.823 INJ, which will be displayed as the key rate for exchanging USDT to INJ within Injex.
As a result, 1000 USDT will be routed to Helix, and after signing the transaction with gas fees, excluding slippage, the user will receive 35.823 INJ in his wallet at the best exchange rate at the time. Moreover, it saves time on searching and comparing prices across DEXes.
How it will work with “Smart Auto Routing” (v2)
In the future second version, which is currently in parallel development, we are going to add “Smart Auto Routing”. With its release, the available liquidity on each exchange will be taken into account, allowing for the creation of more complex and multi-level paths to maximize benefits during exchanges.
Let's take the previous example: 1000 USDT to INJ. In the second version of Injex, our aggregator can perform scenarios like:
Distributing 1000 USDT between two exchanges, Helix and Dojo, as they have the best rates at the time (e.g., 0.03585 INJ per 1 USDT on Helix and 0.03586 INJ per 1 USDT on Dojo). However, the favorable rate on Helix is only for up to 300 USDT, while on Dojo, it's for up to 400 USDT. If the USDT amount exceeds these, the average INJ per 1 USDT drops below 0.0358 INJ. Therefore, we can exchange 700 USDT at the best market rate on two exchanges. Then, Injex searches for other advantageous routes. Injex determines that exchanging the remaining 300 USDT on Astroport first into wETH, and then swapping the wETH for INJ on WhiteWhale, will yield 10.749 INJ, giving an average rate of 0.03583 INJ per 1 USDT, which is better than other exchanges at that moment.
Upon signing the swap transaction for 1000 USDT to INJ, excluding slippage, Injex will execute the following distribution:
User -> 1000 USDT to Injex
Injex -> 300 USDT to INJ (to Helix) -> 10.755 INJ
Injex -> 400 USDT to INJ (to Dojo) -> 14.344 INJ
Injex -> 300 USDT to wETH (to Astroport) -> 0.08 wETH to INJ (to WhiteWhale) -> 10.749 INJ
Injex consolidates all the funds received from the exchanges and sends them to the user in a single transaction
Injex -> 35.848 INJ to the User
As a result, in this theoretical scenario, the user will receive 35.848 INJ instead of 35.823 INJ, as described in the first version. This increase is particularly noticeable with larger amounts, as the larger swap position, the more noticeable the slippage and liquidity deficit.
This will take approximately the same amount of time as a swap within one exchange. The low fees within the Injective network do not create expensive costs for parallel transactions, so the resulting benefit from liquidity aggregation across DEXes will exceed the spent gas fees. If the final benefit were less than the gas fee, Injex would consider this and perform the best exchange ensuring the user's benefit ≥ spent gas fee.
Last updated