Please describe your proposed solution
Background
This proposal builds on the success of our Fund 11 initiative, where we started to develop the initial Aiken Open-Source Smart Contract Library.
<https://projectcatalyst.io/funds/11/cardano-open-developers/aiken-open-source-smart-contract-library-by-meshjs-and-trustlevel>
Given the positive community feedback and the clear advantages Aiken-based contracts bring, we are now focusing on expanding this library to include DeFi smart contracts.
As seen with Minswap Labs' development of their V2 DEX Smart Contract, this upgrade demonstrated Aiken's potential to significantly enhances performance - running at least 5x faster- and to improve throughput and reduce costs. Despite these advances, Cardano's DeFi ecosystem still lacks a unified smart contract library, leading to duplicated efforts, increased security risks, and slower innovation.
By extending our Aiken library to DeFi, we aim to provide developers with new tools for building efficient and secure applications, and thus accelerating innovation and adoption across of Cardano DeFi.
Overview of our proposed library
With this proposal we want to create an open-source library of DeFi smart contracts using Aiken. We aim to offer reusable contract templates that could facilitate faster deployment and scaling of DeFi applications.
<u>Library Composition:</u>
The library will consist of a curated collection of smart contracts categorized into four main groups, each addressing key areas of DeFi:
- Trading and Liquidity Provision: Contracts that facilitate automated market-making and manage liquidity contributions for efficient trading.
- Financial Instruments and Derivatives: Contracts for creating and managing stablecoins, and enabling complex financial operations like options, futures, and swaps.
- Asset Management and Collateral: Contracts for tokenizing assets and managing collateral to ensure financial stability and integrity.
- Oracles: Systems for handling external data integration through oracles, ensuring accurate and real-time data flow for stablecoin pricing and other financial applications.
Detailed Description of Contract Categories
This section will provide a thorough understanding of how these contracts are designed to operate within the DeFi ecosystem:
<u>1. Trading and Liquidity Provision</u>
- Purpose: To ensure that DeFi platforms operate efficiently with sufficient liquidity.
- Construction:
- Automated Market Maker (AMM) Contracts: Contracts with algorithms to automatically balance asset ratios in liquidity pools to determine pricing, allowing for continuous trading.
- Liquidity Provision Contracts: These contracts manage the injection and withdrawal of funds from liquidity pools, calculating and distributing yield based on the amount and duration of liquidity provided by participants.
- Key Functionalities: Dynamic pricing based on liquidity, liquidity pool management, yield calculation, and distribution.
<u>2. Financial Instruments and Derivatives</u>
- Purpose: These contracts allow for the creation and trading of financial products such as derivatives.
- Construction:
- Stablecoin Contracts: Contracts to issue and manage stablecoins, ensuring they remain pegged to external references like fiat currencies or commodities.
- Derivative Contracts: Such as options, futures, and swaps, are designed to execute based on predefined conditions and use smart contract-enforced terms for automatic settlement.
- Key Functionalities: Stablecoin peg maintenance, options for buying/selling, futures for locking in future buy/sell prices, and swaps for exchanging different financial instruments.
<u>3. Asset Management and Collateral</u>
- Purpose: These contracts facilitate the tokenization of both digital and real-world assets, making them accessible and tradable on the blockchain. They also manage collateral, which is essential for securing various financial transactions within DeFi applications.
- Construction:
- Tokenization Contracts: Built to convert physical or digital assets into blockchain tokens, these contracts include mechanisms for verifying asset authenticity, establishing and managing (fractional) ownership.
- Collateral Management Contracts: Designed to handle the locking, tracking, and valuation of collateral assets. These include functions for automated adjustments based on market conditions and protocols for liquidation in case of contract breaches.
- Key Functionalities: Asset registration, fractional ownership management, real-time valuation, and collateral liquidation processes.
<u>4. Data Integration and Oracles</u>
- Purpose: To fetch and verify external data necessary for the accurate functioning of various DeFi applications, particularly those involving valuation-dependent instruments like stablecoins and derivatives.
- Construction:
- Oracle Contracts: Connect with multiple external data sources to fetch reliable, timely, and verifiable data.
- Price Oracles: These contracts are important for providing external data to the blockchain, necessary for DeFi applications that rely on real-time information, such as pricing assets accurately.
- Key Functionalities: Data fetching from external sources, real-time data updates, aggregation of data from multiple sources, and conflict resolution in data discrepancies.
Implementation Plan:
There is already a lot of good open-source code that incorporates some aspects of our proposal. Our main goal is to create a central place where the community can collaborate. If a team wants to contribute without us having to rewrite the code, then we could also use some of the funds for audit, for example, so that we ensure that the code is really secure and correct. Win-win for all open-source DeFi projects in Cardano! However, many contracts are not yet available in Aiken, or only fragmented, so the first step after funding is to ask the community who wants to contribute, and also what the best place for library is (for example, it can be Cardano Foundation, or community sites like Mesh or a new one in our TrustLevel Repo).
<u>Features:</u>
- A library of smart contracts, where each consists of a contract, Aiken workspace, exported blueprint, and Transaction Builder components.
- Transaction builders are included for ease of use, aiding new developers in understanding and implementing contracts.
- Inclusion of existing community open source simple contracts and newly implemented contracts showcasing common Cardano DApp design patterns.
- Documentation includes example use cases and developer support materials making it easier for new and experienced developers to adopt and adapt the library for their specific needs.