AstraPort Smart Contracts are built on Stellar's Soroban framework, enabling decentralized portfolio management with automated rebalancing, event-driven actions, and staking capabilities.
astraport-contracts/
βββ contracts/ # Smart contract crates
β βββ rebalancing/ # Portfolio rebalancing contract
β βββ events/ # Event management contract
β βββ staking/ # Asset staking contract
βββ docs/ # Comprehensive documentation
β βββ ARCHITECTURE.md # Contract architecture & design
β βββ DEVELOPMENT.md # Development setup & guidelines
βββ examples/ # Usage examples
βββ tests/ # Integration tests
βββ Cargo.toml # Workspace configuration
βββ rust-toolchain.toml # Rust version specification
βββ README.md # This file
Manages portfolio rebalancing and allocation adjustments.
Key Functions:
initialize()- Initialize the contractrebalance(portfolio_id)- Execute portfolio rebalancingget_status(portfolio_id)- Query rebalancing status
Use Cases:
- Automated portfolio rebalancing
- Target allocation management
- Drift correction
Emits and manages events on portfolio changes with AI analysis triggers.
Key Functions:
initialize()- Initialize the contractemit_event(portfolio_id, change_type)- Trigger portfolio change eventssubscribe(portfolio_id, subscriber)- Subscribe to eventsunsubscribe(portfolio_id, subscriber)- Unsubscribe from events
Use Cases:
- Portfolio change notifications
- AI analysis triggers
- Event-driven automation
Manages asset staking with alert thresholds and balance monitoring.
Key Functions:
initialize()- Initialize the contractstake(staker, amount)- Stake assetsunstake(staker, amount)- Unstake assetsget_balance(staker)- Query staking balanceset_alert_threshold(threshold)- Configure alert thresholds
Use Cases:
- Asset staking and yield generation
- Balance monitoring
- Threshold-based alerts
- Rust 1.75.0 or higher
- Soroban CLI 21.5.0 or higher
- Node.js 18+ (optional, for example utilities)
-
Clone the repository
git clone https://github.com/FoxAIhelper/astraport-contracts.git cd astraport-contracts -
Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env
-
Install Soroban CLI
cargo install soroban-cli
-
Add WASM target
rustup target add wasm32-unknown-unknown
-
Build contracts
cargo build
Debug build:
cargo buildRelease build (optimized for WASM):
soroban contract build --package astraport-rebalancing
soroban contract build --package astraport-events
soroban contract build --package astraport-stakingAll tests:
cargo testSpecific contract tests:
cargo test -p astraport-rebalancing
cargo test -p astraport-events
cargo test -p astraport-stakingWith verbose output:
cargo test -- --nocaptureFormat code:
cargo fmtCheck for linting issues:
cargo clippy- Architecture Guide - Contract design patterns and security considerations
- Development Guide - Setup, building, testing, and deployment instructions
- Usage Examples - Example implementations and patterns
soroban contract build --package astraport-rebalancing
soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/astraport_rebalancing.wasm \
--source testuser \
--network testnetsoroban contract build --package astraport-rebalancing
soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/astraport_rebalancing.wasm \
--source mainuser \
--network mainnet- All contracts use
#![no_std]to minimize attack surface - Input validation required for all public functions
- Access control mechanisms recommended for sensitive operations
- Regular security audits recommended before mainnet deployment
- Report security issues to: [security contact to be added]
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
For questions and support:
- Open an issue on GitHub
- Check the docs folder for detailed guides
- Review examples in the examples/ directory