openpondai/agents/price-trigger-bot
OpenTool app
1Branch0Tags
typescript
import { z } from "zod";
export const targetSchema = z.object({
symbol: z.string().min(1),
weight: z.number().positive().optional(),
});
export const ruleSchema = z.object({
id: z.string().min(1).optional(),
sourceSymbol: z.string().min(1).optional(),
condition: z
.enum(["above", "below", "crosses-above", "crosses-below"])
.optional(),
threshold: z.number().positive().optional(),
actionSide: z.enum(["buy", "sell"]).optional(),
targets: z.array(targetSchema).optional(),
});
export const configSchema = z.object({
platform: z.literal("hyperliquid").optional(),
ruleType: z.literal("price-trigger").optional(),
allocationMode: z.literal("fixed").optional(),
asset: z.string().min(1).optional(),
amountUsd: z.number().positive().optional(),
schedule: z
.object({
cron: z.string().min(1).optional(),
enabled: z.boolean().optional(),
notifyEmail: z.boolean().optional(),
})
.optional(),
execution: z
.object({
enabled: z.boolean().optional(),
environment: z.enum(["mainnet", "testnet"]).optional(),
leverage: z.number().positive().optional(),
slippageBps: z.number().min(0).max(500).optional(),
})
.optional(),
rules: z.array(ruleSchema).optional(),
});
export const TEMPLATE_CONFIG_SCHEMA = {
type: "object",
properties: {
configVersion: { type: "number" },
platform: { type: "string", enum: ["hyperliquid"] },
ruleType: { type: "string", enum: ["price-trigger"] },
allocationMode: { type: "string", enum: ["fixed"] },
asset: { type: "string" },
amountUsd: { type: "number" },
schedule: {
type: "object",
properties: {
cron: { type: "string" },
enabled: { type: "boolean" },
notifyEmail: { type: "boolean" },
},
},
execution: {
type: "object",
properties: {
enabled: { type: "boolean" },
environment: { type: "string", enum: ["mainnet", "testnet"] },
leverage: { type: "number" },
slippageBps: { type: "number" },
},
},
rules: {
type: "array",
items: {
type: "object",
properties: {
id: { type: "string" },
sourceSymbol: { type: "string" },
condition: {
type: "string",
enum: ["above", "below", "crosses-above", "crosses-below"],
},
threshold: { type: "number" },
actionSide: { type: "string", enum: ["buy", "sell"] },
targets: {
type: "array",
items: {
type: "object",
properties: {
symbol: { type: "string" },
weight: { type: "number" },
},
},
},
},
},
},
},
} as const;