Skip to content

A decentralized Bitcoin-backed yield protocol powered by tokenized Latin American bonds and receivables.

License

Notifications You must be signed in to change notification settings

usecambi/cambi-contracts

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cambi Protocol

A decentralized Bitcoin-backed yield protocol powered by tokenized Latin American bonds and receivables.

Cambi Protocol enables users to earn 7-25% APY on Bitcoin and stablecoins by minting yield-bearing synthetic assets (cmBTC, cmUSD, cmBRL) backed by real-world assets from Latin American markets. Through the innovative Cross-Collateral Yield Optimization Engine (CCYOE), the protocol redistributes excess yields to maximize returns across all users.

Table of Contents

Overview

Cambi Protocol represents a paradigm shift in how Bitcoin & Stablecoin holders access yield and how Latin Americans interact with their wealth. By creating the world's first permissionless Bitcoin-backed yield system powered by Latin American real-world assets, we're expanding El Salvador's Volcano Bonds concept into a more accessible and scalable solution.

Core Components

  • CambiFactory: Central registry managing synthetic assets, collateral types, and CCYOE configuration
  • CambiPositionManager: Handles time-locked collateralized debt positions (CDPs) with enhanced features
  • RebasingSyntheticAsset: Rebasing ERC20 tokens that automatically show growing balances (cmBTC, cmUSD, cmBRL)
  • CCYOEVault: Cross-Collateral Yield Optimization Engine managing yield distribution per asset
  • CambiLens: Comprehensive view contract providing formatted data for frontend applications
  • WrappedRebasingSyntheticAsset: Non-rebasing wrappers for DeFi composability (wcmBTC, wcmUSD, wcmBRL)

Key Features

🏦 Rebasing Synthetic Assets

  • cmBTC: Bitcoin-backed synthetic with 5-8% base yield
  • cmUSD: USD-backed synthetic with 14-18% yield from Brazilian receivables
  • cmBRL: Brazilian Real synthetic with 20-25% yield from local bonds
  • Daily rebasing shows users their balances growing automatically

🔄 Cross-Collateral Yield Optimization Engine (CCYOE)

  • Redistributes excess yields from high-performing assets to boost others
  • Network effects where success in one asset benefits all users
  • Automated rebalancing based on performance thresholds
  • Strategic yield allocation to drive protocol growth

⏰ Time-Locked Staking

  • Minimum lock periods: 90 days for cmBTC/cmUSD/cmBRL, 30 days for others
  • Early withdrawal penalties: 2-5% depending on asset type
  • Extended lock periods for additional yield benefits
  • Emergency withdrawal mechanisms for crisis situations

🌍 Real-World Asset Integration

  • Direct access to Brazilian receivables yielding 14-18% annually
  • Integration with tokenization platforms like Liqi & DUX
  • Ladder maturity management for continuous yield realization
  • USD-denominated receivables eliminate FX exposure for cmUSD

🛡️ Enhanced Security & Risk Management

  • Emergency stop functionality for protocol-wide pauses
  • Over-collateralization with isolated vault architecture
  • Multi-signature controls on RWA purchases
  • Circuit breakers for unusual yield patterns

⚡ DeFi Composability

  • Wrapped versions (wcmBTC, wcmUSD, wcmBRL) for standard DeFi protocols
  • Planned Uniswap V4 liquidation hooks for capital efficiency
  • ERC20 compatibility while maintaining rebasing benefits
  • Yield farming and lending protocol integration

Synthetic Assets

cmBTC - Bitcoin with Yield

  • Yield: 5-8% base + CCYOE boosts
  • Backing: Bitcoin collateral + institutional lending
  • Use Case: Bitcoin hodlers wanting yield without selling
  • Liquidity: Instant cmUSD minting for operational needs

cmUSD - High-Yield Stablecoin

  • Yield: 14-18% from USD-denominated Brazilian receivables
  • Backing: Bitcoin/stablecoin collateral + RWA exposure
  • Use Case: Dollarization for LatAm users, superior DeFi collateral
  • No FX Risk: Receivables denominated in USD or hedge-embedded

cmBRL - Local Currency Hedge

  • Yield: 20-25% from Brazilian bonds and receivables
  • Backing: Bitcoin collateral + local RWA exposure
  • Use Case: Spend in BRL while collateral appreciates
  • Inflation Hedge: Earn above Brazilian inflation rates

