project screenshot 1
project screenshot 2
project screenshot 3

IGL Dex

Introducing a gasless DEX leveraging ERC20 permit functions! 🚀 Sign in with wallet, generate VRS hash & send. Executors rewarded with gas fees, a 0.20% token bonus, plus 0.05% for our protocol.

IGL Dex

Created At

ETHOnline 2023

Project Description

Overview:

Our project introduces a decentralized exchange (DEX) that leverages the ERC20 token's permit function, eliminating the need for users to spend gas when approving tokens for trading. This innovative approach not only reduces the gas fees for users but also simplifies the trading process. Users sign a message off-chain using their private keys, which gives our smart contract the ability to trade on their behalf. Executors, who eventually send these trades to the Ethereum network, are rewarded, making the system beneficial for all parties involved.

Key Features:

Gasless Approvals: By utilizing the permit function available in some ERC20 tokens, users can approve tokens for trading without spending any gas. They simply sign a message, which is then used by our contract to gain the necessary approvals.

Executor Incentives: Any user can become an executor by sending signed trades to the Ethereum network. Executors are compensated by receiving gas fees in the output token and an additional 0.20% bonus of the output token for their services.

Protocol Fee: For sustaining the platform and covering operational costs, a 0.05% fee in the output token is taken from each trade. This fee accrues in the smart contract.

Integration with Uniswap: Our platform seamlessly integrates with Uniswap, a leading DEX, to handle the actual token swaps. This ensures that users get the best rates and the most reliable trading experience.

Transparency and Security: All trades, approvals, and operations are visible on the Ethereum blockchain, ensuring complete transparency. Furthermore, since users sign messages off-chain, their funds are secure, and there's no risk of them being lost or stolen from our platform.

User-friendly Interface: Our front-end interface, built with Next.js, is user-friendly, allowing users to easily connect their wallets, sign messages, and trade. Executors can view pending trades and choose which ones to execute.

How It Works:

  • A user connects their Ethereum wallet to our platform.
  • The user selects the tokens they wish to trade and the amount.
  • Instead of approving tokens (which costs gas), the user signs a message with the details of the trade.
  • This signed message (VRS hash) is stored and is available for executors to pick up and send to the Ethereum network.
  • An executor chooses a trade, sends it to the Ethereum network, and in return, receives gas fees and an additional bonus for their service.
  • The platform takes a small fee from the trade, and the user receives their output tokens.

How it's Made

Technologies Used: Next.js: We chose Next.js for our frontend because of its out-of-the-box capabilities like server-side rendering and static site generation, which provide a seamless user experience. It also has native API routes, which we utilized for handling off-chain operations.

Tailwind CSS: For styling, we used Tailwind CSS. Its utility-first approach allowed for rapid UI development and ensured responsiveness, making the DEX accessible across devices.

Solidity: The core of our platform is built using Solidity smart contracts. These contracts handle on-chain operations like token approvals using the permit function, interacting with Uniswap for token swaps, and distributing fees.

ethers.js: This JavaScript library enabled us to interact with the Ethereum blockchain, making tasks like wallet connection, signing messages, and sending transactions straightforward.

MongoDB: We chose MongoDB for storing off-chain data, like the VRS hashes. Its NoSQL nature allowed for flexibility and scalability.

Uniswap: Integration with Uniswap's smart contracts provided the token swapping functionality. Their liquidity pools ensured users got the best swap rates.

Piecing It Together: Frontend: Users interact with the Next.js frontend. They connect their Ethereum wallet, select tokens, set amounts, and then sign a message. This message is then sent to our Next.js API routes.

Backend: The signed message is stored in MongoDB. Executors can fetch these messages and send them to the Ethereum network.

Smart Contracts: Once a signed message reaches the Ethereum network, our Solidity smart contract takes over. It first approves tokens using the permit function, then interacts with Uniswap to swap tokens, and finally distributes the output tokens and fees accordingly.

Partner Technologies: Uniswap: Being a leader in the DEX space, Uniswap was an obvious choice. Its vast liquidity pools and developer-friendly interfaces greatly benefited our project. Instead of building a swapping mechanism from scratch, we leveraged Uniswap's infrastructure. Notable Hacks: Gasless Approvals: The highlight of our project is the gasless token approval using ERC20's permit function. In a world where gas fees are a significant concern, enabling users to approve tokens without any gas cost was a game-changer.

Executor Incentives: Instead of relying on users to send transactions, we introduced an executor system. Any user can become an executor, send transactions, and earn fees, creating a win-win situation.

Dynamic Fee Calculation: We implemented a dynamic fee calculation mechanism in our smart contract. This ensures that executors are compensated based on the current gas fees and token prices.

background image mobile

Join the mailing list

Get the latest news and updates