Smart Contracts Overview

Nester's on-chain logic runs on Stellar's Soroban platform using Rust smart contracts.

Contract Architecture

┌────────────────────────────────────────────────────────┐
│                    VaultFactory                         │
│  deploy_vault() → creates new Vault instance           │
│  list_vaults() → returns all active vaults             │
│  pause_vault() / unpause_vault()                       │
└────────────────────────┬───────────────────────────────┘
                         │ deploys
         ┌───────────────┼───────────────┐
         ▼               ▼               ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Conservative │ │   Balanced   │ │    Growth    │
│    Vault     │ │    Vault     │ │    Vault     │
│              │ │              │ │              │
│ deposit()    │ │ deposit()    │ │ deposit()    │
│ withdraw()   │ │ withdraw()   │ │ withdraw()   │
│ get_position │ │ get_position │ │ get_position │
│ rebalance()  │ │ rebalance()  │ │ rebalance()  │
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘
       │                │                │
       └────────────────┼────────────────┘
                        │ uses
         ┌──────────────┼──────────────┐
         ▼              ▼              ▼
┌──────────────┐ ┌────────────┐ ┌────────────┐
│ Blend        │ │ Kamino     │ │ Aave       │
│ Adapter      │ │ Adapter    │ │ Adapter    │
│              │ │            │ │            │
│ deposit()    │ │ deposit()  │ │ deposit()  │
│ withdraw()   │ │ withdraw() │ │ withdraw() │
│ balance_of() │ │ balance_of │ │ balance_of │
└──────────────┘ └────────────┘ └────────────┘

Workspace Structure

bash
packages/contracts/
├── Cargo.toml            # Workspace manifest
├── vault/
│   ├── Cargo.toml
│   └── src/lib.rs        # Core vault logic
├── vault_token/
│   ├── Cargo.toml
│   └── src/lib.rs        # nVault share token (SEP-41)
├── vault_factory/
│   ├── Cargo.toml
│   └── src/lib.rs        # Factory for deploying vaults
├── yield_registry/
│   ├── Cargo.toml
│   └── src/lib.rs        # Approved yield source registry
├── strategy/
│   ├── Cargo.toml
│   └── src/lib.rs        # Allocation strategy engine
├── escrow/
│   ├── Cargo.toml
│   └── src/lib.rs        # Off-ramp escrow/settlement
└── adapters/
    ├── blend/src/lib.rs   # Blend protocol adapter
    └── ...