Skip to content

GameChangable/astraport-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AstraPort Smart Contracts

Rust Soroban SDK License

AstraPort Smart Contracts are built on Stellar's Soroban framework, enabling decentralized portfolio management with automated rebalancing, event-driven actions, and staking capabilities.


πŸ“‚ Repository Structure

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

πŸ”‘ Smart Contract Modules

1. Rebalancing Contract

Manages portfolio rebalancing and allocation adjustments.

Key Functions:

  • initialize() - Initialize the contract
  • rebalance(portfolio_id) - Execute portfolio rebalancing
  • get_status(portfolio_id) - Query rebalancing status

Use Cases:

  • Automated portfolio rebalancing
  • Target allocation management
  • Drift correction

2. Events Contract

Emits and manages events on portfolio changes with AI analysis triggers.

Key Functions:

  • initialize() - Initialize the contract
  • emit_event(portfolio_id, change_type) - Trigger portfolio change events
  • subscribe(portfolio_id, subscriber) - Subscribe to events
  • unsubscribe(portfolio_id, subscriber) - Unsubscribe from events

Use Cases:

  • Portfolio change notifications
  • AI analysis triggers
  • Event-driven automation

3. Staking Contract

Manages asset staking with alert thresholds and balance monitoring.

Key Functions:

  • initialize() - Initialize the contract
  • stake(staker, amount) - Stake assets
  • unstake(staker, amount) - Unstake assets
  • get_balance(staker) - Query staking balance
  • set_alert_threshold(threshold) - Configure alert thresholds

Use Cases:

  • Asset staking and yield generation
  • Balance monitoring
  • Threshold-based alerts

πŸš€ Quick Start

Prerequisites

  • Rust 1.75.0 or higher
  • Soroban CLI 21.5.0 or higher
  • Node.js 18+ (optional, for example utilities)

Installation

  1. Clone the repository

    git clone https://github.com/FoxAIhelper/astraport-contracts.git
    cd astraport-contracts
  2. Install Rust (if not already installed)

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    source $HOME/.cargo/env
  3. Install Soroban CLI

    cargo install soroban-cli
  4. Add WASM target

    rustup target add wasm32-unknown-unknown
  5. Build contracts

    cargo build

πŸ”¨ Development

Build Contracts

Debug build:

cargo build

Release build (optimized for WASM):

soroban contract build --package astraport-rebalancing
soroban contract build --package astraport-events
soroban contract build --package astraport-staking

Running Tests

All tests:

cargo test

Specific contract tests:

cargo test -p astraport-rebalancing
cargo test -p astraport-events
cargo test -p astraport-staking

With verbose output:

cargo test -- --nocapture

Code Quality

Format code:

cargo fmt

Check for linting issues:

cargo clippy

πŸ“š Documentation


🌐 Deployment

Testnet Deployment

soroban contract build --package astraport-rebalancing
soroban contract deploy \
  --wasm target/wasm32-unknown-unknown/release/astraport_rebalancing.wasm \
  --source testuser \
  --network testnet

Mainnet Deployment

soroban contract build --package astraport-rebalancing
soroban contract deploy \
  --wasm target/wasm32-unknown-unknown/release/astraport_rebalancing.wasm \
  --source mainuser \
  --network mainnet

πŸ›‘οΈ Security

  • 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]

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

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

πŸ“„ License

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


πŸ“ž Support

For questions and support:

  • Open an issue on GitHub
  • Check the docs folder for detailed guides
  • Review examples in the examples/ directory

πŸ”— Links

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages