Back to Case Studies

DeFi Protocol Integrations for an AI-Powered Blockchain Platform

DeFAIBlockchainTypeScriptDeFiCEX Integration

I built 8 protocol integrations for HeyAnon, a DeFAI platform where users interact with DeFi protocols and centralized exchanges through natural language. Each integration translates plain English commands into deterministic, schema-validated blockchain transactions.

Client: HeyAnon AI

The Challenge

Decentralized finance protocols handle billions in value, but interacting with them requires technical knowledge that most users don't have. Swapping tokens, providing liquidity, staking, borrowing against collateral: each operation involves multiple contract calls, slippage calculations, gas estimation, and approval flows. A single mistake can mean lost funds with no recourse.

HeyAnon set out to solve this by building a DeFAI platform: an AI agent that lets users describe what they want in plain language and executes the blockchain transactions for them. Say "swap 1000 USDC for ETH on Beets, then stake the ETH as collateral on a lending protocol, borrow USDT against it, and stake the borrowed USDT" and the agent orchestrates the entire multi-step flow.

The challenge is that blockchain transactions are irreversible. An LLM that hallucinates a contract address or miscalculates a swap amount doesn't just return a wrong answer; it loses real money. HeyAnon's AUTOMATE framework addresses this by enforcing schema-based, deterministic logic for every on-chain interaction. Each protocol integration is a TypeScript module that defines exactly which operations are possible, what parameters they accept, and how they validate inputs before signing any transaction.

My job was to build these integrations: the bridge between the AI agent's natural language understanding and the actual blockchain protocols.

Solution Approach

The AUTOMATE Framework

Each integration follows a strict modular architecture. Every protocol gets its own TypeScript module with two types of functions: action functions (which execute transactions like swaps, stakes, and deposits) and getter functions (which retrieve data like balances, positions, and pool information). Both are exposed to the AI agent as tool definitions with typed schemas, so the LLM knows exactly what parameters each operation requires and what formats are valid. This eliminates an entire class of hallucination risks: the agent can't invent parameters that don't exist or pass values in wrong formats because the schema rejects them before any transaction is signed.

DeFi Protocol Integrations

I built integrations for protocols across the DeFi ecosystem. Beets DEX on Sonic, including their Boosted Pools (liquidity pools that route idle capital to lending protocols for extra yield) and the stS staking token. Beefy Finance, a multi-chain yield optimizer that auto-compounds returns across dozens of strategies. Pendle Finance V2, which lets users trade future yield as separate tokens. Convex Finance, which optimizes Curve protocol yields.

Each protocol has its own quirks. Beets Boosted Pools require understanding how nested pool structures work and how liquidity is distributed across sub-pools. Pendle's yield tokenization means dealing with time-decaying assets where the same operation behaves differently depending on maturity dates. These edge cases are where most AI integrations break, and where careful tool design matters most.

Centralized Exchange Integrations

I also built integrations for Binance and Bybit, covering both spot trading and futures (USDM perpetual contracts). These are fundamentally different from DeFi integrations: instead of interacting with smart contracts on-chain, the agent calls REST APIs with HMAC-signed requests, manages order books, and handles position lifecycle (open, modify, close, set stop-loss and take-profit). The challenge here is mapping the same natural language interface to two very different execution environments (permissionless blockchain vs. authenticated exchange API) while keeping the user experience consistent.

Results & Impact

  • Delivered 8 protocol integration modules covering both DeFi protocols and centralized exchanges
  • Enabled complex multi-step DeFi operations (swap → collateralize → borrow → stake) from a single natural language command
  • Schema-validated tool definitions eliminated hallucination risks for on-chain transactions
  • Bridged two fundamentally different execution environments (permissionless blockchain and authenticated exchange APIs) under a unified natural language interface
  • All integrations are open source, serving as reference implementations for the HeyAnon community

Technologies Used

  • TypeScript (AUTOMATE framework for schema-based DeFi tooling)
  • Viem for type-safe blockchain interaction and contract calls
  • DeFi: Beets DEX, Beefy, Pendle V2, Convex Finance
  • CEX: Binance Spot & Futures, Bybit Spot & Futures
  • LLM tool definitions with typed schemas for deterministic execution
View Project