CreditFlow is a decentralized credit and lending system built on the Stacks 2.0 blockchain, leveraging Bitcoin's security. The protocol enables users to access loans based on a dynamic credit scoring model that rewards responsible behavior with lower collateral requirements and interest rates.
By integrating on-chain credit reputation, CreditFlow paves the way for more accessible and equitable lending in the Bitcoin ecosystem.
- Credit-Based Lending: Users begin with a base credit score and improve it by repaying loans.
- Dynamic Interest Rates: Borrowers with higher scores receive better rates.
- Collateral Optimization: Collateral requirements decrease as creditworthiness increases.
- Fully Decentralized: Trustless protocol logic governed entirely by Clarity smart contracts.
- Bitcoin Finality: Built on Stacks, with Bitcoin-secured transactions and data.
-
Score Initialization Users opt-in to the protocol by initializing their credit profile (starting at a base score of 50).
-
Loan Request Borrowers request a loan by specifying the amount, collateral, and duration. The protocol checks eligibility based on their current credit score.
-
Loan Repayment Loans are repaid with interest. On successful repayment, the user's credit score increases, and their collateral is returned.
-
Defaults & Penalties If a loan is not repaid by its due date, it may be marked as defaulted by the contract owner, decreasing the user’s score.
-
Score Range:
50 (min)–100 (max) -
Loan Eligibility: Requires score ≥
70 -
Score Impact:
- ✅ Repayment: +2 points (up to 100)
- ❌ Default: −10 points (not below 50)
-
Collateral Ratio: Inversely proportional to credit score
collateral = amount * (100 - score * 0.5) / 100 -
Interest Rate: Also based on score
rate = 10 - (score * 5 / 100)(%)
UserScores: Tracks user’s score and repayment historyLoans: Stores individual loan dataUserLoans: Keeps track of each user's active loan IDs
next-loan-id: Incremental ID for new loanstotal-stx-locked: Global STX collateral locked in the system
- Only the contract deployer (
tx-sender) can mark loans as defaulted. - All other functions are open to users who have initialized their score.
initialize-score: Initializes user score to 50request-loan(amount, collateral, duration): Requests a new loanrepay-loan(loan-id, amount): Repays an active loanmark-loan-defaulted(loan-id): Marks a loan as defaulted (admin only)
get-user-score(user): Retrieves user credit infoget-loan(loan-id): Fetches loan detailsget-user-active-loans(user): Lists user's current active loans
- Written in Clarity, a decidable smart contract language for Stacks.
- Ensure integration with a Stacks wallet and environment (e.g., Clarinet) for deployment and testing.
- Oracle integration for off-chain credit data
- P2P lending pools
- DAO-based governance for protocol parameters
- NFT-based credit badges
We welcome contributions! Please fork the repo, open issues, or submit PRs to improve the protocol logic or documentation.