How 0xoucan/sonicdeltamasterai works
Main Components
• Input Interfaces:
• Chat Interface (chatbot.ts) used for interactive command inputs.
• Telegram Interface (telegram-interface.ts) for mobile and messaging-based commands.
• Command Processing/Dispatcher:
• This is the central engine that interprets commands (e.g., “delta-neutral-apy” or “execute-delta-neutral 10”) and routes them appropriately.
• Strategy Action Providers:
• Multiple modules under src/action-providers (e.g., aave-supply, delta-neutral, machfi, swrapper, usdce-swapx-beefy, wsswapx-beefy, etc.).
• Each provider contains its business logic and integration points with specific DeFi protocols.
• Strategy Manager:
• A module that may coordinate between different providers to balance portfolio management, execute risk checks, or choose the best yield optimization method.
• External Services and Blockchain Integrations:
• Connections to external protocols/services like Aave, MachFi, Beefy, and potentially SonicScan.
• Token Operations & Balance Checker:
• Modules that handle ERC20 token operations (wrapping, unwrapping, transfers) and portfolio balance validations.
Relationships and Flow
• Incoming requests (via chat or Telegram) are first processed by the Input Layer.
• The command is then sent to the Dispatcher / Command Processing unit.
• The Dispatcher evaluates the command and decides which Action Provider to invoke.
• E.g., a “delta-neutral-apy” command is routed to the corresponding provider that implements either the Aave- or MachFi-based delta neutral strategy.
• The selected Action Provider executes its internal process:
• Reads configuration data, applies strategy-specific constants, and uses inbuilt error handling.
• For strategies involving sequential actions (supply/collateral, borrow, wrap tokens, deploy into vaults), illustrate the command as a flow:
• Start → Supply collateral → Borrow asset → Token wrapping (if required) → Vault deposit → Yield calculation.
• Results and feedback are then returned to the interface (chat/telegram) as a processed response.
Architectural Patterns and Design Principles
• Modularity: The model employs a modular design where each action provider encapsulates distinct strategy logic.
• Flow-Oriented Execution: The system is command-driven – a user issues a command and a clear, sequential flow of execution is triggered.
• Separation of Concerns: Clear separation is evident between the presentation layer (chat/telegram interfaces), the business logic (action providers for strategies), and integrations with external protocols.