Skip to content
This repository was archived by the owner on Dec 2, 2025. It is now read-only.

Rust smart contracts for TrustBridges integration with Blend, enabling decentralized lending via bridged assets. This repository includes the core on-chain logic for managing liquidity pools, oracles, interest rate models, and risk parameters on the Stellar blockchain.

License

Notifications You must be signed in to change notification settings

trustbridgecr/TrustBridge-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

45 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

TrustBridge Smart Contracts

TrustBridge is a decentralized finance (DeFi) protocol built on the Stellar network, providing lending and borrowing functionality with collateral management and backstop mechanisms.

πŸ—οΈ Project Structure

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

πŸš€ Quick Start

1. Prerequisites

  • Rust (1.89.0 or later)
  • Stellar CLI
  • wasm32-unknown-unknown target
rustup target add wasm32-unknown-unknown

2. Deploy All Contracts

# Make script executable
chmod +x tools/deploy-all.sh

# Deploy with your admin address
ADMIN_ADDRESS="YOUR_STELLAR_ADDRESS" ./tools/deploy-all.sh

3. Use Deployed Contracts

# Load contract addresses
source deployment.env

# Interact with contracts
stellar contract invoke --id $TRUSTBRIDGE_ORACLE_ID --source alice --network testnet -- set_price ...

πŸ“– Documentation

πŸ”§ Smart Contracts

Core Contracts

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/

Mock Contracts

Testing contracts located in contracts/mocks/:

  • mock-pool-factory/ - Mock pool factory for testing
  • mock-pool/ - Mock pool for testing
  • moderc3156/ - ERC-3156 flash loan standard mock

πŸ› οΈ Development

Build Individual Contracts

# 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 Tests

# Run contract-specific tests
cd contracts/oracle && cargo test

# Run comprehensive test suite
cd testing/test-suites && cargo test

🌐 Networks

Testnet (Recommended for Development)

NETWORK="testnet" ./tools/deploy-all.sh

Futurenet (Experimental Features)

NETWORK="futurenet" ./tools/deploy-all.sh

Mainnet (Production)

NETWORK="mainnet" ./tools/deploy-all.sh

πŸ“„ Configuration Files

Environment Configuration

  • .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 values

Generated Files

After deployment, the following files are created:

  • deployment.json - Contract addresses and deployment metadata
  • deployment.env - Environment variables for easy sourcing

Git Configuration

  • .gitignore - Comprehensive ignore rules for Rust/Soroban projects
  • .gitattributes - Proper handling of text/binary files

πŸ” Security

  • All contracts have been audited (see audits/ directory)
  • Use testnet for development and testing
  • Keep private keys secure
  • Verify all contract addresses before interacting

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes in the appropriate contracts/ directory
  4. Add tests in testing/test-suites/
  5. Update documentation in docs/
  6. 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

πŸ“ License

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

πŸ”— Links

⚠️ Disclaimer

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.

About

Rust smart contracts for TrustBridges integration with Blend, enabling decentralized lending via bridged assets. This repository includes the core on-chain logic for managing liquidity pools, oracles, interest rate models, and risk parameters on the Stellar blockchain.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 2

  •  
  •