Cupcake DEX

Links

Github repo | Demo | Recording

Contact details

Discord: 0xFar5eer#6504 / AnotherDev#1180

Telegram @instarogar / @Someone_Nevv

Inspiration

We were passionate to create a DEX that is more cost-effective than existing options like Uniswap v2. On top of that I was fascinated to learn more about how decentralized exchanges work and try building one from scratch.

What it does

The project is a decentralized exchange built from scratch following the Uniswap v2 whitepaper. The DEX is optimized for swapping. Compared to Uniswap v2 swaps which typically cost 110K gas per swap(3-41% gas efficiency). The DEX uses a single main contract address to store all tokens and does not require a router contract. All ERC20 or native tokens must be paired with the CUPEX token in order to be swapped and the DEX offers a simple and convenient interface for that. The DEX code is well-commented and is licensed under the MIT license, allowing for continued development by anyone interested in this project.

Swap page - Preview for swap prices on different token pairs, swaps for DAI, USDC, XDC, CUPEX, displaying wallet balance

Swap page

Staking page - Staking selected CUPEX amount, unstaking, displaying current stake and interest

Staking page

Managing liquidity page - adding, removing liquidity for selected token pools, displaying user's current liquidity in pools

Managing liquidity page

How we built it

⚫React & Tailwind - Frontend dApp UI for DEX that allows for intraction with swaps, DEX liquidity and staking.

⚫Solidity - Smart contracts deployed on testnet & mainnet.

It's important to emphasize that the contract was built completely from scratch following uniswap v2 whitepaper. Code was optimized for swaps. The following results were achieved: ⚫Swapping XDC --> CUPEX, costs 64,018 gas Swapping CUPEX --> XDC, costs 70,803 gas Swapping USDC --> DAI, costs 106,968 gas

Contract inheritance structure

Challenges we ran into

Our initial problem was that ethers seemed to have problem processing responses from smart contract functions. It turned out that the library can't deal with addresses containing prefix xdc instead of 0x. Luckily thanks to help I got at xdc.dev forum I was able to quickly solve the issue by using different RPC.

Accomplishments that we're proud of

We're happy that even though we kept our team size small and had short time frame we were able to produce fully functional, high-quality dApp going beyond basic features that hackathon projects are usually trying to achieve.

What we learned

We have learned a lot about building a decentralized exchange from scratch and optimizing it for swapping, integrating dApp with XDC browser wallet & deployed XDC smart contracts. I have also had the opportunity to optimize the DEX for swapping, which has allowed me to learn about techniques for reducing gas usage and making the DEX more cost-effective for users.

What's next for Cupcake DEX

Since the project is Open-Source we would love to keep on developing it together with community since there is still a room for quite a few improvements. We want to learn more about Globiance Launchpad and how its opportunities can help us develop the product by adding more features and redesigning UI.

Built With

Share this project:

Updates