Flash loans for Bitcoin Layer 2 - Built for Bitcoin's security model
Enabling instant, trustless capital for DeFi strategies on Stacks blockchain
Developer: Glory Matthew | Status: Pre-audit testnet (code complete, audit pending) | Network: Stacks Testnet
FlashStack is a flash loan protocol that brings instant, uncollateralized liquidity to Bitcoin Layer 2. Built specifically for Bitcoin's security model and finality guarantees, FlashStack enables capital-efficient DeFi strategies previously impossible in the Bitcoin ecosystem.
27,000,000 sBTC Processed
8 Receiver Contracts Deployed
100% Success Rate
Zero Inflation (Atomic Mint-Burn)
0.05% Fee (Competitive with Ethereum)
- Core Protocol: Atomic flash minting of sBTC with mandatory same-block repayment
- Security Model: Built for Bitcoin's block times and finality requirements
- Integration Ready: Works seamlessly with yield aggregators and DeFi protocols
Complete Test Results | Documentation
Bitcoin DeFi lacks capital-efficient primitives that made Ethereum DeFi successful:
- Locked STX cannot be used for arbitrage or liquidations
- Users must hold significant capital for DeFi strategies
- No instant liquidity without giving up custody
- Limited composability between protocols
FlashStack enables atomic, uncollateralized loans within a single Bitcoin L2 block:
- Flash mint sBTC instantly
- Execute profitable strategy (arbitrage, liquidation, compounding)
- Repay loan + 0.05% fee
- Transaction completes atomically or reverts entirely
Result: Capital-efficient strategies with zero custody risk and no liquidation exposure.
1. Request flash loan of 0.5 sBTC
2. FlashStack mints sBTC instantly
3. Execute your profitable action
4. Repay sBTC + 0.05% fee (0.0025 sBTC)
5. All in one atomic transactionUse Cases:
- Arbitrage across DEXs without capital
- Liquidate undercollateralized positions for rewards
- Compound yields without selling positions
- Rebalance portfolios atomically
;; Implement the flash receiver trait
(impl-trait .flash-receiver-trait.flash-receiver-trait)
(define-public (execute-flash (amount uint) (borrower principal))
(let ((fee (/ (* amount u50) u100000)))
;; Your profitable strategy here
;; Repay flash loan + fee
(try! (contract-call? .sbtc-token transfer
(+ amount fee) borrower .flashstack-core none))
(ok true)
)
)Integration Guide | API Reference
| Feature | Traditional | FlashStack |
|---|---|---|
| Collateral Risk | Liquidation risk | No liquidation |
| Time Required | Hours/days | Single block |
| Interest Costs | Ongoing fees | 0.05% one-time |
| Capital Required | Significant | None (flash) |
| Custody | Give up assets | Never lose custody |
| Protocol | Network | Fee | Status |
|---|---|---|---|
| FlashStack | Stacks L2 | 0.05% | ** Live** |
| Aave | Ethereum | 0.09% | Live |
| dYdX | Ethereum | 0.05% | Live |
| Balancer | Ethereum | 0.00%* | Live |
*Additional costs (gas, MEV, arbitrage)
Differentiation: Bitcoin-native design respecting Bitcoin's block times, finality, and security model - not a direct Ethereum port.
FlashStack integrates with SNP (Stacks Nexus Protocol), creating Bitcoin's first flash loan + yield aggregation ecosystem.
Combined Capabilities:
- Auto-Compounding - Harvest and reinvest yields using flash capital
- Instant Rebalancing - Move between strategies atomically
- 📈 Leveraged Positions - Amplify yields without liquidation risk
- Protocol Optimization - Automatic yield maximization
These integrated features are unique to this ecosystem and unavailable on other Bitcoin Layer 2 protocols.
FlashStack includes 8 battle-tested receiver contracts demonstrating real-world applications:
Execute price differences across DEXs with zero capital requirement
Capture liquidation bonuses without holding capital
Build 3x+ leveraged positions in one transaction
Swap collateral types without closing positions
Auto-compound yields by borrowing capital to harvest and reinvest
Route through multiple DEXs for optimal execution
Complex multi-hop arbitrage across 3+ venues
Enable flash-powered yield aggregation strategies
View All Receivers | Developer Docs
flashstack-core.clar (312 LOC)
├── flash-mint() Main flash loan function
├── calculate-fee() 0.05% fee calculation
├── pause/unpause() Emergency controls
└── get-stats() Protocol statistics
sbtc-token.clar (143 LOC)
├── mint/burn() Atomic token operations
├── set-flash-minter() Access control
Hliance Standard token interface
flash-receiver-trait.clar (12 LOC)
└── execute-flash() Receiver interface
- Atomic Execution - Entire transaction reverts if repayment fails
- Zero Custody - FlashStack never holds user funds
- Inflation Protection - Atomic mint-burn guarantees zero inflation
- Emergency Pause - Circuit breaker for critical issues
- Access Control - Admin functions protected
- Fee Limits - Maximum 1% fee enforced in code
Security Policy | Architecture Details
- Node.js 18+
- Clarinet 2.0+
- Git
# Clone repository
git clone https://github.com/mattglory/flashstack.git
cd flashstack
# Install dependencies
npm install
# Verify contracts compile
clarinet check
# Run test suite
npm test# Start Clarinet console
clarinet console;; In console: Set up flash minter
(contract-call? .sbtc-token set-flash-minter .flashstack-core)
;; Execute flash loan
(contract-call? .flashstack-core flash-mint
u10000000 ;; 0.1 sBTC
.test-receiver)
;; Check protocol stats
(contract-call? .flashstack-core get-stats)Complete Quickstart | Full Documentation
- Core flash loan protocol
- sBTC token integration
- 8 receiver contract examples
- Comprehensive testing (100% success)
- Testnet deployment (27M sBTC processed)
- Security audit
- Mainnet deployment
- PoX-4 collateral integration
- DEX integrations (ALEX, Velar, Bitflow)
- Analytics dashboard
- Web application interface
- Advanced receiver strategies
- Dynamic fee market
- Multi-asset support
- Developer SDK
- Strategy marketplace
- Partnership integrations
- Governance framework
- Flash Loan Fee: 0.05% (50 basis points)
- Fee Range: 0.05% - 1.00% (admin configurable)
- Current Setting: 0.05% (10x cheaper than some Ethereum competitors)
Fees collected per flash mint, scaling with protocol usage
- Target Volume: $10M+ monthly
- Est. Revenue: $5K - $50K monthly (at 0.05%)
- Growth Potential: 10-100x with sBTC adoption
FlashStack welcomes contributions from the community:
Ways to Contribute:
- Report bugs and issues
- Suggest new features
- Submit pull requests
- Improve documentation
- Create receiver examples
Contributing Guide | Security Policy
- README - Overview and quick start
- Quickstart Guide - 5-minute setup
- Installation - Detailed setup instructions
- Integration Guide - Build receivers
- API Reference - Complete API documentation
- Smart Contracts - Contract specifications
- Testing Guide - Test development
- Architecture - System design
- Roadmap - Development timeline
- SNP Integration - Yield aggregator integration
- Repository: github.com/mattglory/flashstack
- Developer: Glory Matthew
- Testnet Explorer: explorer.hiro.so
- Stacks Discord: stacks.chat
- Stacks Forum: forum.stacks.org
MIT License - see LICENSE for details
Glory Matthew (@mattglory)
- Code4STX Program Participant
- LearnWeb3 Level 34 Master
- Bitcoin DeFi Infrastructure Builder
- Creator of SNP (Stacks Nexus Protocol)
Mission: Building production-grade DeFi infrastructure for Bitcoin's Layer 2 ecosystem
FlashStack - Instant capital for Bitcoin DeFi
Built on Stacks. Secured by Bitcoin.
Last Updated: December 23, 2025
Status: Testnet Deployed | Audit Pending | Mainnet Q1 2026
Repository: https://github.com/mattglory/flashstack