Ready Swap

Last modified Sep 22, 2022
Ready Swap
 

The Ready Swap aggregates decentralized exchanges’ (DEXs’) swap features and other DeFi services in one comprehensive interface to facilitate and streamline user interactions with decentralized finance on Ethereum and EVM-compatible chains including Polygon, Avalanche, Binance BNB Smart Chain (BSC), and more to come.

Ready Swap Highlights

  • A smart algorithm to find the best trading route with the most favorable exchange price for every swap request.
  • More convenience by automatically computing and combining different DEX swaps to fulfill each request. Users only need to enter their desired parameters in Ready and then Ready Swap will do the rest.
  • Lower swap fee. Users have to pay only the fees of DEX swaps, which are already optimized.
  • Better and more flexible slippage tolerance. The algorithm designs swap routes with the smallest slippage possible. Users can also adjust the slippage tolerance as they prefer.
 
Notion image

How Swaps Work

Incorporating one or some DEXs is a popular choice to exchange one cryptocurrency for another. These DEX swaps have their own smart contracts implementing automatic token transfer based on the Automated Market Maker (AMM) model. With AMM, sellers and buyers do not have to directly interact with each other. All trades are performed using mathematical formulas; such a mechanism eliminates human errors while greatly increasing speed and efficiency.

Each DEX swap has its own pools of tokens. For a specific DEX swap, a token X can be converted into a token Y only if that DEX has a corresponding pool X-Y, and there is a sufficient balance of token Y for the swap.

The received volume of the target token depends on two factors:

  • AMM model applied
  • Pool liquidity

For a particular pair of tokens X-Y, different DEXs can have different pools, each with its own liquidity. For that reason, the same swap request may get a better price in one DEX than in another.

In addition, between the time that a user sees the price in a pool and when the swap is actually executed there, other people may also swap, causing the pool liquidity and the swap rate to constantly change. This phenomenon is called slip, and the difference between the desired price and the effective price is called slippage. The smaller the slippage is, the closer to the user’s expectation a swap output will be.

Not only is each swap susceptible to pool movements but it can also exert its effects on the corresponding pool(s). Upon being completed, it changes the pool liquidity to a certain extent so the price of tokens involved is also affected: simply put, when the volume of a request is large and/or the pool is small, the impact of the swap will be significant. Such an influence is called price impact and should also be minimized to avoid unfavorable rates for users.

Users usually try to find DEX swap routes that offer the best swap rate, slippage tolerance, and price impact; however, manual calculations and arrangements to achieve this are highly complicated due to the substantial number of pools in each network and the swift movements of crypto markets.

 

Ready Swap Features

Routers are created to bring higher efficiency to swaps. Routers find one best pool for each request; better still, they can also carry out swaps in a more sophisticated manner: they split the target swap into multiple smaller ones, each to be performed on a different DEX to optimize the output.

Routers usually consist of core logic and a smart contract, the former for finding optimal swap routes and the latter for sending calls to DEXs then returning results to user wallets.

Ready Swap is designed and implemented as a router, with the aforementioned structure and functionality to help Ready users trade with more ease and greater outcome.

 

Optimal Trading Fees

One of the Ready Swap goals is to minimize the trading fee for users, even in a complex swap order, with the smart routing protocol. Currently, for each swap, users have to pay involved DEXs only (each DEX defines its own fee rate, normally around 0.3%). If users use Ready liquidity pools (particularly in swaps including the Ready token RYT), a fee of 0.3% will be applied to every successful swap.

 

Customizable Slippage Tolerance

Upon making a request on the Ready Swap, users can also specify their slippage tolerance, which is the margin of price change (between order and execution) they find acceptable. Slippage tolerance can be set anywhere between 0.1% and 20%; when not specifically defined, the default value is 0.5%.

If the execution price is within the slippage range, the transaction will be executed. If the execution price is outside the range, the swap will not occur and the user will be notified that the slippage tolerance needs to be adjusted to make the transaction possible.

 

Better Price Impact

Slippage occurs due to both others’ actions and the swap itself. The final difference between the price Ready Swap offers and the price of execution is expressed in percentage under the title “Price Impact” at the bottom of the swap module. If the final price impact is larger than the specified slippage, the transaction will fail.

 

Ready Swap Components

Core Logic

The core idea behind swap routing is based on the fact that each DEX supports different liquidity pools of tokens, and that for one token pair X-Y, there may be pools on more than one DEX.

To perform a swap from token X to token Y, we can break it down into multiple sub-swaps such as X→A→B→Y, where each sub-swap can be carried out on a different DEX.

Each pool normally has 2 tokens, which can be considered 2 nodes. Exchanges between the 2 tokens can happen in either direction (X→Y or Y→X). The pool collection of DEXs can be presented as a weighted graph, with the weight of each path depending on the exchange rate.

The problem of optimizing a swap becomes the problem of finding the shortest path from token X to token Y that can produce the highest output.

For each swap request, a graph is built based on the instant liquidity of pools. The routing algorithms (BFS as the default) are used to design the most favorable path. Afterward, based on the result, encoded data is generated and sent to the corresponding smart contracts of the involved pools for swap execution.

In addition, graphs for DEXs are also created for users’ reference. These graphs help compare swap rates on different DEXs.

 

Smart Contract

The smart contract is built according to the standard of the most renowned swap routers. It consists of the following basic functions.

  • Read functions:
    • feeRate: get the fee rate for this swap route.
    • getAmountsOut: get the final output volume at the current time of the swap, given a path.
    • getAmountsOutLP: get the final output volume at the current time of the swap, given a path and output token pair.
    • isMember: check if a DEX is supported by the router.
    • paused: check if the router is available.
    • referrerFeeRate: get the fee rate for the referrer, if the referrer is specified.
  • Write functions:
    • swapExactTokensForTokens: swap one token for another token.
    • swapExactTokensForETH: swap one token for the native token.
    • swapExactETHForTokens: swap the native token for another token.
    • swap: perform a swap, which may comprise one or more sub-swaps.

Ready Swap Smart Contract Addresses

The Ready Swap smart contracts are deployed on different networks to support a wide range of swap needs. Currently, there is one for Polygon; more smart contracts on other networks and their addresses will be added to the list.

Network
Ready Smart Contract Address
Polygon