project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4

CryptoBASO

Splits swaps across multiple transactions to prevent front running

CryptoBASO

Created At

ETHGlobal San Francisco

Winner of

SKALE Network - Best Use of Zero Gas Fees 3rd place

Project Description

Our project involves splitting up swap orders on DEX’s across multiple transactions by taking advantage of SKALE’s zero gas fees. This is so we can minimize losses occurred from frontrunning. On other blockchains, trying to split up transactions results in more and more gas fees. If you want to make a trade of $50 across multiple transactions, it is not easily doable. It doesn’t make sense to do 5 $10 trades if gas fees are $5. The SKALE network’s zero gas features improves the ability to spread out buy and sell orders across multiple transactions because gas costs are no longer a problematic factor. Our project can be slightly altered to work with any DEX on the network (given the DEX has good documentation). We used a simple “fake DEX” for demonstration purposes. We hope that, as the SKALE network’s DeFi ecosystem increases, we could help facilitate that growth with our own project and differentiate the SKALE ecosystem by using SKALE’s zero gas features with our unique way of minimizing MEV.

How it's Made

The frontend, built with Next.js and styled using Tailwind CSS, serves as the user interface where traders place limit orders, connect wallets, and monitor trades. Ethers.js bridges the frontend with the SKALE blockchain, enabling direct user interaction with the smart contracts. TypeScript enhances code reliability across the application. The smart contracts, written in Solidity, manage the core functionalities on the SKALE network.

For the purpose of this project, we have created our own DEX to simulate trading conditions. It manages trading operations such as token swaps, liquidity management, and order execution, with functions for adding/removing liquidity and handling token swaps. Here, the user mentions the limit orders.

The orderbook.sol contract manages the lifecycle of limit orders, providing functionalities to place, modify, and cancel orders. It maintains a record of active orders and interacts with the DEX contract to execute trades when market conditions match the user’s specified price.

The PriceChecker.sol contract is responsible for validating real-time prices before executing a trade. It interacts with the DEX to fetch current market prices and ensures that each fragmented order meets the user’s criteria for execution.

We have a backend “server” that utilizes ethers.js and the hardhat framework to conduct constant price checks and executions for every order. We utilized hardhat’s local node for testing as well as SKALE’s Europa DeFi testnet.

The "hacky" part involved creating the dex.sol contract to simulate a realistic DEX environment for testing. There were no testnet DEX’s, and other DEX’s we tried to use had poor documentation on deployment. Our DEX handles fragmented trade execution, breaking large orders into smaller swaps to prevent frontrunning, leveraging SKALE's zero gas fees for efficient, iterative execution without incurring extra costs.

background image mobile

Join the mailing list

Get the latest news and updates