Prerequisites

  • Foundry - Ethereum development toolkit
  • Node.js 16+ for frontend integration
  • Understanding of CDP mechanics and rebasing tokens

Installation

  1. Clone the repository:
git clone https://github.com/your-org/cambi-contracts.git
cd cambi-contracts
  1. Install dependencies:
forge install
  1. Set up environment variables:
cp .env.example .env
# Edit .env with your configuration

Usage

Build

Compile the contracts:

forge build

Test

Run the test suite:

forge test

Run tests with gas reporting:

forge test --gas-report

Deploy

Deploy to a network:

FEE_COLLECTOR_ADDRESS=<address> \
PROTOCOL_TREASURY_ADDRESS=<address> \
forge script script/CambiDeploy.s.sol:CambiDeployScript \
--rpc-url <your_rpc_url> \
--private-key <your_private_key> \
--broadcast

Daily Operations

Trigger daily rebase for an asset:

cast send <CAMBI_FACTORY> "triggerRebase(address)" <SYNTHETIC_ASSET> \
--rpc-url <rpc> --private-key <key>

Rebalance CCYOE:

cast send <CAMBI_FACTORY> "rebalanceCCYOE()" \
--rpc-url <rpc> --private-key <key>

Contract Architecture

CambiFactory

Central registry managing all protocol parameters, synthetic assets, and the CCYOE system. Handles asset registration, collateral management, and yield optimization coordination.

Key Functions:

  • Register rebasing synthetic assets with RWA backing
  • Configure CCYOE parameters and rebalancing
  • Manage emergency stops and protocol security
  • Handle collateral and asset relationships

CambiPositionManager

Enhanced CDP manager with time-locked staking and advanced liquidation mechanisms.

Key Functions:

  • Create time-locked positions with custom lock periods
  • Handle early withdrawal with penalties
  • Execute liquidations with Uniswap V4 hooks (planned)
  • Manage emergency withdrawals during crisis

RebasingSyntheticAsset

Rebasing ERC20 implementation that automatically grows user balances through yield accumulation.

Key Functions:

  • Daily rebasing based on vault yield rates
  • Fractional balance tracking for accurate rebasing
  • Yield distribution from CCYOE optimization
  • Rebase history tracking for analytics

CCYOEVault

Individual vault managing yield generation and RWA integration for each synthetic asset.

Key Functions:

  • Invest in Brazilian RWA opportunities
  • Manage maturity ladder for continuous yield
  • Optimize yield distribution strategies
  • Handle emergency RWA withdrawals

CambiLens

Comprehensive view contract providing formatted data access for frontend applications.

Key Functions:

  • Get enhanced position details with time locks
  • Analyze CCYOE performance and optimization
  • Track rebasing token metrics and history
  • Calculate protocol-wide statistics

Protocol Economics

Fee Structure

  • Protocol Fee: 1.5% on withdrawals and position closures
  • Performance Fee: 10% on yields above base rates
  • Early Withdrawal Penalty: 1-5% based on asset type and lock period
  • Emergency Withdrawal Penalty: Additional penalties during emergency mode

CCYOE Distribution

  • 40% to under-supplied assets (asset shortfalls)
  • 30% to strategic growth incentives
  • 20% distributed proportionally to all holders
  • 10% to protocol treasury for security and development

Yield Sources

  • cmBTC: Institutional Bitcoin lending (3-5%) + liquidity premium
  • cmUSD: USD-denominated Brazilian receivables (14-18%)
  • cmBRL: Brazilian fixed income & bonds (20-25%)
  • CCYOE Boosts: Additional yield from cross-asset optimization

Time Lock Benefits

Lock Period Tiers

  • 30-60 days: Base yield rates
  • 90-180 days: +0.5% yield bonus
  • 180-365 days: +1% yield bonus
  • 365+ days: +2% yield bonus + governance voting weight

Early Withdrawal Penalties

  • cmBTC: 5% penalty if withdrawn before 90 days
  • cmUSD: 3% penalty if withdrawn before 90 days
  • cmBRL: 2% penalty if withdrawn before 90 days
  • Emergency Mode: Reduced penalties (50% of normal rates)

RWA Integration

Brazilian Receivables Portfolio

  • E-commerce receivables: 30-day maturity, 15% APR
  • Agricultural exports: 60-day maturity, 18% APR
  • Corporate bonds: 90-day maturity, 20% APR
  • Infrastructure bonds: 1-year maturity, 25% APR

