Inspiration
As traders, we have often run into issues with automated market makers (AMMs) such as frontrunning and high slippage. Although AMMs are powerful tools that leverage DeFi’s capabilities, they lack transparency for end users. This is solved by order books, which are familiar to traditional finance traders and promote a new, transparent DeFi.
On-chain order books exist, but their fees are prohibitively expensive, hence why we chose to build Unlimited on Hedera. Hedera’s Hash graph technology has a uniquely strong use case in financial applications where speed and cost are of the utmost importance, enabling Unlimited to be built to take small maker and taker fees. This lets us beat out our competitors like dYdX and allow our users to keep more money in their wallets.
What it does
Unlimited allows users to trade on a limited order book in a decentralized environment, emulating the centralized exchange experience that users are familiar with while adding the advantages of decentralization.
Unlimited is fully open-sourced, allowing developers to fork the code and build their own decentralized order books. We are committed to improving web3 for all and helping grow the Hedera ecosystem.
How we built it
We built this by first finding similar dApps on other chains and identifying what we thought we could improve. We then wrote the contracts in Solidity, tested the contract, deployed it to the Hedera testnet, and built a front end to let users easily interface with it.
Challenges we ran into
The first challenge we ran into was figuring out how to determine which orders are better than others. Dividing prices and comparing the results isn’t directly applicable as every value in solidity is an integer, making it impossible to use floating point numbers (so that different computer architectures stay consistent when validating the protocol). Therefore we devised a novel ratio that allows for the comparison of orders in a way that the resulting ratio would always be an integer, and based all of our functions on this ratio of the two tokens.
The next challenge we ran into was handling sorting logic on-chain, as there is no gas-efficient way to sort orders using solidity smart contracts. We came to the conclusion that to maximize efficiency, we should allow sorting to be handled off-chain and simply verify the off-chain results in our smart contract. This, however, does not allow for a complete protocol, and thus in the event that the position provided by the off-chain sorting is incorrect, our smart contracts would default back to sorting on-chain.
The biggest challenge we ran into was the development and integration of the front end with our smart contracts. Neither of us had experience with React coming into this hackathon, so we experienced a large learning curve when we were creating a front end that was to be aesthetically pleasing and equally functional. Solidity event handling and updating the UI based on smart contract outcomes was also a new concept that we had to teach ourselves. Also, neither of us was familiar with Hedera or working on the protocol, so we spent a lot of time learning about how to build dApps on Hedera.
Accomplishments that we're proud of
Building a functional matching engine that accurately, efficiently, and fairly carries out orders and linking it to a sleek modern trading frontend.
What we learned
We learned the importance of reentrancy and exploit prevention; especially in the case of financial decentralized applications. All possible edge cases and attack vectors have to be taken into account because if issues arise they can be difficult or impossible to fix and there is no easy way to gain back consumer trust.
We were both inexperienced in Javascript and React, so we were forced to learn to build a functional front end in order to make our product easy for users to interact with.
What's next for Unlimited
We are planning to build expiring markets that are suitable for on-chain options. We are currently working on implementing these options in a way that allows for full collateralization of every position. This fork will be called “Chained” and will be a fully decentralized, oracle-free on-chain options protocol.
Built With
- css
- ethers
- hardhat
- javascript
- react
- solidity
- web3
Log in or sign up for Devpost to join the conversation.