πŸ“œ Smart Contract Architecture

Smart Contract Architecture

MALGIST smart contracts are designed to separate strategy logic, fund custody, and protocol execution. This separation minimizes risk, improves composability, and simplifies audits.


Core Contracts Overview

User
  ↓
UniversalVault
  ↓
Strategy (read-only)
  ↓
Adapter Registry
  ↓
Protocol Adapters

Each contract has a clearly defined role and limited authority.


1. Strategy Contract

The Strategy contract defines what to do, not how funds move.

Responsibilities:

  • Stores strategy configuration:

    • Target protocols

    • Allocation percentages

    • Risk metadata

  • Read-only during execution

  • Cannot hold or move funds

Key Principle: Strategies are instructions, not executors.


2. UniversalVault

The UniversalVault is the core execution and custody contract.

Responsibilities:

  • Accepts user deposits

  • Holds user funds non-custodially

  • Executes strategies at runtime

  • Routes capital across multiple protocols via adapters

  • Handles fee calculation and accounting

Key Properties:

  • Single vault, multiple strategies

  • Users interact only with this contract

  • No protocol-specific logic inside the vault


3. Adapter Registry

The Adapter Registry manages which protocol adapters are allowed.

Responsibilities:

  • Registers approved adapters

  • Maps protocol identifiers β†’ adapter addresses

  • Prevents unauthorized protocol calls

Why this matters:

  • Limits attack surface

  • Enables controlled expansion of supported protocols

  • Simplifies auditing and governance


4. Protocol Adapters

Protocol Adapters act as translation layers between the vault and external DeFi protocols.

Responsibilities:

  • Implement a standardized adapter interface

  • Convert generic vault instructions into protocol-specific calls

  • Interact directly with external contracts (DEXs, lending, etc.)

Design Benefits:

  • One adapter per protocol

  • Isolated integration risk

  • Easy to add or upgrade protocols


Security & Design Principles

  • Non-custodial: Funds always stay in the vault

  • Least privilege: Each contract has minimal authority

  • Composable: New strategies and adapters can be added independently

  • Auditable: Clear boundaries reduce contract complexity


➑️ Next: Execution Flow (step-by-step transaction lifecycle)

Last updated