/** * Trail schema — runnable strategy templates with parameter slots. * * A Trail is the unit a strategist thinks in: "open a Morpho leveraged position on syrupUSDC," * "delta-neutral via Pendle PT + HyperLiquid short," "unwind position X." It sits between two * other abstractions: * * Policy template (raw Merkle leaf — a single allowed call) * └── Trail (parameterized + composable — multiple steps, possibly atomic via flashloan callback) * └── Strategy (multi-trail composition assembled in the canvas — W3) * * Three step kinds reflect what strategies actually do: * • `leaf` — on-chain Merkle-gated call (the only kind the Manager actually executes) * • `api` — off-chain venue API call (HyperLiquid set_leverage, etc.) — needs credentials * • `automation` — off-chain compute (capital split, leverage sizing) — runs on the strategist's server * • `subtrail` — compose another trail inline (e.g. dn.pendle_hyperliquid USES spot.swap_and_buy_pt) * * Three execution modes reflect how the steps run: * • `atomic` — all leaves bundled into ONE manage() call, flashloan-bracketed. First leaf is * the flashloan; everything after is the callback payload that the flashloan * adapter executes inside the bracket. Final leaf typically repays the loan. * • `sequential` — multi-tx ordered. Each step's outputs flow into the next step's args via * $stepId.outputName substitution. Used by DN-style trails where the spot leg * confirms before the short leg sizes itself. * • `parallel` — independent legs that can fire concurrently (rare; usually `sequential`). * * Expression substitution: any string value starting with `$` is a reference resolved at * expansion time. Three reference forms: * • `$paramName` — from the Trail's `params` block * • `$stepId.outputName` — from a prior automation step's named outputs * • `$vault` — magic ref to the vault address being executed against * • `$strategist` — magic ref to the strategist EOA (config.strategist on the vault) */ import { z } from "zod"; export declare const ChainName: z.ZodEnum<{ ethereum: "ethereum"; base: "base"; arbitrum: "arbitrum"; optimism: "optimism"; hyperevm: "hyperevm"; plasma: "plasma"; monad: "monad"; katana: "katana"; }>; export type ChainName = z.infer; export declare const TrailParamType: z.ZodEnum<{ string: "string"; boolean: "boolean"; address: "address"; int256: "int256"; uint16: "uint16"; uint256: "uint256"; morpho_market: "morpho_market"; trail_ref: "trail_ref"; asset_symbol: "asset_symbol"; }>; export type TrailParamType = z.infer; export type ExprValue = string | number | boolean | null | { [k: string]: ExprValue; } | ExprValue[]; export declare const TrailParam: z.ZodObject<{ name: z.ZodString; type: z.ZodEnum<{ string: "string"; boolean: "boolean"; address: "address"; int256: "int256"; uint16: "uint16"; uint256: "uint256"; morpho_market: "morpho_market"; trail_ref: "trail_ref"; asset_symbol: "asset_symbol"; }>; required: z.ZodBoolean; description: z.ZodString; default: z.ZodOptional>>; hint: z.ZodOptional; }, z.core.$strip>; export type TrailParam = z.infer; /** * On-chain Merkle-gated call. `(protocol, action, args)` are an ABSTRACT signature — the catalog * adapter at expansion time looks up the matching concrete leaf (with target/selector/decoder * filled in) for the specific vault + chain. * * `action` is a convention-driven verb describing what the call does at a semantic level: * `flashloan`, `approve`, `swap`, `supply`, `borrow`, `supply_collateral`, `repay`, `withdraw`, * `buy_pt`, `place_limit_order`, `cancel_order`, `set_position`, etc. The catalog adapter has the * `(protocol, action)` → on-chain (target, selector) mapping per chain. */ export declare const TrailLeafStep: z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"leaf">; protocol: z.ZodString; action: z.ZodString; args: z.ZodDefault>>>; }, z.core.$strip>; export type TrailLeafStep = z.infer; /** * Off-chain venue API call. Examples: HyperLiquid `set_leverage`, Binance `transfer_isolated`. * Doesn't go through the Manager — runs on the strategist's server with their credentials. * Credentials come from a `CredentialsProvider` keyed by (vault, venue). */ export declare const TrailApiStep: z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"api">; venue: z.ZodString; method: z.ZodString; params: z.ZodDefault>>>; }, z.core.$strip>; export type TrailApiStep = z.infer; /** * Off-chain compute step. Runs a registered automation script on the strategist's server. May * read chain state if the script needs it (the runner injects a LucidlyClient). Produces named * outputs accessible to later steps via `$stepId.outputName`. */ export declare const TrailAutomationStep: z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"automation">; scriptId: z.ZodString; inputs: z.ZodDefault>>>; outputs: z.ZodDefault>; }, z.core.$strip>; export type TrailAutomationStep = z.infer; /** * Inline composition: call another Trail. Args from the outer trail flow into the inner trail's * params. Subtrail outputs are accessible via `$stepId.outputName`. * * Example: dn.pendle_hyperliquid composes spot.swap_and_buy_pt as its spot leg. */ export declare const TrailSubtrailStep: z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"subtrail">; trailId: z.ZodString; args: z.ZodDefault>>>; }, z.core.$strip>; export type TrailSubtrailStep = z.infer; export declare const TrailStep: z.ZodDiscriminatedUnion<[z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"leaf">; protocol: z.ZodString; action: z.ZodString; args: z.ZodDefault>>>; }, z.core.$strip>, z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"api">; venue: z.ZodString; method: z.ZodString; params: z.ZodDefault>>>; }, z.core.$strip>, z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"automation">; scriptId: z.ZodString; inputs: z.ZodDefault>>>; outputs: z.ZodDefault>; }, z.core.$strip>, z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"subtrail">; trailId: z.ZodString; args: z.ZodDefault>>>; }, z.core.$strip>], "kind">; export type TrailStep = z.infer; export declare const TrailExecution: z.ZodObject<{ mode: z.ZodEnum<{ atomic: "atomic"; sequential: "sequential"; parallel: "parallel"; }>; steps: z.ZodArray; description: z.ZodOptional; kind: z.ZodLiteral<"leaf">; protocol: z.ZodString; action: z.ZodString; args: z.ZodDefault>>>; }, z.core.$strip>, z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"api">; venue: z.ZodString; method: z.ZodString; params: z.ZodDefault>>>; }, z.core.$strip>, z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"automation">; scriptId: z.ZodString; inputs: z.ZodDefault>>>; outputs: z.ZodDefault>; }, z.core.$strip>, z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"subtrail">; trailId: z.ZodString; args: z.ZodDefault>>>; }, z.core.$strip>], "kind">>; flashloanStep: z.ZodOptional; }, z.core.$strip>; export type TrailExecution = z.infer; export declare const Trail: z.ZodObject<{ id: z.ZodString; schemaVersion: z.ZodLiteral<"0.1.0">; name: z.ZodString; summary: z.ZodString; family: z.ZodOptional; chains: z.ZodArray>; params: z.ZodDefault; required: z.ZodBoolean; description: z.ZodString; default: z.ZodOptional>>; hint: z.ZodOptional; }, z.core.$strip>>>; execution: z.ZodObject<{ mode: z.ZodEnum<{ atomic: "atomic"; sequential: "sequential"; parallel: "parallel"; }>; steps: z.ZodArray; description: z.ZodOptional; kind: z.ZodLiteral<"leaf">; protocol: z.ZodString; action: z.ZodString; args: z.ZodDefault>>>; }, z.core.$strip>, z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"api">; venue: z.ZodString; method: z.ZodString; params: z.ZodDefault>>>; }, z.core.$strip>, z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"automation">; scriptId: z.ZodString; inputs: z.ZodDefault>>>; outputs: z.ZodDefault>; }, z.core.$strip>, z.ZodObject<{ id: z.ZodOptional; description: z.ZodOptional; kind: z.ZodLiteral<"subtrail">; trailId: z.ZodString; args: z.ZodDefault>>>; }, z.core.$strip>], "kind">>; flashloanStep: z.ZodOptional; }, z.core.$strip>; preconditions: z.ZodOptional>; risks: z.ZodOptional>; llm_doc: z.ZodString; }, z.core.$strip>; export type Trail = z.infer; /** * Detect whether a value is an expression reference (starts with "$" and isn't escaped). * Returns the bare reference name (without "$") if so, else null. */ export declare function exprRef(v: unknown): string | null; /** * Parse a JSON object into a validated Trail. Throws a zod error with field paths on invalid * input — pleasant authoring experience even before the file lands in a library. */ export declare function parseTrail(json: unknown): Trail; /** Safe variant — returns { success, data | error }. */ export declare function safeParseTrail(json: unknown): { success: true; data: Trail; } | { success: false; error: z.ZodError; };