Hello Compound Community,
We’re developing the Compound Kit as part of a Compound dev tooling grant, aiming to empower developers in the Compound ecosystem. The product architecture is now ready, and we’re eager to incorporate your valuable feedback to improve it.
All thoughts, suggestions, and questions are welcome. Your insights will significantly contribute to the progress of this project.
The Compound Kit
The Compound Kit empowers developers to rapidly build applications and enhance user experiences with the Compound protocol.
Building an application on top of the Compound protocol can be a challenging and time-consuming process due to the inherent risks associated with smart contracts, and the complex calculations and encoding required for various use cases; such as: collateral swaps, self-liquidation, leveraging, and zapping.
The Compound Kit eliminates the need for developers to spend time and resources on building and maintaining their own smart contracts. By leveraging Protocolink, a router system that specializes in bundling multiple functions, developers can add more use cases in a highly modular way without deploying new contracts, and significantly reducing user risk. By providing practical use cases, it empowers developers to build applications more easily while reducing the time and costs associated with development and maintenance.
Compound Kit Architecture
Logics: the above illustrates the actions performed during execution, such as approval, swap, supply, borrow, flash loans, and so on.
Developers
Developers can utilize the Compound Kit in their frontend or backend services. With the use cases supported by the Compound Kit, they can easily generate transaction data or utilize it even for complex transaction scenarios. This significantly lowers the barrier for developers, allowing them to focus on providing a better user experience and infrastructure.
Compound Kit API/SDK
The Compound Kit API and its SDK generate and return transaction data based on the specified use cases. They provide estimated execution results, calculate the optimal path for each use case, and forward protocol logics to Protocolink.
The overall architecture places reusable logics at Protocolink’s level, including functions such as: collateral supply, base supply, collateral withdrawal, base withdrawal, claims, borrowing, repayment with Compound v3 smart contracts, and the use of flash loans and swaps. The Compound Kit leverages Protcolink to provide a minimalist interface that enables applications to offer one-click functionality with the Compound Protocol. Use cases include, but are not limited to:
- Collateral swap
- Self-liquidation
- Leverage
- Zap
Protocolink
Protocolink is a versatile router system proficient in processing ERC20, NFTs, and lending positions. This provides users and developers greater flexibility when creating transactions across different protocols. It covers all reusable logics, can bundle various protocol functions into a single transaction, and further provides an easy-to-integrate API and SDK, like the ones mentioned in the Compound Kit.
Protocolink is designed with extensibility in mind. As the reusable logics are maintained at Protocolink, it’s easier to provide new APIs in the Compound Kit when there’s a new use case. For example, if Compound v4 is released, the logic in Protocolink (such as repayment and withdrawal from Compound v3) can be reused to support a position migration API in the Compound Kit.
Compound Kit Example - Leverage
Building leveraged positions on the target token.
Interface
- getSupportedChainIds(): Returns the supported chain IDs.
- getSupportedMarketIds(): Returns the supported market IDs for the respective chain.
- leverage.getTokens(): Returns the tokens available for use in the market.
- leverage.getQuote(): Returns the anticipated position changes to display, approvals/permits to sign, and leverage positions logic.
- buildTransactionRequest(): Returns transaction data for leveraged operations.
Logics behind
- Initiates a flash loan of the leverage token.
- Deposits the leverage token to the user.
- Borrows the base token from the market.
- Swaps the base token to the leverage token.
- Repays the flash loan with a fee.
- Deposits the remaining tokens, if any.
Fees
In executing the above operations, three types of fees may be involved:
- A fee charged for conducting the swap (the rate depends on the DEX used).
- A cost for utilizing flash loans. This rate depends on the service provider, as well as an additional 0.05% rate charged by Protocolink.
- A fee related to the initial fund deployment or borrowing process, set at 0.2% rate by Protocolink.
Please note that this fee structure may be subject to change as our service grows, in line with our long-term goal of building and supporting the ecosystem.
Moreover, the fees generated by Protocolink can be shared in a 50:50 ratio with the developers who initiate the transaction. This arrangement aims to encourage more developers to utilize the Compound Kit and further expand the Compound ecosystem.
Conclusion and Next Steps
We are sharing the architecture of the Compound Kit to garner feedback from the Compound community. Additionally, we are aiming to successfully complete Milestone 1. Upon its completion, we’ll progress to Milestone 2 as outlined in our Questbook grant proposal (link). Our ultimate goal is to simplify development processes, thereby expanding the Compound ecosystem. We look forward to your valuable feedback and continued support.