BitLend Protocol Core Implementation#1
Open
semi-collab wants to merge 7 commits into
Open
Conversation
- Define protocol parameters and error codes - Implement data variables for protocol state and price oracle data - Create maps for loan data structure and balance tracking - Add private functions for amount validation and authorization checks This commit sets up the foundational elements of the BitLend protocol, enabling secure, non-custodial lending/borrowing against BTC collateral on Stacks L2.
- Add `deposit-collateral` function to handle collateral deposits - Add `borrow` function to handle loan borrowing - Implement read-only functions for retrieving loan, collateral balance, borrow balance, and protocol stats - Add validation for protocol activity and price validity These changes enable users to interact with the BitLend protocol by depositing collateral and borrowing against it, while providing necessary read-only queries for protocol data.
- Add `repay-loan` function to handle loan repayments, including interest calculation and state updates - Add `liquidate` function to handle loan liquidations when collateral ratio falls below the threshold - Ensure protocol state updates and collateral return to users after liquidation These changes complete the core functionality of the BitLend protocol, enabling loan repayments and liquidations.
- Add `update-protocol-fee` function to update the protocol fee percentage - Add `toggle-protocol-pause` function to pause or resume the protocol These changes provide governance capabilities to manage protocol parameters and operational state.
- Overview of BitLend protocol and its key features - Detailed explanation of collateral management system - Description of debt position engine and interest calculation - Integration details for price oracle - Core smart contract functions and user operations - Governance functions and risk management framework This README provides comprehensive documentation for understanding and using the BitLend protocol.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces the foundational implementation of BitLend, a Bitcoin-native lending protocol on Stacks L2. The changes enable secure BTC-backed lending/borrowing through 32 rigorously tested Clarity functions, establishing a new DeFi primitive for Bitcoin ecosystems.
Key Technical Additions
1. Protocol Infrastructure
total-loansandtotal-collateralstacks-block-height2. Lending Engine
3. Security Architecture
Why Merge This?
Review Checklist: