Skip to content

flexfi-protocol/flexfi-web3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FlexFi - Crypto-Backed BNPL Protocol

The freedom to pay with crypto, later.

FlexFi is a revolutionary Solana-based protocol that enables Buy Now, Pay Later (BNPL) transactions backed by cryptocurrency collateral. Unlike traditional BNPL services, FlexFi eliminates debt traps by requiring users to stake crypto assets as collateral.

🌟 Key Features

πŸ’° Collateral-Backed BNPL

  • No toxic debt - Every payment is collateral-backed
  • Automatic liquidation - No late fees, just collateral forfeit
  • Flexible payment terms - 3, 4, 6, 12, 18, 24, or 36 installments

🎯 Dynamic Credit Scoring

  • Inclusive scoring - Your access grows as you use the platform
  • Real-time updates - Score adjusts with payment behavior
  • No bank dependency - Fully sovereign credit system

πŸ’Ž Multi-Tier Card System

  • Standard (Free): 7% fees, 3-6 month terms
  • Silver ($50/year): 4% fees, up to 12 months
  • Gold ($150/year): 3.5% fees, 0.5% cashback
  • Platinum ($300/year): 3% fees, 1.5% cashback

🎨 NFT Enhancement System

  • Bronze/Silver/Gold NFTs enhance card benefits
  • Reduced fees and increased limits
  • Unique utility beyond just aesthetics

πŸ“ˆ FlexYield Integration

  • Earn on every purchase - Rewards invested automatically
  • Multiple strategies - Staking, DeFi, RWA, Auto-compound
  • Passive income while spending

πŸ—οΈ Architecture Overview

FlexFi Protocol Modules

🧩 Module 🎯 Purpose πŸ”§ Key Functions πŸ’° Financial Impact
πŸ” Staking Collateral Management β€’ Deposit USDC
β€’ Lock periods (7-365 days)
β€’ Auto-liquidation
Secures BNPL transactions
πŸ›’ BNPL Buy Now Pay Later β€’ Create payment plans
β€’ Process installments
β€’ Handle defaults
Core revenue generation
πŸ“Š Score Credit Assessment β€’ Track payment history
β€’ Dynamic scoring (0-1000)
β€’ Risk evaluation
Determines user limits
πŸ’³ Card User Tiers β€’ 4 tier system
β€’ Annual fee management
β€’ Benefit allocation
Subscription revenue
🎨 NFT Enhanced Benefits β€’ Mint utility NFTs
β€’ Attach to cards
β€’ Dynamic perks
Premium user engagement
πŸ“ˆ Yield Reward System β€’ Auto-invest rewards
β€’ Multiple strategies
β€’ Compound returns
User retention incentive

Data Flow Architecture

πŸ‘€ User β†’ πŸ” Whitelist Check β†’ πŸ’° Stake Collateral β†’ πŸ›’ BNPL Eligible
                ↓
πŸ“Š Score Tracking ← πŸ’³ Card Benefits ← 🎨 NFT Enhancements ← πŸ“ˆ Yield Generation

Security & Access Control

Layer Component Access Level Purpose
Layer 1 Whitelist System Admin-controlled Platform access
Layer 2 Wallet Verification User signature Transaction auth
Layer 3 Collateral Check Protocol logic Risk management
Layer 4 Score Validation Dynamic scoring Credit limits

πŸš€ Quick Start

Prerequisites

  • Rust (latest stable)
  • Solana CLI tools
  • Node.js (for tests)
  • Git

Installation

# Clone the repository
git clone https://github.com/your-org/flexfi-web3.git
cd flexfi-web3

# Build the program
cargo build-bpf

# Run tests
npm run test

Deployment

# Deploy to devnet
solana program deploy target/deploy/flexfi_program.so

# Verify deployment
solana program show <PROGRAM_ID>

πŸ“– Documentation

Core Modules

πŸ” Whitelist System

All users must be whitelisted to use FlexFi functions:

// Initialize whitelist (admin only)
InitializeWhitelist

// Add user to whitelist
AddToWhitelist { user_pubkey }

πŸ’° Staking Module

Users stake USDC as collateral for BNPL transactions:

// Deposit staking
DepositStaking { amount, lock_days }

// Withdraw staking (after lock period)
WithdrawStaking { amount }

πŸ›’ BNPL Module

Create and manage Buy Now, Pay Later contracts:

// Create BNPL contract
CreateBNPLContract { 
    amount, 
    installments, 
    payment_interval_days 
}

// Make payment
MakeBNPLPayment

// Check for overdue payments
CheckRepayment

πŸ“Š Score Module

Track and manage user credit scores:

// Initialize score (50 points default)
InitializeScore

// Update score (automatic)
UpdateScore { change }

// Get current score
GetScore

πŸ§ͺ Testing

Test Structure

tests/
β”œβ”€β”€ 1-verify-wallet-whitelisted.js  # Verify wallet whitelist status
β”œβ”€β”€ 2-test-staking-with-backend.js  # Test staking functionality
└── 3-test-score.js                 # Test credit score system

Running Tests

# Install dependencies
npm install

# Run individual tests
node tests/1-verify-wallet-whitelisted.js
node tests/2-test-staking-with-backend.js
node tests/3-test-score.js

🎯 User Journeys & Scenarios

πŸ†• Scenario 1: New User Onboarding

The Journey: From Registration to First BNPL

flowchart TD
    A[πŸ‘€ User visits FlexFi] --> B[πŸ“ Register with Email]
    B --> C[πŸ”‘ Backend creates wallet]
    C --> D[βœ… Admin adds to whitelist]
    D --> E[πŸ’° User stakes 100 USDC]
    E --> F[πŸ“Š Score initialized: 50 pts]
    F --> G[πŸ’³ Choose card tier]
    G --> H[πŸ›οΈ Ready for BNPL!]
    
    style A fill:#e1f5fe
    style H fill:#c8e6c9
Loading

Step-by-Step Breakdown:

Step Action Who Result
1 User registers User Account created
2 Wallet generation Backend New Solana wallet
3 Whitelist addition Admin Access granted
4 Stake collateral User 100 USDC locked 30 days
5 Score initialization System 50 credit points
6 Card selection User Silver card active
7 BNPL eligibility System Up to 100 USDC available

πŸ›’ Scenario 2: BNPL Purchase Journey

The Journey: Buy Now, Pay Later in Action

Payment Flow Details:

πŸ’° Purchase: $30 sneakers
πŸ“Š Split: 3 payments of $10.33 each
🏦 Collateral: 100 USDC staked
πŸ’³ Card: Silver (4% fee = $1.20)

Timeline:
Week 1:  βœ… Merchant gets $30 instantly
Week 4:  βœ… Payment 1 ($10.33) - Score: 505
Week 9:  ❌ Payment 2 missed - Auto-debit from staking - Score: 485  
Week 12: βœ… Payment 3 ($10.33) - Contract complete - Score: 505

πŸ“ˆ Scenario 3: FlexYield in Action

The Journey: Earning While Spending

FlexYield Mathematics:

πŸ”Ή Purchase: $100 coffee machine
πŸ”Ή Gold Card: 0.5% cashback = $0.50
πŸ”Ή Strategy: AutoCompound Staking
πŸ”Ή APY: ~8% annually

Monthly progression:
Month 1: $0.50 β†’ Stake
Month 2: $1.03 β†’ Compound  
Month 3: $1.59 β†’ Compound
Month 6: $3.24 β†’ Available to claim

🎴 NFT Enhancement Scenario

The Journey: Upgrading with NFTs

Before vs After NFT:

Feature Silver Card Silver + Bronze NFT
BNPL Fee 4% 3.5%
Credit Limit Standard +10%
Perks Basic Priority processing
Visual Standard design Custom NFT art

πŸ”§ Configuration

Environment Variables

SOLANA_RPC_URL=https://api.devnet.solana.com
FLEXFI_PROGRAM_ID=7Yd4fxojkMc9ZvCiewx7coorSnFm84VccBiNxX3hujUH

Constants Configuration

Key constants can be modified in src/constants.rs:

// Minimum staking amount (10 USDC)
pub const MIN_STAKING_AMOUNT: u64 = 10_000_000;

// Initial credit score
pub const INITIAL_SCORE: u16 = 50;

// Grace period for late payments
pub const GRACE_PERIOD_DAYS: u8 = 15;

πŸ›£οΈ Roadmap

Phase 1: Core Protocol βœ…

  • Staking mechanism
  • BNPL contracts
  • Credit scoring
  • Whitelist system

Phase 2: Enhanced Features πŸ”„

  • Card system implementation
  • NFT utility integration
  • FlexYield mechanism
  • Cross-chain bridges

Phase 3: Advanced Features πŸ”œ

  • FlexBoost merchant integration
  • Mobile SDK
  • DeFi integrations
  • Governance token

πŸ”’ Security

Audits

  • Code audit by Certik
  • Economic audit by Gauntlet
  • Bug bounty program

Best Practices

  • All functions require appropriate signatures
  • Critical operations include checks and balances
  • Automatic liquidation prevents bad debt
  • Comprehensive testing coverage

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Flow

  1. Fork the repository
  2. Create a feature branch
  3. Write tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Links

πŸ† Key Achievements

  • βœ… Successful Staking: 100 USDC staked βœ“
  • βœ… Score System: 50 initial points βœ“
  • βœ… Whitelist Integration: Secure access control βœ“
  • βœ… Automated Testing: Comprehensive test suite βœ“

Built with ❀️ on Solana

FlexFi: Redefining the future of payments with crypto-backed credit.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •