Inspiration

The inspiration for this project came from DeFi and the AMM model of Uniswap. I wanted to understand it more deeply by implementing my own DEX MVP.

What it does

The product accomplishes two main objectives:

  1. It provides a DEX design allowing users to create any token pair (mock tokens or real deployed tokens) using the factory contract. Users can add liquidity, remove liquidity, obtain (and lose upon removal) liquidity pool tokens (LPTokens), swap one token for another, and receive a new AMM price. This price often deviates from the market price, visualizing arbitrage opportunities.

  2. It enables users to send tokens (e.g., USDC) deployed on the Fuji testnet to the DEX pair contract (e.g., USDC/Link) deployed on the Sepolia testnet. This serves as a foundation for enabling cross-chain swaps in future updates, further enhancing liquidity and price efficiency (the DEX price will adjust to the market price through cross-chain arbitrage).

How I built it

  • I leveraged AI for fast Solidity contract iterations and development.
  • I extensively used Solidity templates from Chainlink's bootcamp.
  • I adopted the proven design framework of Uniswap.
  • Initially, I tried to deploy and test using Python, but faced challenges with outdated Ganache local testing using web3.py, mainly due to OpenZeppelin imports. I then switched back to Remix for deployment and testing.

Challenges I ran into

  • Deployment and testing using Python: I lost a significant amount of time trying to deploy and test my contracts using web3.py and Ganache (local testing), and encountered many bugs due to the fact that most Python frameworks are outdated and not actively maintained.
  • Testing and deployment in Remix were challenging when I did not have enough test tokens.
  • Navigating Solidity smart contract logic was difficult as I did not have a Solidity background before the hackathon.
  • Not being able to join the Chainlink Discord Channel. I always get an error when I want to join.

Accomplishments that we're proud of

  • I understood and implemented Uniswap's core contract design: a factory and a pair contract.
  • I successfully implemented a fully functioning AMM price model for adding, removing liquidity, and swapping tokens. My demo showcases the beauty of the AMM, as it can provide a price that deviates strongly from the market price, attracting arbitrage traders to align the DEX price with the market price.
  • I leveraged CCIP to send the official USDC token from my Fuji address to my USDC/Link pair contract/liquidity pool.
  • I navigated different testing and deployment frameworks, identifying what still works, what could work with more time, and built a project through which I can dive deeper into Solidity, DeFi, and smart contracts.

What we learned

  • Instead of debugging an old framework, it is better to stick to the latest and most actively maintained ones (according to my research, Foundry would be the best choice) to avoid wasting time on debugging outdated frameworks.
  • I practiced using an MVP framework to achieve a minimally functioning DEX as quickly as possible, and then expanded the product with additional functionalities (including CCIP functionalities).
  • I learned about different Chainlink products, mainly price feeds and CCIP cross-chain token transfers.

What's next for DEX MVP with AMM and CCIP

  • Migrate from Remix to VSCode and a Foundry framework.
  • Build a cross-chain swap feature.
  • Develop a Flask and/or FastAPI backend service for the DEX.
  • Create a simple front-end.

Where I use chainlink products in my code (url of the contracts to be looked at that leverage chainlink products):

  1. https://github.com/CedricVo91/blockmagic_chainlink_hackaton24/blob/main/Pair_final_v3.sol

  2. https://github.com/CedricVo91/blockmagic_chainlink_hackaton24/blob/main/factory_final_v3.sol

  3. https://github.com/CedricVo91/blockmagic_chainlink_hackaton24/blob/main/TransferUSDCBasic.sol

Built With

Share this project:

Updates