Skip to main content

OctoPos Architecture

System Overview

OctoPos is a modular platform with four interconnected services that work together to provide comprehensive DeFi intelligence on Stellar.

Core Services

Position Tracker

The Position Tracker continuously monitors user positions across Stellar DeFi protocols.

Responsibilities:

  • Collect positions every 60 seconds from all supported protocols
  • Price positions using a 6-feed priority chain
  • Store snapshots and maintain historical data
  • Monitor data source health

Data Collections:

CollectionPurpose
position_snapshotsFull portfolio snapshots (90-day TTL)
position_statesCurrent position state
event_logsLifecycle events (1-year TTL)
price_cacheCached token prices (5-min TTL)
source_healthData source health metrics

Risk Monitoring Service (RMS)

RMS continuously evaluates positions across Blend, Aquarius, SoroSwap, Phoenix, FxDAO, and other protocols for risk conditions and triggers notifications.

Risk Levels:

LevelHealth FactorDescription
healthy≥ 1.50Position is healthy
warn1.25 – 1.50Attention recommended
alert1.10 – 1.25Action recommended
emergency< 1.10Immediate action required

Risk Triggers:

TriggerDescription
low_health_factorHealth factor below threshold
oracle_stalePrice oracle data is outdated
oracle_price_manipulationPotential price manipulation detected
pool_utilization_highPool utilization exceeds safe limits
pool_freezePool operations have been paused
borrow_apr_spikeBorrow rate increased significantly
collateral_depegCollateral asset losing peg stability
collateral_liquidity_lowInsufficient liquidity for liquidation

Transaction Builder (TxB)

TxB builds optimized Soroban transactions for position management.

Supported Operations:

OperationDescription
REPAYRepay borrowed assets to improve health factor
LIQUIDATELiquidate undercollateralized position
UNWINDClose entire position (withdraw + repay)

Features:

  • Real Soroban SDK integration
  • Transaction simulation before submission
  • Slippage protection (configurable BPS)
  • TTL bumping for safety margin
  • Resource footprint optimization

Notification Service (NS)

NS delivers risk alerts through multiple channels with retry logic.

Supported Channels:

ChannelSetup
TelegramBot token + chat ID
DiscordWebhook URL
EmailSMTP configuration

Features:

  • Alert cooldowns to prevent spam
  • Dead letter queue for failed deliveries
  • Priority routing (normal/urgent)
  • Per-user notification preferences

Design Principles

  1. Mainnet-only — All operations target Stellar mainnet
  2. Resilient — Services are independent; failures are isolated
  3. Configurable — Thresholds and settings are user-defined
  4. Extensible — New protocols and feeds can be added
  5. Observable — Health monitoring and logging throughout

Data Flow

Position Collection Loop

Risk Evaluation Loop

Transaction Building Flow