BitYield Protocol enables Bitcoin holders to earn DeFi yields on Starknet without complex bridging or wrapping processes. Single Query for Bitcoin to Starknet yield farming with automated optimization across multiple protocols.
Bitcoin holders cannot easily access DeFi yields without:
- Understanding complex bridging mechanisms
- Manually wrapping BTC to WBTC
- Navigating multiple DeFi protocols
- Managing rebalancing strategies As a result ,Billions of Bitcoin capital remains unused and untapped in Defi.
BitYield provides:
- AI Powered Bitcoin deposits via Atomiq integration
- Automatic WBTC conversion on Starknet
- Yield optimization across Vesu lending markets and Troves strategies
- Automated rebalancing via Cairo smart contracts
- Xverse wallet integration for seamless UX
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (React + Starknet.js) β
β Xverse Wallet + Atomiq SDK Integration β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
βAI Agent (LangGraph AGENT)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Atomiq Bridge Layer (BTC β WBTC) β
β ββββββββββββββββββ ββββββββββββββββββββ β
β β AtomiqBridge βββββββββββΊ MockAtomiqGatewayβ β
β β (Cairo) β β (Testing) β β
β ββββββββββββββββββ ββββββββββββββββββββ β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BitYield Core (Cairo 2.12.0 Contracts) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β BitYieldVault.cairo (ERC-4626) β β
β β β’ Deposit/Withdraw with share calculations β β
β β β’ Fee collection (performance + management) β β
β β β’ Emergency pause mechanism β β
β ββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββΌββββββββββββββββββββββββββββββββββββββ β
β β StrategyManager.cairo β β
β β β’ Yield optimization algorithm β β
β β β’ Rebalancing with threshold triggers β β
β β β’ APY calculation: Ξ£(w_i Γ r_i) β β
β ββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββΌβββββββββββββββ¬βββββββββββββββββββββββ β
β β VesuAdapter.cairo β TrovesAdapter.cairo β β
β β β’ Multi-pool management β β’ Strategy framework β β
β β β’ ERC-4626 vToken calls β β’ Reward harvesting β β
β βββββββββββββββββββββββββββββ΄βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Protocol Integration Layer (Starknet) β
β ββββββββββββ ββββββββββββ ββββββββββββββββββββββββ β
β β Vesu β β Troves β β Future Protocols β β
β β (Lending)β β(Staking) β β (Expandable) β β
β ββββββββββββ ββββββββββββ ββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Contract | Address | Starkscan |
|---|---|---|
| BitYieldVault | 0x06552bc669d3a53c7223ae7d0d5f47613f5da4fb318f21e5f596cc8a791a3f90 |
View |
| VesuAdapter | 0x0096b181aba9febca459591efdf27b885b3f8096b42f5f1f805fbd9bee65b75b |
View |
| TrovesAdapter | 0x0722c6917ff0ac4e298bfdeb409001d3bac6df3b72f338d63d075a6f614a4910 |
View |
| StrategyManager | 0x06154fad2a07742aed27af28c80c1259377bdffd1ffabee5aca9b1b7690b6a57 |
View |
| AtomiqBridge | 0x030cb9c97a7bb3f4e160382ce233ffdbc623b65776ce2e08ee9806e7f9d808ff |
View |
BitYield-Protocol/
βββ packages/
β βββ nextjs/ # Frontend application
β β βββ app/ # Next.js app router pages
β β βββ components/ # React components
β β βββ contracts/ # Contract ABIs and addresses
β β βββ public/ # Static assets
β β
β βββ snfoundry/ # Smart contracts
β βββ contracts/ # Cairo contracts
β β βββ src/ # Contract source code
β β βββ tests/ # Contract tests
β βββ scripts-ts/ # Deployment scripts
β
βββ .tool-versions # asdf version specifications
βββ package.json # Root package config
βββ README.md # This file
The main ERC4626-compliant vault contract managing user deposits and withdrawals.
Key Features:
- ERC20 share tokens (byWBTC) representing vault ownership
- Deposit WBTC, receive byWBTC shares
- Withdraw by burning byWBTC shares
- Automated fee collection (performance + management)
- Emergency pause/unpause functionality
- Owner-controlled rebalancing
State Variables:
asset: ContractAddress // WBTC token
total_assets_deposited: u256 // Total WBTC deposited
strategy_manager: ContractAddress // Strategy orchestration
vesu_adapter: ContractAddress // Vesu integration
troves_adapter: ContractAddress // Troves integration
performance_fee_bps: u32 // Performance fee (basis points)
management_fee_bps: u32 // Management fee (basis points)
fee_recipient: ContractAddress // Fee collection addressKey Functions:
deposit(assets: u256) -> u256: Deposit WBTC, receive byWBTC shareswithdraw(shares: u256) -> u256: Burn shares, receive WBTCtotal_assets() -> u256: Total value locked (TVL)rebalance(vesu_bps: u32, troves_bps: u32): Rebalance allocationscollect_fees(): Collect accrued feesemergency_withdraw(): Pull all funds from strategies
Manages deposits/withdrawals to Vesu lending pools.
Key Features:
- Multi-pool support (different Vesu markets)
- ERC4626 vToken integration
- Pool weight management
- Emergency withdrawal per pool
Key Functions:
add_pool(pool_id: felt252, v_token: ContractAddress): Add Vesu pooldeposit(pool_id: felt252, assets: u256) -> u256: Deposit to poolwithdraw(pool_id: felt252, assets: u256) -> u256: Withdraw from poolget_total_assets() -> u256: Total deposited across poolsget_pool_balance(pool_id: felt252) -> u256: Balance in specific pool
Integration with Troves/Endurfi for liquid staking strategies.
Features:
- Liquid staking deposit/withdrawal
- Reward claiming and compounding
- Strategy optimization
Orchestrates yield optimization across protocols.
Features:
- APY calculation and optimization
- Automated rebalancing with threshold triggers
- Multi-protocol allocation management
1. Connect Xverse Wallet
β
2. Initiate Bitcoin Deposit
β
3. Atomiq Bridges BTC β WBTC (Starknet)
β
4. User Approves WBTC to BitYield Vault
β
5. Vault Deposits WBTC, Mints byWBTC Shares
β
6. Vault Automatically Deploys to Vesu/Troves
β
7. Yield Accrues (Lending Interest + Staking Rewards)
β
8. User Withdraws: Burn byWBTC β Receive WBTC
β
9. Optional: Bridge WBTC β BTC via Atomiq
1. Monitor Pool Yields (Vesu vs Troves)
β
2. Call rebalance() to Optimize Returns
β
3. Collect Performance + Management Fees
β
4. Emergency: Pause vault or emergency_withdraw()
This project is built using Scaffold-Stark 2, a modern development stack for Starknet dApps.
System Requirements:
-
Node.js v18+ and Yarn package manager
node --version # Should be v18 or higher yarn --version -
Starknet Development Tools (managed via asdf):
- Scarb v2.12.0 (Cairo package manager)
- Starknet Foundry v0.49.0 (Testing framework)
- Starknet Devnet v0.4.3 (Local node)
git clone https://github.com/CodeBlocker52/BitYield-Protocol
cd BitYield-ProtocolThe project uses asdf to manage Starknet toolchain versions. This ensures everyone uses the same versions.
# Install asdf
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
# Add to shell profile (choose your shell)
# For bash:
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc
source ~/.bashrc
# For zsh:
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.zshrc
source ~/.zshrc# Add Starknet toolchain plugins
asdf plugin add scarb
asdf plugin add starknet-foundry
asdf plugin add starknet-devnet# Install Starknet toolchain versions (reads from .tool-versions)
asdf install
# Verify installations
scarb --version # Should show: scarb 2.12.0
snforge --version # Should show: snforge 0.49.0
starknet-devnet --version # Should show: starknet-devnet 0.4.3
# Install Node.js dependencies for frontend
cd packages/nextjs
yarn install
# Install Node.js dependencies for contracts (if needed)
cd ../snfoundry
yarn installcd packages/snfoundry/contracts
scarb buildThe project includes comprehensive test coverage (92 tests covering all contracts).
# From contracts directory
cd packages/snfoundry/contracts
snforge test# Test specific contract
snforge test test_vault
# Test with verbose output
snforge test -vvv
# Test with gas profiling
snforge test --detailed-resourcessnforge test --coveragecd packages/nextjs
# Start development server
yarn startVisit http://localhost:3000 to see the application.
cd packages/nextjs
# Build for production
yarn build
# Start production server
yarn startTerminal 1: Start Local Node
cd packages/snfoundry
yarn chainTerminal 2: Deploy Contracts
cd packages/snfoundry
yarn deploy --network devnetcd packages/snfoundry
yarn deploy --network sepoliaDeployment Process:
- Deploys VesuAdapter
- Deploys TrovesAdapter
- Deploys StrategyManager
- Deploys BitYieldVault
- Deploys AtomiqBridge
- Configures all contract addresses
- Outputs contract addresses to console
Save the Contract Addresses:
After deployment, update packages/nextjs/contracts/deployedContracts.ts with the new addresses.
cd packages/snfoundry
yarn deploy --network mainnet-
Edit Contracts
# Contracts are in packages/snfoundry/contracts/src/ nano packages/snfoundry/contracts/src/vault.cairo -
Rebuild
cd packages/snfoundry/contracts scarb build -
Run Tests
snforge test -
Update Frontend (if ABI changed)
cd packages/nextjs yarn contracts:sync -
Test Frontend
yarn dev
# Contracts
scarb build # Build contracts
snforge test # Run all tests
snforge test -vvv # Verbose test output
scarb clean # Clean build artifacts
# Frontend
yarn dev # Start dev server
yarn build # Build for production
yarn start # Start production server
yarn lint # Run linter
yarn format # Format code
# Full Stack
yarn chain # Start local devnet
yarn deploy # Deploy contracts
yarn contracts:sync # Sync ABIs to frontend- Navigate to Yield Dashboard (
http://localhost:3000/yield) - Connect Wallet (Argent X, Braavos, or Xverse)
- Approve WBTC for vault spending
- Deposit WBTC to receive byWBTC shares
- Monitor Yield and rebalancing events
- Withdraw by burning byWBTC shares
starkli call \
0x06552bc669d3a53c7223ae7d0d5f47613f5da4fb318f21e5f596cc8a791a3f90 \
total_assets \
--rpc https://starknet-sepolia.public.blastapi.io/rpc/v0_9# 1. Approve WBTC
starkli invoke \
<WBTC_TOKEN_ADDRESS> \
approve \
0x06552bc669d3a53c7223ae7d0d5f47613f5da4fb318f21e5f596cc8a791a3f90 \
u256:1000000 \
--rpc https://starknet-sepolia.public.blastapi.io/rpc/v0_9
# 2. Deposit to vault
starkli invoke \
0x06552bc669d3a53c7223ae7d0d5f47613f5da4fb318f21e5f596cc8a791a3f90 \
deposit \
u256:1000000 \
--rpc https://starknet-sepolia.public.blastapi.io/rpc/v0_9Visit contract pages for UI-based interaction:
Current Test Coverage: 92 Tests - All Passing β
- Vault Tests (16): Deposit, withdraw, pause, fees, multi-user scenarios
- VesuAdapter Tests (24): Pool management, deposits, withdrawals, balances
- TrovesAdapter Tests (24): Strategy management, deposits, withdrawals, rewards
- StrategyManager Tests (28): Rebalancing, yield calculation, authorization
β Deposit Flow
- Zero amount rejection
- First deposit share calculation
- Multiple user deposits
- Share price consistency
β Withdrawal Flow
- Partial withdrawals
- Full withdrawals
- Insufficient shares protection
β Rebalancing
- Owner-only rebalancing
- Authorized rebalancer access
- Time-based rebalancing constraints
- Allocation optimization
β Security
- Unauthorized access prevention
- Zero address validation
- Pause mechanism
- Emergency withdrawals
- β Reentrancy Guards: Prevent reentrancy attacks
- β Pausable: Emergency stop mechanism
- β Ownable: Access control for admin functions
- β Input Validation: Zero amount checks, address validation
- β Safe Math: Cairo 2.0 overflow protection
- β Role-Based Access: Separate owner and rebalancer roles
Monitor these key metrics through the frontend dashboard:
- TVL (Total Value Locked): Total WBTC deposited in vault
- APY: Current annual percentage yield (weighted average)
- Allocation: % distribution between Vesu and Troves
- User Balance: Your byWBTC shares and WBTC value
- Fee Collection: Performance and management fees accrued
Deposit(user, assets, shares)
Withdraw(user, assets, shares)
Rebalance(vesu_bps, troves_bps)
FeeCollected(amount, recipient)
StrategyUpdated(strategy_id, new_target)We welcome contributions! Here's how to get started:
# 1. Fork and clone
git clone https://github.com/CodeBlocker52/BitYield-Protocol
cd BitYield-Protocol
# 2. Install dependencies
asdf install
cd packages/nextjs && yarn install
# 3. Create feature branch
git checkout -b feature/amazing-feature
# 4. Make changes and test
cd packages/snfoundry/contracts
scarb build
snforge test
# 5. Test frontend
cd ../../nextjs
yarn dev
# 6. Commit and push
git add .
git commit -m 'Add amazing feature'
git push origin feature/amazing-feature
# 7. Open Pull Request- Cairo: Follow official Cairo style guide
- TypeScript: Use ESLint and Prettier configurations
- Testing: Add tests for new features
- Documentation: Update README and inline comments
Issue: "No version is set for command scarb"
# Solution: Install asdf and project tools
asdf installIssue: "Module not found" in frontend
# Solution: Reinstall dependencies
cd packages/nextjs
rm -rf node_modules yarn.lock
yarn installIssue: Tests failing after contract changes
# Solution: Rebuild contracts
cd packages/snfoundry/contracts
scarb clean
scarb build
snforge testIssue: Frontend can't connect to contracts
# Solution: Sync ABIs
cd packages/nextjs
yarn contracts:syncMIT License - see LICENSE file for details
- Starknet: starknet.io
- Scaffold-Stark 2: github.com/Scaffold-Stark/scaffold-stark-2
- Vesu Protocol: vesu.xyz
- Troves Protocol: troves.app
- Atomiq Bridge: atomiq.io
- Cairo Book: cairo-book.github.io
- Starknet Foundry: foundry-rs.github.io/starknet-foundry
Starknet Re{solve} Hackathon 2025
- First Bitcoin-native yield aggregator on Starknet
- Seamless UX - No manual bridging/wrapping for users
- Automated optimization via Cairo smart contracts
- Multi-protocol integration (Vesu, Troves, Atomiq)
- ERC4626 compliance for composability
- Comprehensive test coverage (92 tests - 100% passing)
- Integrate additional Troves strategies
- Add more Vesu lending pools
- Implement auto-compounding
- Advanced rebalancing algorithms (ML-based APY prediction)
- Governance token for protocol decisions
- Cross-chain yield opportunities (Bitcoin L2s)
- Mobile app integration (iOS/Android)
- Security audit and mainnet launch
Built with β€οΈ on Starknet for Starknet Re{Solve} Hackathon 2025