UNPKG

sei-agent-kit

Version:

A package for building AI agents on the SEI blockchain

48 lines 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SeiRedeemTakaraTool = void 0; const zod_1 = require("zod"); const tools_1 = require("langchain/tools"); const SeiRedeemTakaraInputSchema = zod_1.z.object({ ticker: zod_1.z .string() .describe("The token ticker (e.g., 'USDC', 'SEI')"), redeemAmount: zod_1.z .string() .describe("The amount to redeem in human-readable format (e.g., '50' for 50 USDC). Use 'MAX' to redeem all tTokens"), redeemType: zod_1.z .enum(["underlying", "tokens"]) .optional() .describe("Optional: The type of redemption - 'underlying' to redeem a specific amount of underlying tokens, or 'tokens' to redeem a specific amount of tTokens. Defaults to 'underlying'"), }); /** * LangChain tool for redeeming Takara tokens */ class SeiRedeemTakaraTool extends tools_1.StructuredTool { constructor(seiKit) { super(); this.seiKit = seiKit; this.name = "redeem_takara"; this.description = "Redeems tTokens from the Takara Protocol to get underlying tokens back. Use 'MAX' as redeemAmount to redeem all available tokens."; this.schema = SeiRedeemTakaraInputSchema; } async _call({ ticker, redeemAmount, redeemType = "underlying" }) { try { const result = await this.seiKit.redeemTakara(ticker, redeemAmount, redeemType); return JSON.stringify({ status: "success", message: `Successfully redeemed tTokens. Transaction hash: ${result}`, txHash: result, }); } catch (error) { return JSON.stringify({ status: "error", message: error.message, code: error.code || "UNKNOWN_ERROR", }); } } } exports.SeiRedeemTakaraTool = SeiRedeemTakaraTool; //# sourceMappingURL=redeem.js.map