A plugin for Hedera Agent Kit (v4) that provides seamless integration with Bonzo Finance, an Aave v2βcompatible lending protocol on the Hedera network.
Bonzo Finance Labs is NOT responsible for any loss incurred by using this SDK plugin. This software is provided "as is" without warranty of any kind.
- Do Your Own Research (DYOR) before using this plugin
- Always test on testnet first before using on mainnet
- This plugin interacts with smart contracts and financial protocols
- Cryptocurrency transactions are irreversible
- Always verify contract addresses and parameters before executing transactions
- The authors and maintainers assume no liability for any losses, damages, or consequences arising from the use of this software
By using this plugin, you acknowledge that you understand the risks and agree to use it at your own discretion.
The Bonzo plugin enables AI agents to interact with the Bonzo lending protocol, providing functionality for:
- Market Data: Fetch real-time market information (tokens, APYs, liquidity, utilization)
- Approve: Approve ERC20 tokens for Bonzo operations
- Deposit: Supply tokens to the lending pool
- Withdraw: Withdraw supplied tokens from the lending pool
- Borrow: Borrow tokens from the lending pool (stable or variable rate)
- Repay: Repay borrowed tokens
All transactional tools (approve, deposit, withdraw, borrow, repay) extend BaseTool, so they fully support v4 hooks and policies (e.g. HcsAuditTrailHook, MaxRecipientsPolicy, RejectToolPolicy). The market data tool is a read-only query and uses the simpler functional Tool interface.
bun add @bonzofinancelabs/hak-bonzo-plugin \
@hashgraph/hedera-agent-kit \
@hashgraph/hedera-agent-kit-langchain \
@hiero-ledger/sdk \
@langchain/openai langchainThe agent kit core, the LangChain toolkit, and the Hiero SDK are declared as peer dependencies and must be installed alongside the plugin. Pick whichever LLM provider you prefer (@langchain/openai, @langchain/anthropic, etc.).
import { AgentMode } from "@hashgraph/hedera-agent-kit";
import { HederaLangchainToolkit } from "@hashgraph/hedera-agent-kit-langchain";
import { Client, PrivateKey } from "@hiero-ledger/sdk";
import { bonzoPlugin } from "@bonzofinancelabs/hak-bonzo-plugin";
import { ChatOpenAI } from "@langchain/openai";
import { createAgent } from "langchain";
const client = Client.forTestnet().setOperator(
process.env.ACCOUNT_ID!,
PrivateKey.fromStringECDSA(process.env.PRIVATE_KEY!),
);
const toolkit = new HederaLangchainToolkit({
client,
configuration: {
plugins: [bonzoPlugin],
context: { mode: AgentMode.AUTONOMOUS },
},
});
const agent = createAgent({
model: new ChatOpenAI({ model: "gpt-4.1" }),
tools: toolkit.getTools(),
systemPrompt: "You are a helpful assistant with access to Bonzo lending tools.",
});
const response = await agent.invoke({
messages: [{ role: "user", content: "What are the current APYs on Bonzo?" }],
});π‘ To combine Bonzo tools with the built-in Hedera tools, also pass
allCorePluginsfrom@hashgraph/hedera-agent-kit/plugins:import { allCorePlugins } from "@hashgraph/hedera-agent-kit/plugins"; // plugins: [bonzoPlugin, ...allCorePlugins]
A reference CLI is included in this repository:
git clone https://github.com/Bonzo-Labs/bonzoPlugin
cd bonzoPlugin
bun install
# Testnet (default)
bun run src/index.ts
# Mainnet with operator
HEDERA_NETWORK=mainnet ACCOUNT_ID=0.0.x PRIVATE_KEY=0x... bun run src/index.tsParameter shape: each transactional tool exposes its inputs as two nested objects,
requiredandoptional. Example payload forbonzo_deposit_tool:{ "required": { "tokenSymbol": "USDC", "amount": 1000 }, "optional": { "onBehalfOf": "0.0.12345", "referralCode": 0 } }The agent picks this up automatically from the Zod schemas; the parameter lists below are grouped to match that shape.
Fetches real-time market data including supported tokens, supply/borrow APYs, liquidity, and utilization rates.
- Method:
bonzo_market_data_tool - Parameters: None
- Returns: Human-readable summary of all Bonzo markets
Example usage: "What are the current APYs for tokens on Bonzo?"
Approves the Bonzo LendingPool (or a custom spender) to spend a given ERC20 token.
- Method:
approve_erc20_tool
Required Parameters:
tokenSymbol: Token symbol (e.g.,USDC,WHBAR,HBARX,SAUCE)amount: Amount to approve (human-readable number or string)
Optional Parameters:
spender: EVM address of spender (defaults to LendingPool address)useMax: Iftrue, approves maximum amount (type(uint256).max)
Example usage: "Approve 1000 USDC for Bonzo"
π Available token symbols (per
bonzo-contracts.json):USDC,WHBAR,WHBARE,HBARX,SAUCE,XSAUCE,KARATE,GRELF,KBL,BONZO,DOVU,HST,PACK,STEAM. Not every symbol is configured on both networks β callbonzo_market_data_toolto see what is currently active.
Supplies tokens to the Bonzo lending pool. Users earn supply APY on deposited tokens.
- Method:
bonzo_deposit_tool
Required Parameters:
tokenSymbol: Token symbol to depositamount: Amount to deposit (human-readable number or string)
Optional Parameters:
onBehalfOf: Hedera account ID to deposit on behalf of (defaults to caller's account)referralCode: Referral code (default: 0)
π‘ Note: You must approve the token before depositing. Use
approve_erc20_toolfirst.
Example usage: "Deposit 1000 USDC to Bonzo"
Withdraws previously supplied tokens from the Bonzo lending pool.
- Method:
bonzo_withdraw_tool
Required Parameters:
tokenSymbol: Token symbol to withdrawamount: Amount to withdraw (human-readable number or string)
Optional Parameters:
to: Hedera account ID to withdraw to (defaults to caller's account)withdrawAll: Iftrue, withdraws all available balance
Example usage: "Withdraw 500 USDC from Bonzo"
Borrows tokens from the Bonzo lending pool at either stable or variable interest rates.
- Method:
bonzo_borrow_tool
Required Parameters:
tokenSymbol: Token symbol to borrowamount: Amount to borrow (human-readable number or string)rateMode: Interest rate mode -"stable"or"variable"
Optional Parameters:
onBehalfOf: Hedera account ID to borrow on behalf of (defaults to caller's account)referralCode: Referral code (default: 0)
π‘ Note: You must have sufficient collateral deposited before borrowing.
Example usage: "Borrow 100 USDC at variable rate from Bonzo"
Repays borrowed tokens to the Bonzo lending pool.
- Method:
bonzo_repay_tool
Required Parameters:
tokenSymbol: Token symbol to repayamount: Amount to repay (human-readable number or string)rateMode: Interest rate mode -"stable"or"variable"(must match the original borrow)
Optional Parameters:
onBehalfOf: Hedera account ID to repay on behalf of (defaults to caller's account)repayAll: Iftrue, repays the entire borrowed amount
π‘ Note: You must approve the underlying token before repaying. Use
approve_erc20_toolfirst.
Example usage: "Repay 50 USDC variable rate debt on Bonzo"
For programmatic access to tool names:
import { bonzoPluginToolNames } from "@bonzofinancelabs/hak-bonzo-plugin";
bonzoPluginToolNames.BONZO_MARKET_DATA_TOOL;
bonzoPluginToolNames.APPROVE_ERC20_TOOL;
bonzoPluginToolNames.BONZO_DEPOSIT_TOOL;
bonzoPluginToolNames.BONZO_WITHDRAW_TOOL;
bonzoPluginToolNames.BONZO_BORROW_TOOL;
bonzoPluginToolNames.BONZO_REPAY_TOOL;The plugin works on both Hedera Testnet and Mainnet. Network selection is driven by the Hashgraph SDK client:
const client = Client.forTestnet(); // testnet
const client = Client.forMainnet(); // mainnetAll contract addresses are sourced from bonzo-contracts.json shipped with the plugin (hedera_mainnet / hedera_testnet sections), and are resolved automatically based on client.ledgerId. Tools return clear errors with the available symbols if a token is not configured on the selected network.
Both execution modes are supported:
AUTONOMOUS: transactions are executed on-chain and return receipt / transactionIdRETURN_BYTES: transactions are frozen and returned as bytes for external signing
Mode is controlled via configuration.context.mode.
Required for CLI:
OPENAI_API_KEY: OpenAI API key for the agent LLM
Required for Autonomous Mode:
ACCOUNT_IDorHEDERA_ACCOUNT_ID: Hedera account IDPRIVATE_KEYorHEDERA_PRIVATE_KEY: ECDSA private key (0x...format)
Optional:
HEDERA_NETWORK:testnet|mainnet(default:testnet)HAK_MODEorAGENT_MODE:autonomous|return_bytes(default:return_bytes)BONZO_GAS_LIGHT: gas override for light operations (default:6_000_000)BONZO_GAS_HEAVY: gas override for heavy operations (default:10_000_000)BONZO_MAX_FEE_HBAR: max transaction fee in HBAR (default:2)
Some assets may require token association on Hedera before executing actions. Ensure your account has associated the token or has auto-association enabled.
- Deposit and Repay require approval of the underlying ERC20 token first via
approve_erc20_tool.
For HBAR-native flows, wrapping/unwrapping may be required via gateway contracts depending on Bonzo's implementation.
ABI encoding uses @ethersproject/abi against Aave v2 function signatures. Transactions are built with ContractExecuteTransaction from the Hiero SDK.
bonzoPlugin/
βββ src/
β βββ plugin.ts # Plugin definition and exports
β βββ index.ts # CLI entry point
β βββ client.ts # LangChain agent factory
β βββ tools.ts # Market data tool
β βββ bonzo/
β β βββ bonzo-market-service.ts # Market API service
β β βββ bonzo.zod.ts # Zod parameter schemas
β β βββ utils.ts # Shared utilities
β βββ tools/
β βββ approve-erc20.ts # Approve tool
β βββ deposit.ts # Deposit tool
β βββ withdraw.ts # Withdraw tool
β βββ borrow.ts # Borrow tool
β βββ repay.ts # Repay tool
βββ bonzo-contracts.json # Contract addresses by network
βββ package.json
- Hedera Agent Kit β plugin and tool development guide (v4)
- Aave v2 Developer Docs β ABI references and function signatures
- Bonzo Finance β protocol website and documentation
MIT
Made with β€οΈ by Bonzo Finance Labs