gasless swap

A smart contract for gasless token swaps using Uniswap's Universal Router with Permit2 integration

gasless swap

Created At

ETHOnline 2025

Project Description

This project implements a sophisticated decentralized exchange (DEX) aggregation system that enables gasless token swaps on Ethereum using Uniswap's Universal Router with Permit2 integration. Here's a detailed breakdown:

Core Features:

Gasless token swaps: Users can swap tokens without holding ETH for gas Gas fees are paid in the input token itself Integrates with Uniswap's Universal Router for optimal swap routing Uses Permit2 for secure, gasless token approvals Supports batch transfers with a single permit signature Technical Architecture:

Smart Contract (UniversalSwapper.sol):

Handles the core swap logic Implements reentrancy protection Includes owner-only rescue functions Manages valid sender verification Node.js Backend (node-scripts):

Handles signature generation for Permit2 Manages transaction preparation and execution Calculates gas fees in terms of input tokens Monitors transaction status and balances Security Features:

Implements ReentrancyGuard for protection against reentrancy attacks Uses SafeERC20 for safe token transfers Includes ownership controls for administrative functions Validates addresses and amounts before execution Implements nonce management for signature security Key Components:

Permit2 Integration: Enables gasless approvals and transfers Universal Router: Provides optimal swap routing and execution Batch Processing: Supports multiple transfers in a single transaction Fee Management: Handles gas fees and protocol fees in input tokens Workflow:

User signs a permit for token transfer System calculates gas fees in terms of input token Transaction batches gas fee transfer and swap amount Universal Router executes the optimal swap path Output tokens are sent directly to the user Use Cases:

Users without ETH can still perform token swaps Reduced transaction complexity for end users Protocol fee collection integrated into swaps Flexible routing through Uniswap's infrastructure This project significantly improves the UX of DEX trading by eliminating the need for users to hold ETH for gas fees while maintaining security and efficiency in token swaps

How it's Made

it has been made using foundry and soldeer + node.js/ethers.js for the script part adn also typechain for abi typing. the main language is solidity and the scripts are written in type script. the main contract is a simple contract and the main operations happens on the back end side.

background image mobile

Join the mailing list

Get the latest news and updates