The ADK (Agent Development Kit) TypeScript SDK (@iqai/adk) provides the foundation for building intelligent AI agents that can interact with blockchain protocols, monitor DeFi positions, and automate complex workflows.MetaVault AI uses ADK-TS to create autonomous agents that monitor vault strategies, manage risk, and execute transactions.
import { AgentBuilder } from "@iqai/adk";import { env, model } from "../env";import { getStrategySentinelAgent } from "./sub-agents/strategy-sentinel-agent/agent";import { getYieldGeneratorAgent } from "./sub-agents/yield-generator-agent/agent";export const getRootAgent = async () => { const strategySentinelAgent = await getStrategySentinelAgent(); const yieldSimulatorAgent = await getYieldGeneratorAgent(); return AgentBuilder .create("root_agent") .withDescription("AI Agent that monitors and manages the Funds and Strategies of the Vault.") .withInstruction(` Use the sub-agent Strategy Sentinel Agent for getting vault, strategies, and users' stats, and perform deposit, withdraw, rebalance, harvest, auto_deleverage. Use the sub-agent Yield Generator Agent for accruing or generating yield to the Pool. `) .withModel(model) .withSubAgents([strategySentinelAgent, yieldSimulatorAgent]) .build();}
import { LlmAgent } from "@iqai/adk";import { model } from "../../../env";import dedent from "dedent";import { get_strategy_states, get_user_balances, get_vault_state, rebalance_vault, harvest_strategy, vault_deposit, vault_withdraw, check_liquidation_risk, auto_deleverage, get_token_prices, get_leverage_strategy_state, get_vault_apy} from "./tools";export async function getStrategySentinelAgent() { return new LlmAgent({ name: "strategy_sentinel_agent", description: "A agent that monitors and manages the strategies in the Vault.", instruction: dedent` You are the Strategy Sentinel Agent, responsible for monitoring, analyzing, and managing every strategy within the portfolio. Your primary objective is to maintain safety, optimal performance, healthy leverage, and capital preservation. Never assume or invent on-chain values. Always use provided tools. `, model: model, tools: [ get_strategy_states, get_user_balances, get_vault_state, rebalance_vault, harvest_strategy, vault_deposit, vault_withdraw, check_liquidation_risk, auto_deleverage, get_token_prices, get_leverage_strategy_state, get_vault_apy ] })}
const { runner } = await getRootAgent();// Ask the agent to perform a taskconst result = await runner.ask( "Check the vault state and rebalance if allocations diverge from targets");console.log(result);
Use the dedent package for clean, readable multi-line instructions:
import dedent from "dedent";const instruction = dedent` You are an AI agent responsible for... Rules: - Never expose confidential data - Always verify data with tools - Prefer safety over yield`;