Skip to content

Within this application, you will have the opportunity to perform WETH-USDT swaps across various decentralized exchanges (DEXs) while selecting the most favorable exchange rate available.

Notifications You must be signed in to change notification settings

JMariadlcs/best-rates-swaps-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BEST RATES SWAPS

Welcome to Best Swaps Rates. Within this application, you will have the opportunity to perform WETH-USDT swaps across various decentralized exchanges (DEXs) while selecting the most favorable exchange rate available. Currently deployed in Arbitrum.

Functionalities

The primary functionality of this project involves the exchange of assets from Wrapped Ether (WETH) to Tether (USDT) through various decentralized exchanges, with the objective of obtaining the most favorable exchange rate available among them.

To achieve the desired goal, two methods of swapping assets have been implemented. These two methods are utilized to demonstrate how a similar goal can be attained through two distinct procedures. These methods have been called:

  1. CommonSwaps.
  2. DEXAggregatorSwaps.

CommonSwaps

The common swaps method combines both an on-chain and off-chain structure. The best rate is previously calculated off-chain using the router view functions of each decentralized exchange. Once we have determined the best rate offered by an exchange, the on-chain swap occurs within our Treasury smart contract, selecting the decentralized exchange with the previously calculated best rate. Computing the best rate "off-chain" makes it more challenging for malicious actors, such as MEV bots, to engage in front-running or sandwich attacks.

The implemented Treasury smart contract can be found at the following link: here. This repository encompasses all aspects related to the smart contracts utilized in this project, including the contract itself, deployment scripts, and testing scripts.

This contract works in the following way:

  1. Any user has the option to deposit WETH tokens, and these tokens are pooled together within the contract without individual tracking for each user.
  2. Any user can access the platform and initiate a swap for the entire WETH balance held within the contract. The swap is facilitated through the exchange that provides the most favorable rate, as indicated by our frontend interface.
  3. Any user can withdraw the USDT amount of tokens held in the Treasury.
  4. There is a button available for users to retrieve the WETH and USDT token balances of the Treasury contract at any given moment.

Currently, the implemented exchanges available for swapping are UniSwapV2 and SushiSwapV2. It is worth noting that any other exchange, such as Curve or SushiSwapV3, can be incorporated by following the same procedure.

DEXAggregatorSwaps

The DEXAggregatorSwaps method utilizes Paraswap's API. This method allows any user to initiate a direct swap of their WETH tokens to USDT from their wallet. The DEXAggregatorSwaps method selects the optimal route from SushiSwapV2, UniSwapV2, UniSwapV3, and Curve, facilitating the swap process and returning the USDT amount to the user's wallet.

About

Within this application, you will have the opportunity to perform WETH-USDT swaps across various decentralized exchanges (DEXs) while selecting the most favorable exchange rate available.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published