TrustBridge is a decentralized finance (DeFi) protocol built on the Stellar network, providing lending and borrowing functionality with collateral management and backstop mechanisms.
TrustBridge-contracts/
βββ contracts/ # All smart contracts
β βββ oracle/ # Price feed oracle (SEP-40)
β βββ pool-factory/ # Factory for creating lending pools
β βββ backstop/ # Backstop mechanism for pool security
β βββ pool/ # Main lending pool contract
β βββ tbrg-token/ # TrustBridge governance token
β βββ mocks/ # Mock contracts for testing
βββ tools/ # Deployment and utility scripts
β βββ deploy-all.sh # Complete deployment automation
β βββ scripts/ # Additional utility scripts
βββ testing/ # Test suites and fixtures
βββ docs/ # Documentation
βββ audits/ # Security audit reports
βββ Cargo.toml # Workspace configuration
- Rust (1.89.0 or later)
- Stellar CLI
- wasm32-unknown-unknown target
rustup target add wasm32-unknown-unknown# Make script executable
chmod +x tools/deploy-all.sh
# Deploy with your admin address
ADMIN_ADDRESS="YOUR_STELLAR_ADDRESS" ./tools/deploy-all.sh# Load contract addresses
source deployment.env
# Interact with contracts
stellar contract invoke --id $TRUSTBRIDGE_ORACLE_ID --source alice --network testnet -- set_price ...- Complete Deployment Guide - Step-by-step deployment instructions
- Architecture Overview - Contract architecture and interactions
| Contract | Description | Location |
|---|---|---|
| Oracle | SEP-40 price feed oracle | contracts/oracle/ |
| Pool Factory | Creates and manages lending pools | contracts/pool-factory/ |
| Backstop | Backstop mechanism for pool security | contracts/backstop/ |
| Pool | Main lending/borrowing pool | contracts/pool/ |
| TBRG Token | TrustBridge governance token | contracts/tbrg-token/ |
Testing contracts located in contracts/mocks/:
mock-pool-factory/- Mock pool factory for testingmock-pool/- Mock pool for testingmoderc3156/- ERC-3156 flash loan standard mock
# Build oracle
cd contracts/oracle && cargo build --target wasm32-unknown-unknown --release
# Build all contracts in dependency order
./tools/deploy-all.sh # This also builds everything# Run contract-specific tests
cd contracts/oracle && cargo test
# Run comprehensive test suite
cd testing/test-suites && cargo testNETWORK="testnet" ./tools/deploy-all.shNETWORK="futurenet" ./tools/deploy-all.shNETWORK="mainnet" ./tools/deploy-all.sh.env.example- Template for environment variables.env- Your local environment variables (create from .env.example)
# Setup environment
cp .env.example .env
# Edit .env with your valuesAfter deployment, the following files are created:
deployment.json- Contract addresses and deployment metadatadeployment.env- Environment variables for easy sourcing
.gitignore- Comprehensive ignore rules for Rust/Soroban projects.gitattributes- Proper handling of text/binary files
- All contracts have been audited (see
audits/directory) - Use testnet for development and testing
- Keep private keys secure
- Verify all contract addresses before interacting
- Fork the repository
- Create a feature branch
- Make your changes in the appropriate
contracts/directory - Add tests in
testing/test-suites/ - Update documentation in
docs/ - Submit a pull request
Notes for contributors:
- Under no circumstances should the "overflow-checks" flag be removed otherwise contract math will become unsafe
- Follow the existing code style and patterns
- Ensure all tests pass before submitting
This project is licensed under the AGPL-3.0 License - see the LICENSE file for details.
This software is provided "as is" without warranty. Use at your own risk. Always test thoroughly on testnets before mainnet deployment.
For detailed deployment instructions, see docs/DEPLOYMENT.md.