/** * AutomationRegistry — server-side compute scripts that Trails reference by id. * * Automation steps run on the strategist's server (not in the EVM, not in the browser). They: * • Take resolved inputs from the Trail's previous steps. * • Optionally call out to chain via an injected `LucidlyClient` for live state. * • Return named outputs that downstream steps in the same Trail can reference via * `$stepId.outputName`. * * The SDK ships a starter registry with the two scripts the W1 reference trails need: * • `split_capital_dn` — given total capital + target leverage + asset, output the * (spotLegAmount, shortLegMargin, idleMargin) split for a * delta-neutral position. * • `compute_morpho_leverage` — given target LTV bps + collateral price + initial deposit, * output the flashloan amount for a leveraged Morpho position. * * Users can register their own scripts: * const registry = new AutomationRegistry(); * registry.register("my_custom_split", async (inputs, ctx) => { … return { foo: …, bar: … }; }); * * The runner (W4) is responsible for calling these in the right order with the right inputs; * the registry is just a typed dispatch surface. */ import type { LucidlyClient } from "./client.js"; export interface AutomationContext { /** Optional chain client for scripts that need live state (Morpho oracle reads, etc.). */ client?: LucidlyClient; /** Vault the trail is running against — useful for vault-specific overrides. */ vault?: `0x${string}`; /** Strategist EOA, in case the script needs to authorize sub-calls. */ strategist?: `0x${string}`; } export type AutomationScript = (inputs: Record, ctx: AutomationContext) => Promise>; export interface AutomationScriptDescriptor { id: string; description: string; /** Names of inputs the script expects. Used for documentation + validation. */ inputs: { name: string; description: string; }[]; /** Names of outputs the script produces. */ outputs: { name: string; description: string; }[]; fn: AutomationScript; } export declare class AutomationRegistry { private readonly scripts; constructor(initial?: AutomationScriptDescriptor[]); register(descriptor: AutomationScriptDescriptor): void; has(id: string): boolean; get(id: string): AutomationScriptDescriptor | undefined; all(): AutomationScriptDescriptor[]; /** Run a registered script. Throws if id is unknown. */ run(id: string, inputs: Record, ctx: AutomationContext): Promise>; } export declare function defaultAutomationRegistry(): AutomationRegistry; export declare const STARTER_AUTOMATION_SCRIPTS: AutomationScriptDescriptor[];