Skip to main content
RampartAgent extends the Rampart class and exposes every SDK function as a structured Vercel AI SDK v6 tool. Pass agent.tools directly to generateText, streamText, or any AI SDK function - the agent handles schema validation and execution automatically.

Overview

RampartAgent wraps all Rampart functions using tool() from the Vercel AI SDK v6. Each tool uses inputSchema: (Zod) for input validation and an execute function that delegates to the underlying protocol function. This means any LLM with tool-calling support can query Monad DeFi data autonomously.
import { RampartAgent } from 'rampart-monad'
import { generateText } from 'ai'
import { anthropic } from '@ai-sdk/anthropic'

const agent = new RampartAgent()

const { text } = await generateText({
  model: anthropic('claude-3-5-sonnet-20241022'),
  tools: agent.tools,
  system: 'You are a Monad DeFi analyst.',
  prompt: 'Find the best yield for USDC right now',
  maxSteps: 5,
})

console.log(text)

Available Tools (41)

ToolDescriptionReturns
get_kuru_poolsKuru DEX pool listKuruPool[]
get_kuru_priceMON price from Kurunumber
get_token_priceToken priceTokenPrice
get_uniswap_poolsUniswap V3 poolsPool[]
get_euler_vaultsEuler V2 vaultsEulerVault[]
get_euler_best_supplyBest Euler supply rateEulerVault
get_neverland_ratesNeverland lending ratesLendingRate[]
get_morpho_vaultsMorpho Blue vaultsMorphoVault[]
get_all_lst_statsAll 5 LST statsLSTStats[]
get_best_lstHighest APR LSTLSTStats
compare_lstsLST APR comparisonLSTStats[]
get_staking_apraPriori staking APRStakingAPR
get_best_swap_routeBest DEX routeRouterResult
get_all_swap_quotesAll DEX quotesSwapRoute[]
detect_arbitrageDEX arbitrage alertsArbitrageAlert[]
get_market_overviewEcosystem overviewMonadMarketOverview
get_best_yieldsTop yield opportunitiesYieldOpportunity[]
get_monad_tvlTotal DeFi TVLTVLBreakdown
get_portfolioWallet portfolioPortfolio
get_token_balancesERC20 balancesTokenBalance[]
get_euler_positionsEuler vault positionsEulerPosition[]
get_lst_positionsLST holdingsLSTPosition[]
get_verified_priceCross-oracle priceVerifiedPrice
get_pricesBatch oracle pricesOraclePrice[]
detect_oracle_discrepancyOracle price deviationobject
get_lst_ratiosLST exchange ratesLSTRatios
get_pancakeswap_poolsPancakeSwap poolsPancakeSwapPair[]
get_nadfun_statsnad.fun launchpadNadFunStats
get_trending_memesTrending memecoinsMemeToken[]
get_perp_marketsPerp market dataPerpMarket[]
get_perp_tvlPerpetuals TVLnumber
get_curvance_marketsCurvance marketsCurvanceMarket[]
get_best_yields_for_assetYields for assetYieldOpportunity[]
get_uniswap_v4_poolsUniswap V4 poolsUniswapV4Pool[]
get_mellow_vaultsMellow vshMON vaultsMellowVault[]
get_market_intelligenceFull market intelMonadMarketOverview

Tool Input Schema Example

Tools are built internally using the Vercel AI SDK tool() helper with inputSchema: (not parameters:, which is the v5 API):
import { tool } from 'ai'
import { z } from 'zod'

const get_best_swap_route = tool({
  description: 'Find best swap route across all DEXes',
  inputSchema: z.object({
    tokenIn:  z.string().describe('Input token address'),
    tokenOut: z.string().describe('Output token address'),
    amountIn: z.string().describe('Amount in wei'),
  }),
  execute: async ({ tokenIn, tokenOut, amountIn }) =>
    getBestSwapRoute(tokenIn, tokenOut, amountIn),
})

Multi-Step Agent Example

import { RampartAgent } from 'rampart-monad'
import { generateText } from 'ai'
import { anthropic } from '@ai-sdk/anthropic'

const agent = new RampartAgent()

// Multi-step: the model can call multiple tools in sequence
const { text, steps } = await generateText({
  model: anthropic('claude-3-5-sonnet-20241022'),
  tools: agent.tools,
  system: `You are a Monad DeFi analyst. Use the available tools to answer
  questions about yields, prices, liquidity, and portfolio positions.
  Always verify prices using the cross-oracle tool before making recommendations.`,
  prompt: 'Compare the best LST option versus the best Euler supply rate for MON.',
  maxSteps: 8,
})

console.log(`Model called ${steps.length} tools`)
console.log(text)

Streaming Example

import { RampartAgent } from 'rampart-monad'
import { streamText } from 'ai'
import { anthropic } from '@ai-sdk/anthropic'

const agent = new RampartAgent()

const result = streamText({
  model: anthropic('claude-3-5-sonnet-20241022'),
  tools: agent.tools,
  system: 'You are a Monad DeFi analyst.',
  prompt: 'What is the current total TVL on Monad and where is most of it?',
  maxSteps: 5,
})

for await (const chunk of result.textStream) {
  process.stdout.write(chunk)
}

Working with Specific Tools

You can destructure individual tools from agent.tools if you want to compose a custom subset:
import { RampartAgent } from 'rampart-monad'
import { generateText } from 'ai'
import { openai } from '@ai-sdk/openai'

const agent = new RampartAgent()

const { get_market_overview, get_best_yields, get_verified_price } = agent.tools

const { text } = await generateText({
  model: openai('gpt-4o'),
  tools: { get_market_overview, get_best_yields, get_verified_price },
  prompt: 'Give me a market summary and top 3 yields.',
  maxSteps: 4,
})

Notes

  • RampartAgent is model-agnostic - any AI SDK v6 compatible provider works (Anthropic, OpenAI, Google, etc.).
  • All tools use inputSchema: (Vercel AI SDK v6 API). Do not use parameters: which is the v5 API and will cause a type error.
  • The execute functions are async and call the same underlying RPC functions as the Rampart class methods - there is no additional latency layer.
  • maxSteps controls how many sequential tool calls the model may make. For complex multi-protocol queries, set this to at least 5.