DeFi has some awesome protocols to generate yield if you’re long on your crypto asset. Most yield generators automatically manage funds and maximize the yield. While yield generating protocols make it convenient and cheap for DeFi users to maximize Yield, they don’t maximize the total returns. If you want to maximize the returns on your deposit if the price of the deposited asset fluctuates beyond a pre-defined range at the same time earning yield on your crypto assets, then there are no protocols in production as of now. Users can manually deposit their assets on a yield generator and then withdraw them when the price of the asset falls/rises beyond a certain point to maximize total returns. But this is not convenient for naive users as they have to continuously monitor price feeds and then withdraw their funds. It would be great if users can deposit funds and the protocol maximizes the returns automatically. It’ll also be useful if the returns can be transferred automatically to the user.
Symphony finance allows users to create limit orders by depositing the sell asset. The sell asset is deposited to a yield generating protocol like Aave, Yearn, Mstable, etc. This feature allows limit orders to earn yield for the time they are on the order book. The initial deposit + yield earned are traded for the buy asset automatically by the executor if the price constraints are satisfied. The order creator receives the buy assets automatically when the order is filled. The executor receives a small fee for executing the orders as they have to bear the expenses for running the relayer service and transaction cost.
Creating a limit order in symphony finance is similar to other order book exchanges, the only difference is that the sell asset has to be deposited into the contract. There is also a feature of stop-loss which is very useful in minimizing risk in case the sell asset price goes below a certain price. The sell asset is deposited to yield generating DeFi protocols like Aave, Compound, Yearn, etc. This is obviously different from the traditional limit orders where the sell assets are not utilized while the order is on the order book.
This project has four main components. First are the smart contracts that are written in solidity. All the core features like max range, stop-loss, interest protocols, and trade handlers are implemented in solidity. 1inch, Balancer, Uniswap, Paraswap are used as the trade handler. Their liquidity is used to fill the limit orders. Aave, Compound, Stake DAO are used as interest protocols. The sell assets are deposited to these protocols to earn interest while they are on the order book. These contracts are deployed on the polygon for scalability. Chainlink oracles are used to implement the stop-loss feature. The second component is the executor service or relayer service which fills the orders when the price constraints are satisfied. It indexes all the orders that are submitted to the core contracts and sends out transactions when the price is right. The service is written in typescript with the Postgres database. The third component is the event indexer or the subgraph. We have used the graph protocol to implement it. It is used by the executor and the UI. The fourth component is the UI which lets the user create, view & cancel its limit orders.