Risk Management

  • Diversified portfolio: 50+ receivables across sectors
  • Ladder maturities: Continuous liquidity through staggered maturities
  • Credit analysis: Traditional + AI-powered risk assessment
  • Insurance buffer: 2% of TVL reserved for defaults

Frontend Integration

Key Contract Interactions

// Get comprehensive protocol data
const protocolInfo = await cambiLens.getProtocolInfo();

// Create time-locked position
const tx = await positionManager.createPosition(
  cmUSDAddress,
  btcAddress,
  collateralAmount,
  mintAmount,
  lockPeriod
);

// Check rebasing token metrics
const metrics = await cambiLens.getRebasingTokenMetrics(cmBTCAddress);

// Preview CCYOE rebalance
const rebalanceData = await cambiLens.previewCCYOERebalance();

WebSocket Events for Real-time Updates

// Listen for rebase events
contract.on('Rebase', (epoch, multiplier, newSupply, yieldRate) => {
  updateUserBalances();
});

// Monitor CCYOE rebalancing
factory.on('CCYOERebalanced', (totalYield, timestamp) => {
  refreshYieldData();
});

Testing

Core Test Categories

  1. Rebasing Mechanics: Token rebasing, yield distribution, balance calculations
  2. Time Lock System: Lock periods, early withdrawal penalties, emergency modes
  3. CCYOE Optimization: Yield redistribution, asset optimization, rebalancing
  4. RWA Integration: Mock provider interactions, yield claiming, emergency withdrawals
  5. Liquidation System: Under-collateralization detection, liquidation execution
  6. Emergency Procedures: Protocol pauses, emergency withdrawals, security measures

Run Specific Test Suites

# Test rebasing functionality
forge test --match-path "test/RebasingTest.sol"

# Test CCYOE system
forge test --match-path "test/CCYOETest.sol"

# Test time locks
forge test --match-path "test/TimeLockTest.sol"

# Integration tests
forge test --match-path "test/IntegrationTest.sol"

Deployment Guide

1. Deploy Core Contracts

# Deploy factory with oracle and fee configuration
forge script script/01_DeployCore.s.sol --broadcast

# Deploy position manager
forge script script/02_DeployPositionManager.s.sol --broadcast

# Deploy lens for frontend integration
forge script script/03_DeployLens.s.sol --broadcast

2. Configure Protocol

# Register synthetic assets
forge script script/04_RegisterAssets.s.sol --broadcast

# Set up collateral types with RWA integration
forge script script/05_SetupCollateral.s.sol --broadcast

# Configure CCYOE parameters
forge script script/06_ConfigureCCYOE.s.sol --broadcast

3. Initialize RWA Providers

# Deploy mock Brazilian RWA provider for testing
forge script script/07_DeployRWAProviders.s.sol --broadcast

# Connect RWA providers to collateral types
forge script script/08_ConnectRWA.s.sol --broadcast

Governance & Upgrades

Protocol Parameters Controlled by Governance

  • CCYOE redistribution ratios and thresholds
  • Time lock periods and early withdrawal penalties
  • Fee structures and performance fee rates
  • Emergency stop triggers and conditions
  • RWA provider approvals and integrations

Upgrade Path

  • Modular architecture allows individual contract upgrades
  • Time-locked governance proposals for parameter changes
  • Emergency procedures for critical security updates
  • Community governance through $CMB token (future)

Security Considerations

Audits & Reviews

  • Initial audit by top-tier security firm
  • Economic model review by DeFi risk specialists
  • RWA integration audit by TradFi experts
  • Ongoing bug bounty program

Risk Mitigation

  • Over-collateralization requirements (150% minimum)
  • Isolated vault architecture prevents contagion
  • Circuit breakers for unusual market conditions
  • Multi-signature controls on critical functions

Contributing

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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow Solidity best practices and style guide
  • Write comprehensive tests for new features
  • Update documentation for any interface changes
  • Ensure gas optimization for user-facing functions

License

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

Disclaimer

Cambi Protocol is experimental software. Users should understand the risks involved in DeFi protocols, RWA integration, and yield-bearing assets. Past performance does not guarantee future results. Please consult with financial advisors before making investment decisions.


Built with ❤️ for the future of global finance

Bridging Bitcoin and Brazilian Real-World Assets

About

A decentralized Bitcoin-backed yield protocol powered by tokenized Latin American bonds and receivables.

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • Solidity 100.0%