sei-agent-kit
Version:
A package for building AI agents on the SEI blockchain
38 lines • 2.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SeiCitrexPlaceOrdersTool = void 0;
const tools_1 = require("langchain/tools");
const enums_js_1 = require("../../../node_modules/citrex-sdk/lib/enums.js");
const zod_1 = require("zod");
// Define the schema for a single order
const OrderSchema = zod_1.z.object({
isBuy: zod_1.z.boolean().describe("Whether to buy (true) or sell (false)"),
price: zod_1.z.number().positive().describe("The price of the asset you intend to order"),
productId: zod_1.z.number().int().positive().describe("The product ID of asset"),
quantity: zod_1.z.number().positive().describe("The amount of the asset you intend to order"),
orderType: zod_1.z.nativeEnum(enums_js_1.OrderType).optional().describe("The type of order (default: MARKET)"),
timeInForce: zod_1.z.nativeEnum(enums_js_1.TimeInForce).optional().describe("The time in force for the order (default: FOK)"),
expiration: zod_1.z.number().optional().describe("The expiration time of the order in milliseconds (default: now + 30 days)"),
nonce: zod_1.z.number().optional().describe("A unique identifier for the order (default: current unix timestamp in nano seconds)"),
priceIncrement: zod_1.z.number().optional().describe("The price precision for the product (required for MARKET orders)"),
slippage: zod_1.z.number().optional().describe("The percentage by which to adjust the price when orderType is MARKET (default: 2.5%)"),
});
// Input schema for placing multiple orders
const CitrexPlaceOrdersInputSchema = zod_1.z.object({
orders: zod_1.z.array(OrderSchema).min(1).describe("Array of orders to place"),
});
class SeiCitrexPlaceOrdersTool extends tools_1.StructuredTool {
constructor(seiKit) {
super();
this.seiKit = seiKit;
this.name = "citrex_place_orders";
this.description = "Places multiple orders on the Citrex Protocol in a single operation. This is more efficient than placing orders one by one. Returns an array of created orders, each with details including order ID, account address, product information, price, quantity, order type, time in force, buy/sell direction, creation time, expiry, and status.";
this.schema = CitrexPlaceOrdersInputSchema;
}
async _call(input) {
const { orders } = input;
return this.seiKit.citrexPlaceOrders(orders);
}
}
exports.SeiCitrexPlaceOrdersTool = SeiCitrexPlaceOrdersTool;
//# sourceMappingURL=placeOrders.js.map