UNPKG

sei-agent-kit

Version:

A package for building AI agents on the SEI blockchain

30 lines 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SeiCitrexCancelOrdersTool = void 0; const tools_1 = require("langchain/tools"); const zod_1 = require("zod"); // Define a schema for a single order cancellation const OrderCancelSchema = zod_1.z.object({ orderId: zod_1.z.string().startsWith("0x").describe("The unique order ID of the order to be cancelled"), productId: zod_1.z.number().int().positive().describe("The product ID of the order to be cancelled"), }); const CitrexCancelOrdersInputSchema = zod_1.z.object({ orders: zod_1.z.array(OrderCancelSchema).min(1).describe("Array of orders to cancel, each with orderId and productId"), }); class SeiCitrexCancelOrdersTool extends tools_1.StructuredTool { constructor(seiKit) { super(); this.seiKit = seiKit; this.name = "citrex_cancel_orders"; this.description = "Cancels multiple orders on the Citrex Protocol in a single operation. This is more efficient than cancelling orders one by one. Returns an array of success flags indicating whether each cancellation was successful."; this.schema = CitrexCancelOrdersInputSchema; } async _call(input) { const { orders } = input; // Convert to the format expected by the SDK const formattedOrdersArgs = orders.map(({ orderId, productId }) => [orderId, productId]); return this.seiKit.citrexCancelOrders(formattedOrdersArgs); } } exports.SeiCitrexCancelOrdersTool = SeiCitrexCancelOrdersTool; //# sourceMappingURL=cancelOrders.js.map