Skip to content

onflow/FlowCreditMarket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

FlowCreditMarket - DeFi Lending Protocol on Flow

πŸ“Š Project Status

  • Contract: βœ… Implemented with FungibleToken Standard
  • Tests: βœ… 100% Passing (22/22 tests)
  • Coverage: βœ… 89.7%
  • Documentation: βœ… Complete
  • Standards: βœ… FungibleToken & DeFi Actions Compatible
  • FlowVault Removal: βœ… Complete (Ready for FlowVaults Integration)

🎯 FlowVaults Integration Milestones

Current Status (Tracer Bullet Phase)

  • βœ… Smart Contract Integration: FlowCreditMarket provides sink/source interfaces for token swapping
  • βœ… Development & Testing: Automated testing framework for FlowCreditMarket and DefiActions
  • βœ… Repository Structure: FlowCreditMarket code in private repo, DefiActions in public repo
  • πŸ’› Test Coverage: Working towards comprehensive test suite for FlowVaults functionality
  • πŸ‘Œ AMM Integration: Currently using dummy swapper, real AMM deployment planned

Upcoming (Limited Beta)

  • βœ… Documentation: First pass documentation of FlowCreditMarket (this README)
  • βœ… Testing: Extensive test suite for FlowCreditMarket and DefiActions
  • πŸ’› Sample Code: DefiActions sample code and tutorials needed
  • πŸ‘Œ Advanced Features: Per-user limits and controlled testing capabilities

Future (Open Beta)

  • βœ… Open Access: Full public access to FlowCreditMarket and DefiActions
  • πŸ’› Documentation: Improved documentation and tutorials
  • βœ… Sample Code: Complete tutorials for DefiActions integration

🏦 About FlowCreditMarket

FlowCreditMarket is a decentralized lending and borrowing protocol built on the Flow blockchain. It implements the Flow FungibleToken standard and integrates with DeFi Actions for composability.

Key Features

  • FungibleToken Standard: Full compatibility with Flow wallets and DEXs
  • DeFi Actions Integration: Composable with other DeFi protocols via Sink/Source interfaces
  • Vault Operations: Secure deposit and withdraw functionality
  • Position Management: Create and manage lending/borrowing positions
  • Interest Mechanics: Compound interest calculations with configurable rates
  • Health Monitoring: Real-time position health calculations and overdraft protection
  • Access Control: Secure entitlement-based access with proper authorization
  • Token Agnostic: Supports any FungibleToken.Vault implementation (FlowVault removed)

Technical Highlights

  • Implements FungibleToken.Vault interface for standard token operations
  • Provides DeFiActions.Sink and DeFiActions.Source for DeFi composability
  • Uses scaled balance tracking for efficient interest accrual
  • Supports multiple positions per pool with independent tracking
  • Includes comprehensive metadata views for wallet integration

πŸ§ͺ Test Suite

The project includes comprehensive tests covering all functionality:

# Run all tests with coverage
flow test --cover

# Run specific test file
flow test cadence/tests/core_vault_test.cdc

Test Results Summary

  • Core Vault Operations: βœ… 3/3 passing
  • Interest Mechanics: βœ… 6/6 passing
  • Position Health: βœ… 3/3 passing
  • Token State Management: βœ… 3/3 passing
  • Reserve Management: βœ… 3/3 passing
  • Access Control: βœ… 2/2 passing
  • Edge Cases: βœ… 3/3 passing
  • Simple Import: βœ… 2/2 passing

Total: 22/22 tests passing with 89.7% code coverage

For detailed test status and FlowVault removal summary, see TestingCompletionSummary.md

πŸš€ Quick Start

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/your-username/FlowCreditMarket.git
cd FlowCreditMarket
  1. Install dependencies:
flow dependencies install
  1. Run tests:
flow test --cover

Deploy to Emulator

  1. Start the Flow emulator:
flow emulator --start
  1. Deploy the contracts:
flow project deploy --network=emulator

πŸ“¦ Project Structure

FlowCreditMarket/
β”œβ”€β”€ cadence/
β”‚   β”œβ”€β”€ contracts/
β”‚   β”‚   └── FlowCreditMarket.cdc           # Main lending protocol contract
β”‚   β”œβ”€β”€ tests/
β”‚   β”‚   β”œβ”€β”€ test_helpers.cdc            # Shared test utilities
β”‚   β”‚   β”œβ”€β”€ core_vault_test.cdc         # Vault operation tests
β”‚   β”‚   β”œβ”€β”€ interest_mechanics_test.cdc # Interest calculation tests
β”‚   β”‚   └── ...                         # Other test files
β”‚   β”œβ”€β”€ transactions/                   # Transaction templates (coming soon)
β”‚   └── scripts/                        # Query scripts (coming soon)
β”œβ”€β”€ FlowActions/
β”‚   └── cadence/contracts/interfaces/
β”‚       └── DeFiActions.cdc             # DeFi Actions interface
β”œβ”€β”€ imports/                            # Flow standard contracts
β”œβ”€β”€ flow.json                           # Flow configuration
└── README.md                           # This file

πŸ”§ Contract Architecture

Core Components

  1. Pool: Main lending pool managing positions and reserves
  2. Position: User positions tracking deposits and borrows
  3. TokenState: Per-token state including interest indices
  4. FlowCreditMarketSink/Source: DeFi Actions integration for composability

Key Interfaces

  • FungibleToken.Vault: Standard token operations
  • ViewResolver: Metadata views for wallets
  • Burner.Burnable: Token burning capability
  • DeFiActions.Sink/Source: DeFi protocol composability

πŸ› οΈ Development

Creating a Position

// Create a new pool with your token type
let pool <- FlowCreditMarket.createPool(
    defaultToken: Type<@YourToken.Vault>(),
    defaultTokenThreshold: 0.8
)

// Create a position
let positionId = pool.createPosition()

// Deposit funds
let vault <- YourToken.mintTokens(amount: 100.0)
pool.deposit(pid: positionId, funds: <-vault)

Running Tests

# Run all tests
flow test --cover

# Run specific test category
flow test cadence/tests/interest_mechanics_test.cdc

πŸ“š Documentation

Current Documentation

Planning & Roadmap

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

This project is licensed under the MIT License.

πŸ”— Resources

Note

Tests are being updated for the new contract implementation and will be added in the next PR.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published