AI+DeFi: Analyzing DeFai technology architecture and security challenges

Decentralized Finance (Decentralized Finance) Since the last Decentralized Finance Summer, a prosperous and open new financial ecosystem has been created through Smart Contracts. However, with the development of Decentralized Finance, many Decentralized Finance protocols have become increasingly complex, and the knowledge required to understand the related protocols has also become higher. This makes it difficult for many ordinary users to clearly understand the risks of protocols and interact with Decentralized Finance protocols safely.

From the end of 2024, AI Agent has become a hot topic in the on-chain ecosystem, and the combination of Decentralized Finance and AI (DeFai) is attempting to innovate in the Decentralized Finance space: Ordinary users can simplify the interaction process of Decentralized Finance and optimize their trading decisions through AI, transforming Decentralized Finance into a more user-friendly, intelligent, and efficient financial ecosystem. In this article, Beosin will take everyone to understand the operation mode of DeFai and the security challenges it faces, providing users with a clearer risk awareness.

DeFai Technical Architecture

In blockchain, AI Agent can serve as an intermediary interface between users and the Decentralized Finance protocol, replacing users to interact with Smart Contracts, handling complex contract calls without the need for users to continuously operate manually. By studying DeFai projects in the market, we categorize the architecture of such projects into the following key components:

1 Account Management

1.1 Smart Account (ERC-4337)

Traditional EOA accounts do not separate asset custody from trade signing - the same account that holds the funds must sign each trade. Smart accounts following ERC-4337 separate asset custody from trade authorization through programmable verification logic, allowing for safe delegation of trade execution to an AI Agent while keeping the account non-custodial.

When users interact with such DeFai systems, the system will create a smart account associated with the user’s own EOA account. This smart account is fully owned and controlled by the user and represents the user in executing complex transactions.

1.2 Multi-signature Threshold (MPC-TSS)

For semi-autonomous DeFai applications, MPC-TSS can split the key between the AI Agent, user, and trusted third party, while allowing the user to maintain a certain level of control over the AI Agent.

1.3 Trusted Execution Environment (TEE)

For fully autonomous AI systems, TEE provides a secure solution, storing the private key in a secure encrypted environment, allowing the AI Agent to execute transactions on behalf of the user in a trusted and protected environment without third-party interference.

Each of the above three solutions has its advantages and disadvantages. Smart accounts and MPC solutions are secure and controllable, but their operations are limited by predefined rules and permissions. TEE solutions offer more freedom, but require the project party to solve hardware-level issues.

2 Decision Execution Module

This module acts as an interface between AI Agent and the Decentralized Finance ecosystem, interacting with external protocols through a standardized abstraction layer, converting market data and user instructions into actionable blockchain transactions.

This process involves multiple stages:

The first stage is data aggregation, where the AI Agent needs to process continuously incoming information from on-chain data, Decentralized Finance protocol, and the market. This data needs to be processed and input into this module in a standardized format.

Read contract data

The second stage is evaluation decision-making, the system can identify opportunities that meet user goals based on the data from the first stage, combined with traditional financial algorithms and AI, such as APR prediction system, event-driven Meme token trading system. This helps AI Agent optimize the timing of holding positions and the selection of trading targets.

In the third stage, the AI Agent translates previous decisions and user instructions into specific on-chain operations, which have specified exact transaction parameters (contract address, token quantity, etc.), as shown in the following figure:

Create Uniswap V3 liquidity pool

3 Risk Management Module

For the DeFi protocol, developers need to implement multiple layers of protection to ensure the security of user funds and reduce the risks associated with obtaining Decentralized Finance returns. This risk module should run 24/7, taking into account factors such as Smart Contract security, governance risks, liquidity risks, price impact, volatility, and historical reliability of different Decentralized Finance protocols.

For users, DeFai allows them to efficiently interact with multi-chain Decentralized Finance ecosystems without needing to research the specific details of each chain, protocol, and ecosystem.

Security Risks

The construction of DeFai is based on the existing Decentralized Finance protocol, so in addition to the system risks of the DeFai protocol itself (account management, risk control management), users also need to pay attention to the following potential security risks when using DeFai to manage encrypted assets:

1. Market Risk

Trading Slippage/MEV Attack

When the AI Agent conducts token exchange or AMM liquidity provision in the liquidity pool, there may be significant slippage in token exchange or LP creation due to the liquidity issue of the original pool, or be attacked by MEV robots, resulting in trading losses. Below is a case where a user lost approximately $210,000 due to MEV attack when exchanging USDC for USDT:

Liquidity Risk

During periods of significant market volatility, the liquidity of Decentralized Finance protocol (especially lending protocol) may be restricted, potentially affecting user deposits or withdrawals.

2. Protocol Risk

Smart Contract Risks

Each Decentralized Finance protocol interacting with the AI Agent operates based on Smart Contracts, and the contracts may contain undiscovered vulnerabilities. Decentralized Finance protocols should undergo thorough security audits to enhance the security of the protocol as much as possible.

Protocol Design Risks

The operation mechanism and economic model of Decentralized Finance protocol may result in defaults or other unexpected outcomes in extreme market conditions, leading to asset losses for users.

The recent liquidation event of HyperLiquid resulted in a loss of approximately $4 million for the protocol treasury and its providers. The flaw lies in the fact that the project party did not carefully consider the maintenance margin and maximum leverage for large positions. Arbitrageurs/attackers exploited high leverage to breach positions, and the protocol treasury bore the loss from the breach.

Oracle Risk/Price Manipulation

Decentralized Finance protocol may rely on manipulated or technically problematic oracle price feeds, leading to incorrect price information, such as the Polter Finance incident that resulted in a loss of over $7 million. This Decentralized Finance project relied on the easily manipulable token reserves of the UniswapV2 Pair for price calculations. Hackers inflated the project token price through flash loans, borrowing assets far exceeding their collateral value.

Summary

With the continuous development of Decentralized Finance, the financial industry will enter a more user-friendly, intelligent, and efficient new stage. The deep integration of AI in the field of Decentralized Finance will greatly simplify user interaction processes, optimize risk management, and achieve seamless on-chain interaction experience. In this stage, whether you are a seasoned player in Decentralized Finance or a novice, you can easily access on-chain information, manage assets, and securely execute various on-chain operations with the help of DeFai tools.

At the same time, the security risks of the DeFai system cannot be ignored: the management of account private keys, risk control in executing transactions, and various third-party risks of Decentralized Finance protocols are all affecting the security of user assets. Users should choose DeFai projects that have undergone rigorous auditing and market testing to minimize fund risks.

DEFI-0,01%
View Original
This page may contain third-party content, which is provided for information purposes only (not representations/warranties) and should not be considered as an endorsement of its views by Gate, nor as financial or professional advice. See Disclaimer for details.
  • Reward
  • Comment
  • Repost
  • Share
Comment
0/400
No comments
  • Pin

Trade Crypto Anywhere Anytime
qrCode
Scan to download Gate App
Community
  • 简体中文
  • English
  • Tiếng Việt
  • 繁體中文
  • Español
  • Русский
  • Français (Afrique)
  • Português (Portugal)
  • Bahasa Indonesia
  • 日本語
  • بالعربية
  • Українська
  • Português (Brasil)