Skip to main content

OctoPos Architecture

System Overview

Layers

LayerNameResponsibility
1ConnectorsSDK wrappers for Soroban RPC, Horizon, DeFiLlama, protocol APIs
2AdaptersProtocol-specific position extraction (Blend, Aquarius, SoroSwap, Phoenix, FxDAO, StellarWallet, UntangledVaults)
3FeedsPrice data from 6-source priority chain (Aquarius → Wrapped Asset → Blend Oracle → StellarExpert → DeFiLlama → Untangled Vault)
3bResolversToken symbol & contract type resolution
3cIntrospectionOn-chain contract state reading (reserves, TVL)
4DataMongoDB models, OHLC aggregation, health monitoring
5ServicesOrchestration (AggregatorService), pricing (UnifiedPricingService), health alerts
6APIREST endpoints, API key auth, rate limiting, Gzip compression

Design Principles

  1. Mainnet-only — No testnet support. Stellar mainnet prices and contracts only.
  2. YAML-driven config — Token addresses, pool configs, and thresholds live in tokens.yaml, not in code.
  3. Priority feed chain — 6 price feeds tried in order; first non-null result wins with cross-validation.
  4. Plugin-first extensibility — New protocols added via drop-in TypeScript plugins; no core changes.
  5. Lazy registration — Built-in adapters/feeds registered on first use to keep startup fast.
  6. Tiered aggregation — Raw snapshots (60s) → hourly OHLC → daily OHLC for space-efficient history.
  7. Resilient — Each adapter/feed is independent; failures are isolated and health-monitored with Slack alerts.
  8. G-address resolution — C-addresses (Soroban contracts) are probed to detect type and resolve underlying G-addresses.

Data Flow

Price Feed Chain

Tracker Loop

MongoDB Collections

CollectionPurposeTTL
octopos_position_snapshotsFull portfolio snapshots (historical)90 days
octopos_position_statesCurrent position stateNone
octopos_event_logsLifecycle events (deposit, liquidation, etc.)1 year
octopos_price_cacheCached token prices5 minutes
octopos_source_healthPer-adapter health metrics30 days
octopos_hourly_aggregatesHourly OHLC rollups90 days
octopos_daily_aggregatesDaily OHLC rollupsPermanent
octopos_contract_typesResolved Soroban contract typesNone
octopos_tracked_addressesAddresses configured for trackingNone
octopos_api_keysAPI key authentication recordsNone