Development of the Backend Solution for Starkdefi DEX
In the rapidly evolving landscape of blockchain and DeFi, Blaize has emerged as a key player, offering cutting-edge solutions in blockchain technology and smart contract development.
This case study focuses on Blaize’s collaboration with StarkDefi, a truly big player in the DeFi space. StarkDefi, known for its innovative approach to decentralized exchanges, operates on the Starknet network, a layer-2 scaling solution that enhances Ethereum’s capabilities.
A CALLThe collaboration aimed to revolutionize StarkDefi’s user experience by implementing a sophisticated backend system that not only tracks user activities but also integrates complex functionalities like swap point calculations and leaderboard management, thereby elevating the platform’s efficiency and user engagement.
StarkDefi’s platform is renowned for its commitment to providing a seamless and secure DeFi experience. The platform offers an array of services including liquidity provision, token swapping, and yield farming, all built on a decentralized infrastructure that prioritizes transparency and user autonomy. StarkDefi’s integration with the Starknet network signifies its dedication to scalability and reduced transaction costs, making it a go-to platform for DeFi enthusiasts.
We have also earlier carried out smart contract security audits for StarkDefi. Read more about the case here.
WHAT WAS THE TASK?
The primary objective was to develop a robust backend system for StarkDefi’s DEX on the Starknet network. The system needed to:
- Monitor user activity within the DEX.
- Compute ‘swap points’ based on criteria like liquidity added, swap activity, and the dollar value of these activities.
- Rank users on a leaderboard according to their swap points.
After the successful completion of the aforementioned milestones, we needed to implement a brand new backend API for seamless integration with StarkDefi’s front end.
PROJECT ARCHITECTURE
The architecture devised for this project was aimed at ensuring scalability, reliability, and real-time processing. It involved setting up servers, databases, and the necessary middleware for effective communication between the Starknet network and the DEX’s front end.
The scheme above shows the database with information about the user’s activity in pairs.
BOOK A CALL WITH BLAIZE TO GET TO KNOW MORE ABOUT OUR ADVANCED DEVELOPMENT SERVICES
THE DEVELOPMENT PROCESS
During the development process, we managed to successfully reach the following milestones:
- Development of a User Activity Tracking Worker: This component was crucial in monitoring and recording all user interactions within the DEX, such as trades and liquidity management. Utilizing smart contract event listeners, this worker provided real-time data crucial for the subsequent calculation of swap points.
- Algorithm for Calculating Swap Points: A sophisticated algorithm was developed to accurately calculate swap points. The algorithm was designed to be efficient and scalable to handle large volumes of transactions.
- Implementation of a Leaderboard System: The leaderboard was developed to dynamically rank users based on their accumulated swap points. It involved designing a user-friendly interface that could update in real time and handle a large number of user data points.
- Establishment of API Endpoints for Frontend Integration: API endpoints were created to facilitate the communication between the backend and StarkDefi’s front end. This involved ensuring secure data transmission, optimizing for low latency, and maintaining data consistency across the platform.
Each milestone was approached with meticulous planning and rigorous testing to ensure compatibility with Starknet’s unique infrastructure and to maintain the highest standards of security and performance. The team’s collaborative efforts and expertise let us meet all the project’s deadlines and requirements.
Blaize’s dedicated team involved in this project included:
- Tech Lead
- Back-end Developers
- DevOps Specialist
CHALLENGES WE CONFRONTED
The Blaize team faced several significant challenges during the development process, which required innovative solutions and a deep understanding of both blockchain technology and the Starknet environment:
1) Starknet’s novel architecture and its unique approach to smart contracts presented a steep learning curve. The team had to become proficient with Starknet-specific tools and methodologies, particularly for event listening within the blockchain. This was essential for accurately tracking user activities and transactions on the DEX.
2) Designing the system architecture required careful consideration of numerous edge cases. For instance, the team had to account for scenarios like the transfer or removal of liquidity and the fluctuating prices of tokens. These factors were critical in ensuring that the swap points were calculated accurately and fairly. The architecture also needed to be scalable and robust enough to handle a large volume of transactions without compromising performance.
RESULT
A key achievement was the development of a sophisticated backend system capable of accurately calculating swap points for all users. This system tracked various user activities, including liquidity provision and swap transactions, ensuring fair and precise point allocation.
Additionally, the team implemented a dynamic leaderboard that ranked users based on their accumulated swap points. This feature not only fostered a competitive environment but also made the platform more engaging and interactive. Designed for scalability and real-time updates, the leaderboard could efficiently handle a large number of users.
Another crucial accomplishment was the development of robust API endpoints, which enabled seamless integration between the new backend systems and StarkDefi’s existing frontend. This integration was vital for a smooth user experience, allowing for instantaneous data updates and transmission.
Moreover, Blaize’s team successfully identified and resolved a significant bottleneck in StarkDefi’s front end. This intervention, which involved an in-depth analysis and optimization of the existing codebase, led to improved website performance, characterized by reduced loading times and enhanced user interface responsiveness.