Перейти к содержанию
Версия: 3.3.51 Обновлено: 2026-01-23

Investment Lifecycle Architecture

Обзор

UPDATED: 2025-11-03 - Mobile-First MVP

Документация жизненного цикла инвестиций в Saga DeFi Platform - mobile-first MVP с auto-approve flow и multi-network test support.

Investment Flow Overview

High-Level Architecture (Integration-Only MVP)

stateDiagram-v2
    [*] --> Deposit: User deposits via Crypto2B
    Deposit --> CREATE: Auto-Invest enabled
    CREATE --> ACTIVE: Auto-Approve (immediate)
    ACTIVE --> COMPLETED: Yield accrued
    ACTIVE --> WITHDRAWN: User withdraws
    COMPLETED --> WITHDRAWN: User withdraws

    note right of CREATE
        - NO PENDING STATE
        - NO BLOCKCHAIN INTERACTION
        - AUTO-INVEST on deposit
    end note

    note right of WITHDRAWN
        - Withdrawal via Fordefi
        - From general balance
    end note

Key Principles:

  • NO PENDING STATE: Investments immediately "active"
  • NO BLOCKCHAIN INTERACTION: Crypto2B + Fordefi handle all crypto operations
  • AUTO-INVEST: Automatic investment creation on deposit
  • WITHDRAWAL: From general balance (not specific investment)

MVP Implementation

Key Files

Backend:

  • backend/shared/routing/user_api_router.go - Auto-invest deposit handler (lines ~550-580)
  • backend/shared/services/canonical/investment_service.go - Auto-approve logic (status="active")
  • backend/shared/services/multi_network_test_provider.go - Multi-network TEST address generation

Frontend:

  • frontend/user-app/src/components/dashboard/MobileDashboard.tsx - Main mobile-first container
  • frontend/user-app/src/components/dashboard/DepositSection.tsx - Multi-network deposits + auto-invest toggle
  • frontend/user-app/src/components/dashboard/WithdrawalSection.tsx - Withdrawal from general balance
  • frontend/user-app/src/components/dashboard/PortfolioSection.tsx - Portfolio overview with strategy chart
  • frontend/user-app/src/components/modals/TransactionDetailsModal.tsx - Investment details modal

MVP Flow

  1. Deposit → User deposits via multi-network TEST address (Tron/EVM/Solana)
  2. Auto-Invest → Automatic investment creation on deposit (10% APY)
  3. Investment Status → Immediately "active" (no pending, no blockchain interaction)
  4. Yield Config → APY configured in config/limits.yaml (10% MVP)
  5. Withdrawal → From general balance (not specific investment)

Database Changes

Users Table (Auto-Invest Fields):

auto_invest_enabled BOOLEAN DEFAULT TRUE,
auto_invest_strategy VARCHAR(20) DEFAULT 'conservative'

Investments Table (Status Flow):

  • CREATE → status='active' (immediate, no pending)
  • User withdrawal → status='completed'

Multi-Network Support:

  • wallets.network_id INTEGER (1=Tron, 2=EVM, 3=Solana)
  • TEST address formats documented in docs/developers/testing/multi-network-test-addresses.md