UNPKG

sei-agent-kit

Version:

A package for building AI agents on the SEI blockchain

47 lines 1.59 kB
import { z } from "zod"; import { StructuredTool } from "langchain/tools"; const SeiBorrowTakaraInputSchema = z.object({ ticker: z .string() .describe("The token ticker (e.g., 'USDC', 'SEI')"), borrowAmount: z .string() .describe("The amount to borrow in human-readable format (e.g., '50' for 50 USDC)"), }); /** * LangChain tool for borrowing against Takara tokens */ export class SeiBorrowTakaraTool extends StructuredTool { seiKit; name = "borrow_takara"; description = "Borrows underlying tokens from the Takara Protocol using tTokens as collateral. For example, use tUSDC as collateral to borrow USDC."; schema = SeiBorrowTakaraInputSchema; constructor(seiKit) { super(); this.seiKit = seiKit; } async _call({ ticker, borrowAmount }) { try { if (!ticker) { throw new Error("ticker is required"); } if (!borrowAmount) { throw new Error("borrowAmount is required"); } const result = await this.seiKit.borrowTakara(ticker, borrowAmount); return JSON.stringify({ status: "success", message: `Successfully borrowed tokens. Transaction hash: ${result}`, txHash: result, }); } catch (error) { return JSON.stringify({ status: "error", message: error.message, code: error.code || "UNKNOWN_ERROR", }); } } } //# sourceMappingURL=borrow.js.map