UNPKG

sei-agent-kit

Version:

A package for building AI agents on the SEI blockchain

50 lines 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SeiBorrowTakaraTool = void 0; const zod_1 = require("zod"); const tools_1 = require("langchain/tools"); const SeiBorrowTakaraInputSchema = zod_1.z.object({ ticker: zod_1.z .string() .describe("The token ticker (e.g., 'USDC', 'SEI')"), borrowAmount: zod_1.z .string() .describe("The amount to borrow in human-readable format (e.g., '50' for 50 USDC)"), }); /** * LangChain tool for borrowing against Takara tokens */ class SeiBorrowTakaraTool extends tools_1.StructuredTool { constructor(seiKit) { super(); this.seiKit = seiKit; this.name = "borrow_takara"; this.description = "Borrows underlying tokens from the Takara Protocol using tTokens as collateral. For example, use tUSDC as collateral to borrow USDC."; this.schema = SeiBorrowTakaraInputSchema; } 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", }); } } } exports.SeiBorrowTakaraTool = SeiBorrowTakaraTool; //# sourceMappingURL=borrow.js.map