Part 2 — KyberSwap to use Reserve Routing to Reduce Gas Fees

Sunny Jain
KyberSwap
Published in
4 min readAug 28, 2020

Click to read Part 1 our ‘Combating Gas Fees’ series: What are Gas fees ?

KyberSwap has implemented a new Reserve Routing system to reduce gas fees! Enjoy up to 60% in gas savings!

Why do some Ethereum transactions consume gas in the millions and others much less? For example, transferring ETH from wallet A to wallet B might consume only 21,000 gas, while swapping ETH to MANA consumes ~500,000 gas. The reason is:

The Gas Limit of any Ethereum blockchain transaction is decided by how much computation is needed on the blockchain to facilitate that transaction.

Transactions have different computation needs, hence they have different gas limits. The 3 main types of blockchain transactions on KyberSwap — Swap, Transfer, and Limit Order — have different gas limits because of their varying computational needs. Similarly, swap transactions on different DEXes have different gas limits depending on the algorithms used to swap the tokens and whether the transactions are fully on-chain. Below we have a simple explanation of how gas limit is calculated.

Gas Limit Calculation for a KyberSwap Transaction

KyberSwap transactions are performed fully on-chain on Ethereum. When a user wants to swap KNC to DAI on KyberSwap, KyberSwap forwards this swap transaction to the Kyber Network Proxy Contract.

The Proxy Contract then performs the following 3 main computational steps in order to swap the tokens:

  1. Search for KNC Reserve that offers the best rate for KNC to ETH
  2. Search for DAI Reserve that offers the best rate for ETH to DAI
  3. Swap KNC → DAI via Reserves found in step 1 and 2

Each of the above steps is done fully on-chain and contributes to the total gas limit of a token swap. Assuming:

  1. Step 1 needs 250,000 of gas units (it may vary; depending upon how many reserves supports KNC to ETH conversion)
  2. Step 2 needs 250,000 of gas units (it may vary; depending upon how many reserves support ETH to DAI conversion)
  3. Step 3 needs 500,000 of gas units (it may also vary depending how many reserves are used in the swap operation)

Total gas limit estimation of swap transaction = 1,000,000 gas units.

Introducing Reserve Routing

With Kyber Network’s recent protocol upgrade (Katalyst), KyberSwap is now able to implement Reserve Routing! During a token swap, Kyber Network’s smart contracts can be routed to use specific reserve(s), instead of always searching for the best rates through multiple reserves. As such, KyberSwap can reduce gas consumption by pre-determining the best Reserves to use before the final on-chain transaction.

Using the earlier example, for a token swap from KNC to DAI, KyberSwap can search for the best Reserves (Steps 1 and 2) prior to the on-chain token swap, and route trades only to the selected Kyber Reserve(s). This will reduce the total gas needed for the transaction (e.g. 1M gas limit down to 500K gas limit), making it much cheaper.

KyberSwap is using Reserve Routing to Reduce Gas Fees

During our research on gas tokens and reserve routing, we discovered that the latter is more effective in saving gas. In some cases, reserve routing can save up to 60% in gas costs; if presently you pay $10 for a transaction, by using reserve routing you pay only ~$4.

Reserve routing illustration

Reserve Routing is still challenging as the decision to choose the best Reserve depends upon many factors such as trade size (10 ETH or 30 ETH? etc), number of reserves supporting the tokens involved in the trade, splitting ratio of a trade across multiple reserves, optimal rates etc.

Given the aforementioned challenges, KyberSwap has decided to take a multi-phase approach and will first start Reserve Routing for tokens that are being supported by 1 Reserve. This will immediately pass 10–20% gas savings to users. More than 50 tokens at KyberSwap have only 1 supported Reserve, so this first phase will have an immediate positive impact to majority of the trades at KyberSwap.

As a user of KyberSwap, there is no extra step needed. Just enjoy trading with lower gas fees! Please note that KyberSwap has other initiatives in the pipeline to help users save gas. Reserve Routing is just the first step!

This feature is available immediately on the KyberSwap.com website. Both iOS and Android mobile apps are going through the approval process and will be available in a couple of days.

In Part 3 of our ‘KyberSwap: Combating Gas Fees’ series, we will explore how KyberSwap plans to implement advanced Reserve Routing. Stay tuned!

Read Part 3 — KyberSwap Implements Advanced Reserve Routing.

Other Information

👉🏻KyberSwap Support Helpdesk

👉🏻Why KyberSwap?

👉🏻KyberSwap Official Telegram

👉🏻Get started on Ethereum with KyberSwap

👉🏻Tips for trading on KyberSwap

👉🏻Follow KyberSwap Twitter Announcements

👉🏻Download KyberSwap Android App

👉🏻Download KyberSwap iOS App

👉🏻Website: KyberSwap.com

--

--