Neko Vault

Neko Vault Architecture

Overview

A Neko Vault is an ERC4626-compliant smart contract that serves as the primary user interface for Neko's automated yield strategies. Users deposit a single asset (e.g., ETH, USDC) into a Vault and receive vault shares representing their portion of the underlying assets.

The vault's core function is to delegate the management of its assets to Neko’s DeFAI Multiagent System. This system actively deploys, monitors, and rebalances capital across a variety of DeFi protocols to generate yield on behalf of depositors. The architecture is a hybrid on-chain and off-chain system designed for security, efficiency, and the ability to execute complex, AI-driven strategies.

Core Components

The Neko architecture is composed of distinct on-chain and off-chain systems that work in concert. The on-chain contracts provide non-custodial security for user funds, while the off-chain system provides the intelligence and execution power for complex strategies.

On-Chain Infrastructure (The Vault and its Guards)

These smart contracts are deployed on-chain and directly hold user funds in a non-custodial manner.

  1. Vault (VaultV2.sol) The user-facing entry point. This standard, audited ERC4626 contract is responsible for:

    • Accepting user deposits and issuing vault shares.

    • Processing user withdrawals by redeeming shares for assets.

    • Interacting with a single, paired Adapter to manage its assets.

  2. Adapter (UniversalAdapterEscrow.sol) The on-chain hub for all strategy execution and asset management. Each Vault is paired with its own unique Adapter, which acts as a non-custodial escrow contract. Its responsibilities include:

    • Holding all assets allocated from the Vault.

    • Executing multi-step DeFi strategies via a strict whitelist of approved function calls.

    • Interacting with the Valuer to report the total value of its holdings.

  3. Valuer (UniversalValuerOffchain.sol) An on-chain contract that serves as the source of truth for the total value of a vault's assets. It does not perform calculations itself but instead receives cryptographically signed price updates from an off-chain Keeper Bot. This design allows Neko to support complex assets (like Pendle PTs or concentrated liquidity LP positions) that are difficult to value accurately in real-time on-chain.

The Adapter smart contract will only execute calls to a pre-approved list of contracts and functions, preventing any interaction with unintended protocols.

Off-Chain Intelligence (The DeFAI Worker System)

This is the off-chain "brain" that drives strategy. It is composed of several specialized components that analyze, decide, and execute actions without ever taking custody of funds.

  1. DeFAI Multiagent System (The Strategist) The high-level analytical engine. A swarm of AI models analyzes vast amounts of historical and real-time market data to select the optimal, pre-approved strategy for a given vault. It identifies opportunities but does not execute transactions.

  2. Neko Worker (The Executor) A deterministic, event-driven task processor that automatically manages a vault's on-chain position. Each vault is managed by a dedicated, autonomous Neko Worker (1 vault = 1 worker). The worker's sole job is to execute a predefined strategy playbook with precision and reliability.

  3. State Management Database (The Memory) A comprehensive database that stores the complete state of each vault's position, including its assigned strategy, performance metrics, and on-chain status. This persistence ensures that if a worker restarts, it can resume exactly where it left off.

  4. Execution Layer (The Secure Gateway) A secure, external API service that acts as the final gateway for on-chain execution. Workers do not build or sign transactions directly. Instead, they send high-level commands (e.g., "rebalance," "compound") to the Execution Layer, which is responsible for the final, complex step of building, signing, and broadcasting the on-chain transaction to the Adapter.

How It Works: The Strategy Execution Lifecycle

  1. Deposit & Allocation: A user deposits assets into the Vault. The Vault then transfers these assets to its paired Adapter, where they are held in non-custodial escrow, ready for deployment.

  2. Strategy Selection: The DeFAI Multiagent System analyzes market conditions and assigns a predefined strategy from the State Management Database to the vault's dedicated Neko Worker.

  3. Deterministic Execution Loop: The Neko Worker begins its continuous management loop: a. It fetches the latest on-chain data for its assigned position (e.g., current price, uncollected fees). b. It evaluates this data against the strict, predefined rules of its assigned strategy. c. If an action is required, the worker sends a precise, high-level command (e.g., rebalance) to the secure Execution Layer. d. The Execution Layer translates this command into a specific, whitelisted multicall transaction and broadcasts it to the Adapter contract. e. The on-chain Adapter executes the transaction, interacting with external DeFi protocols on behalf of the user. f. The worker updates the State Management Database with the results and reschedules itself to run again.

  4. Position Valuation: In parallel, an off-chain Keeper Bot continuously calculates the real-time net value of the Adapter's position and submits signed updates to the on-chain Valuer contract, ensuring the vault's share price is always accurate.

Last updated