No history yet

DeFAI Architecture Foundations

The DeFAI Stack

To move beyond simple automation and build truly autonomous on-chain actors, we need a structured approach. Think of it like building a skyscraper. You don't just start throwing bricks together; you lay a foundation and build up, layer by layer. The Decentralized Finance AI (DeFAI) stack provides this structure, organizing the system into four modular layers.

This modular design allows each component to be developed and upgraded independently, creating a more robust and flexible system.

  • The Data Layer: This is the agent's sensory input. It ingests a constant stream of information from both on-chain and off-chain sources. On-chain data includes everything from real-time activity and smart contract state changes to historical transaction records. Off-chain data can be anything from crypto news APIs and social media sentiment to traditional financial market data.

  • The Intelligence Layer: This is the brain of the operation. It takes the raw data from the layer below, analyzes it, and formulates a strategy. This is where a (LLM) or other reasoning engine lives. It plans the necessary steps to achieve a goal, adapting its strategy based on new information.

  • The Abstraction Layer: This is the user-friendly interface. Instead of requiring users to craft complex, multi-step transactions, it allows them to state their goals in simple terms—a concept known as intent-based interaction. For example, a user might state, "Get me the highest possible yield on 10 ETH, but don't expose more than 20% to protocols with less than $10M in liquidity." The agent figures out the how.

  • The Execution Layer: These are the agent's hands. Once the Intelligence Layer decides on a course of action, the Execution Layer translates that plan into concrete on-chain transactions. It uses libraries like Viem or Ethers.js to interact directly with smart contracts, sign transactions, and broadcast them to the network.

Agents vs Bots

It's easy to mistake a DeFAI agent for a sophisticated trading bot, but there's a fundamental difference. A traditional trading bot operates on a rigid, pre-programmed set of rules. It executes if-then logic: if the price of ETH hits $3,500, then sell.

Bots follow scripts. Agents form strategies.

An autonomous agent, powered by the DeFAI stack, is far more dynamic. It perceives its environment through the Data Layer, reasons and learns from outcomes in the Intelligence Layer, and acts on-chain through the Execution Layer. If its initial strategy fails or market conditions change unexpectedly, it can form a new plan without human intervention. It can combine multiple tools, like swapping on Uniswap, borrowing on Aave, and bridging to another chain, all to fulfill a single, high-level intent.

FeatureTraditional Trading BotAutonomous AI Agent
LogicPre-programmed, rule-basedAdaptive, goal-oriented
EnvironmentLimited to specific data pointsIngests broad on-chain & off-chain data
ActionsExecutes single, defined tasksComposes complex, multi-step actions
AdaptabilityRigid; requires manual updatesLearns and adapts to new conditions

Agentic Frameworks for Web3

Building these agents from scratch is a complex task. That's where come in. These are toolkits that provide the core components for building autonomous agents, simplifying the development process. Frameworks like LangChain, Autonolas, and CrewAI offer pre-built modules for memory, planning, and tool use.

In the context of Web3, these frameworks are extended with specialized tools for on-chain interaction. For example, an agent might be equipped with a "tool" that allows it to query the balance of any wallet, another for swapping tokens on a DEX, and a third for checking gas fees. The Intelligence Layer then learns how and when to combine these tools to achieve its goals.

Agentic AI frameworks add a decision-making orchestrator embedded with external tools, including web search, Python interpreter, contextual database, and others, on top of monolithic LLMs, turning them from passive text oracles into autonomous problem-solvers that can plan, call tools, remember past steps, and adapt on the fly.

By combining a flexible, layered architecture with powerful agentic frameworks, DeFAI moves us from simple, automated scripts to a new paradigm of intelligent, autonomous on-chain actors.

Ready to test your knowledge?

Quiz Questions 1/5

Which layer of the DeFAI stack is responsible for translating a user's high-level goal, such as "get me the highest possible yield on 10 ETH," into actionable steps?

Quiz Questions 2/5

What is the primary advantage of using an agentic framework like LangChain or Autonolas when building a DeFAI agent?