import { Schema } from 'effect';
import z from 'zod';

declare const SolTypeSchema: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
declare const ResourceSchema: Schema.Union<[Schema.Struct<{
    kind: Schema.Literal<["native"]>;
    chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>, Schema.Struct<{
    kind: Schema.Literal<["erc20"]>;
    token: typeof Schema.String;
    chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>]>;
declare const ResourceInputSchema: Schema.Struct<{
    name: typeof Schema.String;
    resource: Schema.Union<[Schema.Struct<{
        kind: Schema.Literal<["native"]>;
        chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
    }>, Schema.Struct<{
        kind: Schema.Literal<["erc20"]>;
        token: typeof Schema.String;
        chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
    }>]>;
}>;
declare const HandleInputSchema: Schema.Struct<{
    name: typeof Schema.String;
    type: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
}>;
declare const FlowInputSchema: Schema.Union<[Schema.Struct<{
    name: typeof Schema.String;
    resource: Schema.Union<[Schema.Struct<{
        kind: Schema.Literal<["native"]>;
        chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
    }>, Schema.Struct<{
        kind: Schema.Literal<["erc20"]>;
        token: typeof Schema.String;
        chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
    }>]>;
}>, Schema.Struct<{
    name: typeof Schema.String;
    type: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
}>]>;
declare const RefSchema: Schema.Struct<{
    $ref: Schema.filter<typeof Schema.String>;
}>;
declare const LiteralBindingSchema: Schema.Struct<{
    kind: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
    value: typeof Schema.String;
}>;
declare const BindValueSchema: Schema.Union<[Schema.Struct<{
    $ref: Schema.filter<typeof Schema.String>;
}>, Schema.Struct<{
    kind: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
    value: typeof Schema.String;
}>]>;
declare const AppliedGuardSchema: Schema.TypeLiteral<{
    kind: typeof Schema.String;
}, readonly [{
    readonly key: typeof Schema.String;
    readonly value: typeof Schema.Unknown;
}]>;
declare const CallSchema: Schema.Struct<{
    id: typeof Schema.String;
    op: typeof Schema.String;
    bind: Schema.optionalWith<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.Struct<{
        $ref: Schema.filter<typeof Schema.String>;
    }>, Schema.Struct<{
        kind: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
        value: typeof Schema.String;
    }>]>>, {
        default: () => {};
    }>;
    config: Schema.optionalWith<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>, {
        default: () => {};
    }>;
    guards: Schema.optional<Schema.Array$<Schema.TypeLiteral<{
        kind: typeof Schema.String;
    }, readonly [{
        readonly key: typeof Schema.String;
        readonly value: typeof Schema.Unknown;
    }]>>>;
}>;
declare const ContinuationSchema: Schema.Struct<{
    awaits: typeof Schema.String;
    flowId: typeof Schema.String;
}>;
declare const FlowSchema: Schema.Struct<{
    version: Schema.Literal<[1]>;
    id: typeof Schema.String;
    chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
    inputs: Schema.Array$<Schema.Union<[Schema.Struct<{
        name: typeof Schema.String;
        resource: Schema.Union<[Schema.Struct<{
            kind: Schema.Literal<["native"]>;
            chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
        }>, Schema.Struct<{
            kind: Schema.Literal<["erc20"]>;
            token: typeof Schema.String;
            chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
        }>]>;
    }>, Schema.Struct<{
        name: typeof Schema.String;
        type: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
    }>]>>;
    nodes: Schema.Array$<Schema.Struct<{
        id: typeof Schema.String;
        op: typeof Schema.String;
        bind: Schema.optionalWith<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.Struct<{
            $ref: Schema.filter<typeof Schema.String>;
        }>, Schema.Struct<{
            kind: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
            value: typeof Schema.String;
        }>]>>, {
            default: () => {};
        }>;
        config: Schema.optionalWith<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>, {
            default: () => {};
        }>;
        guards: Schema.optional<Schema.Array$<Schema.TypeLiteral<{
            kind: typeof Schema.String;
        }, readonly [{
            readonly key: typeof Schema.String;
            readonly value: typeof Schema.Unknown;
        }]>>>;
    }>>;
    continuation: Schema.optional<Schema.Struct<{
        awaits: typeof Schema.String;
        flowId: typeof Schema.String;
    }>>;
}>;
type SolType = typeof SolTypeSchema.Type;
type ResourceInput = typeof ResourceInputSchema.Type;
type HandleInput = typeof HandleInputSchema.Type;
type FlowInput = typeof FlowInputSchema.Type;
type Ref = typeof RefSchema.Type;
type LiteralBinding = typeof LiteralBindingSchema.Type;
type BindValue = typeof BindValueSchema.Type;
type AppliedGuard = typeof AppliedGuardSchema.Type;
type Call = typeof CallSchema.Type;
type Continuation = typeof ContinuationSchema.Type;
type Flow = typeof FlowSchema.Type;

type Availability = "now" | "future";
interface OutputAmount {
    readonly expected: bigint;
    readonly min?: bigint;
}
type Resource = {
    readonly kind: "native";
    readonly chainId: number;
} | {
    readonly kind: "erc20";
    readonly token: string;
    readonly chainId: number;
};
type SimulatedAmounts = {
    readonly amountOut: bigint;
    readonly amountOutMin: bigint;
};
type ProducedResource = Resource & {
    readonly availability: Availability;
    readonly simulated?: SimulatedAmounts;
    readonly owner: string;
};
declare const erc20Resource: (token: string, chainId: number) => Resource;
declare const nativeResource: (chainId: number) => Resource;
declare const isERC20Resource: (r: Resource) => r is Extract<Resource, {
    kind: "erc20";
}>;
declare const isNativeResource: (r: Resource) => r is Extract<Resource, {
    kind: "native";
}>;
declare const resourcesEqual: (a: Resource, b: Resource) => boolean;
declare const foldResource: <R>(r: Resource, cases: {
    readonly native: (chainId: number) => R;
    readonly erc20: (token: string, chainId: number) => R;
}) => R;
declare const resourceKey: (r: Resource) => string;
declare const erc20Token: (r: Resource) => string;

type SimulationPolicy = "strict" | "allow-revert";
/**
 * Destination for sweeping proxy-held terminal resources after execution.
 * Either a literal EVM address or a `{ $ref }` context reference
 * (e.g. `{ $ref: "context.sender" }`).
 */
type SweepTo = string | {
    readonly $ref: string;
};
interface ComposeRun {
    readonly inputs: Record<string, InputSpec>;
    readonly preconditions?: readonly Precondition[];
    readonly signer: string;
    readonly assumptions?: Record<string, bigint>;
    readonly referrer?: string;
    readonly integratorFeeBps?: number;
    readonly maxPriceImpactBps?: number;
    readonly sweepTo?: SweepTo;
    readonly simulationPolicy?: SimulationPolicy;
    readonly checkOnChainAllowances?: boolean;
}
interface ComposeCompileRequest {
    readonly flow: Flow;
    readonly run: ComposeRun;
}
interface PriceImpact {
    readonly inputValueUsd: number;
    readonly outputValueUsd: number;
    readonly impactBps: number;
    readonly unpricedInputs: readonly string[];
    readonly unpricedOutputs: readonly string[];
}
interface ApprovalEntry {
    readonly token: string;
    readonly spender: string;
    readonly amount: string;
    readonly transactionRequest: {
        readonly to: string;
        readonly data: string;
        readonly value: "0";
    };
}
interface SimulationRevert {
    readonly code: number;
    readonly rawErrorBytes: string;
    readonly decodeResult?: {
        readonly errorCandidates?: readonly {
            readonly decodedErrorSignature: string;
            readonly decodedParams: readonly string[];
        }[];
        readonly error?: string;
    };
}
interface ComposeTransactionRequest {
    readonly to: string;
    readonly data: string;
    readonly value: string;
    readonly gasLimit?: string;
}
interface ComposeContinuation {
    readonly awaits: string;
    readonly flowId: string;
}
interface ComposeCompileSuccessData {
    readonly producedResources: Record<string, ProducedResource>;
    readonly transactionRequest: ComposeTransactionRequest;
    readonly userProxy: string;
    readonly priceImpact?: PriceImpact;
    readonly approvals?: readonly ApprovalEntry[];
    readonly continuation?: ComposeContinuation;
}
interface ComposeCompilePartialData {
    readonly producedResources: Record<string, ProducedResource>;
    readonly transactionRequest: ComposeTransactionRequest;
    readonly userProxy: string;
    readonly simulationRevert: SimulationRevert;
    readonly approvals?: readonly ApprovalEntry[];
    readonly continuation?: ComposeContinuation;
}
type ComposeCompileResult = (ComposeCompileSuccessData & {
    readonly status: "success";
}) | (ComposeCompilePartialData & {
    readonly status: "partial";
    readonly error: {
        readonly kind: string;
        readonly message: string;
    };
});

declare const ResourcePortZod: z.ZodObject<{
    kind: z.ZodLiteral<"resource">;
    name: z.ZodString;
    accepts: z.ZodEnum<{
        native: "native";
        erc20: "erc20";
        any: "any";
    }>;
    mode: z.ZodEnum<{
        linear: "linear";
        copy: "copy";
    }>;
    optional: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>;
declare const HANDLE_UNITS: readonly ["raw", "wad", "ray", "bps", "token-decimals"];
declare const STATIC_SOL_TYPES: readonly ["uint256", "uint128", "uint64", "uint32", "uint16", "uint8", "address", "bool", "bytes32"];
declare const HandleUnitsZod: z.ZodEnum<{
    raw: "raw";
    wad: "wad";
    ray: "ray";
    bps: "bps";
    "token-decimals": "token-decimals";
}>;
declare const StaticSolTypeZod: z.ZodEnum<{
    uint8: "uint8";
    uint16: "uint16";
    uint32: "uint32";
    uint64: "uint64";
    uint128: "uint128";
    uint256: "uint256";
    address: "address";
    bool: "bool";
    bytes32: "bytes32";
}>;
declare const isStaticSolType: (value: string) => value is StaticSolType;
declare const HandlePortZod: z.ZodObject<{
    kind: z.ZodLiteral<"handle">;
    name: z.ZodString;
    type: z.ZodEnum<{
        string: "string";
        uint8: "uint8";
        uint16: "uint16";
        uint32: "uint32";
        uint64: "uint64";
        uint128: "uint128";
        uint256: "uint256";
        int128: "int128";
        int256: "int256";
        address: "address";
        bool: "bool";
        bytes: "bytes";
        bytes4: "bytes4";
        bytes32: "bytes32";
    }>;
    mode: z.ZodEnum<{
        linear: "linear";
        copy: "copy";
    }>;
    expose: z.ZodOptional<z.ZodBoolean>;
    units: z.ZodOptional<z.ZodEnum<{
        raw: "raw";
        wad: "wad";
        ray: "ray";
        bps: "bps";
        "token-decimals": "token-decimals";
    }>>;
}, z.core.$strip>;
declare const InputPortZod: z.ZodDiscriminatedUnion<[z.ZodObject<{
    kind: z.ZodLiteral<"resource">;
    name: z.ZodString;
    accepts: z.ZodEnum<{
        native: "native";
        erc20: "erc20";
        any: "any";
    }>;
    mode: z.ZodEnum<{
        linear: "linear";
        copy: "copy";
    }>;
    optional: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>, z.ZodObject<{
    kind: z.ZodLiteral<"handle">;
    name: z.ZodString;
    type: z.ZodEnum<{
        string: "string";
        uint8: "uint8";
        uint16: "uint16";
        uint32: "uint32";
        uint64: "uint64";
        uint128: "uint128";
        uint256: "uint256";
        int128: "int128";
        int256: "int256";
        address: "address";
        bool: "bool";
        bytes: "bytes";
        bytes4: "bytes4";
        bytes32: "bytes32";
    }>;
    mode: z.ZodEnum<{
        linear: "linear";
        copy: "copy";
    }>;
    expose: z.ZodOptional<z.ZodBoolean>;
    units: z.ZodOptional<z.ZodEnum<{
        raw: "raw";
        wad: "wad";
        ray: "ray";
        bps: "bps";
        "token-decimals": "token-decimals";
    }>>;
}, z.core.$strip>], "kind">;
declare const ResourceOutputPortZod: z.ZodObject<{
    kind: z.ZodLiteral<"resource_output">;
    name: z.ZodString;
    mode: z.ZodEnum<{
        linear: "linear";
        copy: "copy";
    }>;
    availability: z.ZodOptional<z.ZodEnum<{
        now: "now";
        future: "future";
    }>>;
    providesMinimum: z.ZodOptional<z.ZodBoolean>;
    omitIfZero: z.ZodOptional<z.ZodBoolean>;
    deliveryAddressInput: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
declare const OutputPortZod: z.ZodDiscriminatedUnion<[z.ZodObject<{
    kind: z.ZodLiteral<"resource_output">;
    name: z.ZodString;
    mode: z.ZodEnum<{
        linear: "linear";
        copy: "copy";
    }>;
    availability: z.ZodOptional<z.ZodEnum<{
        now: "now";
        future: "future";
    }>>;
    providesMinimum: z.ZodOptional<z.ZodBoolean>;
    omitIfZero: z.ZodOptional<z.ZodBoolean>;
    deliveryAddressInput: z.ZodOptional<z.ZodString>;
}, z.core.$strip>, z.ZodObject<{
    kind: z.ZodLiteral<"handle">;
    name: z.ZodString;
    type: z.ZodEnum<{
        string: "string";
        uint8: "uint8";
        uint16: "uint16";
        uint32: "uint32";
        uint64: "uint64";
        uint128: "uint128";
        uint256: "uint256";
        int128: "int128";
        int256: "int256";
        address: "address";
        bool: "bool";
        bytes: "bytes";
        bytes4: "bytes4";
        bytes32: "bytes32";
    }>;
    mode: z.ZodEnum<{
        linear: "linear";
        copy: "copy";
    }>;
    expose: z.ZodOptional<z.ZodBoolean>;
    units: z.ZodOptional<z.ZodEnum<{
        raw: "raw";
        wad: "wad";
        ray: "ray";
        bps: "bps";
        "token-decimals": "token-decimals";
    }>>;
}, z.core.$strip>], "kind">;
declare const ManifestOperationZod: z.ZodObject<{
    id: z.ZodString;
    description: z.ZodOptional<z.ZodString>;
    inputs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
        kind: z.ZodLiteral<"resource">;
        name: z.ZodString;
        accepts: z.ZodEnum<{
            native: "native";
            erc20: "erc20";
            any: "any";
        }>;
        mode: z.ZodEnum<{
            linear: "linear";
            copy: "copy";
        }>;
        optional: z.ZodOptional<z.ZodBoolean>;
    }, z.core.$strip>, z.ZodObject<{
        kind: z.ZodLiteral<"handle">;
        name: z.ZodString;
        type: z.ZodEnum<{
            string: "string";
            uint8: "uint8";
            uint16: "uint16";
            uint32: "uint32";
            uint64: "uint64";
            uint128: "uint128";
            uint256: "uint256";
            int128: "int128";
            int256: "int256";
            address: "address";
            bool: "bool";
            bytes: "bytes";
            bytes4: "bytes4";
            bytes32: "bytes32";
        }>;
        mode: z.ZodEnum<{
            linear: "linear";
            copy: "copy";
        }>;
        expose: z.ZodOptional<z.ZodBoolean>;
        units: z.ZodOptional<z.ZodEnum<{
            raw: "raw";
            wad: "wad";
            ray: "ray";
            bps: "bps";
            "token-decimals": "token-decimals";
        }>>;
    }, z.core.$strip>], "kind">>;
    outputs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
        kind: z.ZodLiteral<"resource_output">;
        name: z.ZodString;
        mode: z.ZodEnum<{
            linear: "linear";
            copy: "copy";
        }>;
        availability: z.ZodOptional<z.ZodEnum<{
            now: "now";
            future: "future";
        }>>;
        providesMinimum: z.ZodOptional<z.ZodBoolean>;
        omitIfZero: z.ZodOptional<z.ZodBoolean>;
        deliveryAddressInput: z.ZodOptional<z.ZodString>;
    }, z.core.$strip>, z.ZodObject<{
        kind: z.ZodLiteral<"handle">;
        name: z.ZodString;
        type: z.ZodEnum<{
            string: "string";
            uint8: "uint8";
            uint16: "uint16";
            uint32: "uint32";
            uint64: "uint64";
            uint128: "uint128";
            uint256: "uint256";
            int128: "int128";
            int256: "int256";
            address: "address";
            bool: "bool";
            bytes: "bytes";
            bytes4: "bytes4";
            bytes32: "bytes32";
        }>;
        mode: z.ZodEnum<{
            linear: "linear";
            copy: "copy";
        }>;
        expose: z.ZodOptional<z.ZodBoolean>;
        units: z.ZodOptional<z.ZodEnum<{
            raw: "raw";
            wad: "wad";
            ray: "ray";
            bps: "bps";
            "token-decimals": "token-decimals";
        }>>;
    }, z.core.$strip>], "kind">>;
    configSchema: z.ZodOptional<z.ZodUnknown>;
}, z.core.$strip>;
declare const GuardSelectorZod: z.ZodObject<{
    binding: z.ZodString;
    source: z.ZodEnum<{
        inputs: "inputs";
        outputs: "outputs";
    }>;
    match: z.ZodObject<{
        kind: z.ZodUnion<readonly [z.ZodEnum<{
            resource: "resource";
            handle: "handle";
            resource_output: "resource_output";
        }>, z.ZodArray<z.ZodEnum<{
            resource: "resource";
            handle: "handle";
            resource_output: "resource_output";
        }>>]>;
        mode: z.ZodOptional<z.ZodEnum<{
            linear: "linear";
            copy: "copy";
        }>>;
        type: z.ZodOptional<z.ZodEnum<{
            native: "native";
            erc20: "erc20";
            any: "any";
        }>>;
    }, z.core.$strip>;
    selection: z.ZodDiscriminatedUnion<[z.ZodObject<{
        kind: z.ZodLiteral<"config">;
        configKey: z.ZodString;
        cardinality: z.ZodEnum<{
            one: "one";
            many: "many";
        }>;
    }, z.core.$strip>, z.ZodObject<{
        kind: z.ZodLiteral<"all_matching">;
    }, z.core.$strip>], "kind">;
}, z.core.$strip>;
declare const GuardCompatibilityZod: z.ZodObject<{
    selectors: z.ZodArray<z.ZodObject<{
        binding: z.ZodString;
        source: z.ZodEnum<{
            inputs: "inputs";
            outputs: "outputs";
        }>;
        match: z.ZodObject<{
            kind: z.ZodUnion<readonly [z.ZodEnum<{
                resource: "resource";
                handle: "handle";
                resource_output: "resource_output";
            }>, z.ZodArray<z.ZodEnum<{
                resource: "resource";
                handle: "handle";
                resource_output: "resource_output";
            }>>]>;
            mode: z.ZodOptional<z.ZodEnum<{
                linear: "linear";
                copy: "copy";
            }>>;
            type: z.ZodOptional<z.ZodEnum<{
                native: "native";
                erc20: "erc20";
                any: "any";
            }>>;
        }, z.core.$strip>;
        selection: z.ZodDiscriminatedUnion<[z.ZodObject<{
            kind: z.ZodLiteral<"config">;
            configKey: z.ZodString;
            cardinality: z.ZodEnum<{
                one: "one";
                many: "many";
            }>;
        }, z.core.$strip>, z.ZodObject<{
            kind: z.ZodLiteral<"all_matching">;
        }, z.core.$strip>], "kind">;
    }, z.core.$strip>>;
}, z.core.$strip>;
declare const ManifestGuardZod: z.ZodObject<{
    kind: z.ZodString;
    description: z.ZodOptional<z.ZodString>;
    configSchema: z.ZodOptional<z.ZodUnknown>;
    compatibility: z.ZodOptional<z.ZodObject<{
        selectors: z.ZodArray<z.ZodObject<{
            binding: z.ZodString;
            source: z.ZodEnum<{
                inputs: "inputs";
                outputs: "outputs";
            }>;
            match: z.ZodObject<{
                kind: z.ZodUnion<readonly [z.ZodEnum<{
                    resource: "resource";
                    handle: "handle";
                    resource_output: "resource_output";
                }>, z.ZodArray<z.ZodEnum<{
                    resource: "resource";
                    handle: "handle";
                    resource_output: "resource_output";
                }>>]>;
                mode: z.ZodOptional<z.ZodEnum<{
                    linear: "linear";
                    copy: "copy";
                }>>;
                type: z.ZodOptional<z.ZodEnum<{
                    native: "native";
                    erc20: "erc20";
                    any: "any";
                }>>;
            }, z.core.$strip>;
            selection: z.ZodDiscriminatedUnion<[z.ZodObject<{
                kind: z.ZodLiteral<"config">;
                configKey: z.ZodString;
                cardinality: z.ZodEnum<{
                    one: "one";
                    many: "many";
                }>;
            }, z.core.$strip>, z.ZodObject<{
                kind: z.ZodLiteral<"all_matching">;
            }, z.core.$strip>], "kind">;
        }, z.core.$strip>>;
    }, z.core.$strip>>;
}, z.core.$strip>;
declare const ManifestMaterialiserZod: z.ZodObject<{
    kind: z.ZodString;
    description: z.ZodOptional<z.ZodString>;
    accepts: z.ZodEnum<{
        resource: "resource";
        any: "any";
        handle: "handle";
    }>;
    configSchema: z.ZodOptional<z.ZodUnknown>;
}, z.core.$strip>;
declare const ManifestPreconditionZod: z.ZodObject<{
    type: z.ZodString;
    description: z.ZodOptional<z.ZodString>;
    configSchema: z.ZodOptional<z.ZodUnknown>;
}, z.core.$strip>;
declare const ComposeManifestZod: z.ZodObject<{
    manifestVersion: z.ZodNumber;
    manifestHash: z.ZodString;
    flowSchema: z.ZodObject<{}, z.core.$loose>;
    operations: z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        description: z.ZodOptional<z.ZodString>;
        inputs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
            kind: z.ZodLiteral<"resource">;
            name: z.ZodString;
            accepts: z.ZodEnum<{
                native: "native";
                erc20: "erc20";
                any: "any";
            }>;
            mode: z.ZodEnum<{
                linear: "linear";
                copy: "copy";
            }>;
            optional: z.ZodOptional<z.ZodBoolean>;
        }, z.core.$strip>, z.ZodObject<{
            kind: z.ZodLiteral<"handle">;
            name: z.ZodString;
            type: z.ZodEnum<{
                string: "string";
                uint8: "uint8";
                uint16: "uint16";
                uint32: "uint32";
                uint64: "uint64";
                uint128: "uint128";
                uint256: "uint256";
                int128: "int128";
                int256: "int256";
                address: "address";
                bool: "bool";
                bytes: "bytes";
                bytes4: "bytes4";
                bytes32: "bytes32";
            }>;
            mode: z.ZodEnum<{
                linear: "linear";
                copy: "copy";
            }>;
            expose: z.ZodOptional<z.ZodBoolean>;
            units: z.ZodOptional<z.ZodEnum<{
                raw: "raw";
                wad: "wad";
                ray: "ray";
                bps: "bps";
                "token-decimals": "token-decimals";
            }>>;
        }, z.core.$strip>], "kind">>;
        outputs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
            kind: z.ZodLiteral<"resource_output">;
            name: z.ZodString;
            mode: z.ZodEnum<{
                linear: "linear";
                copy: "copy";
            }>;
            availability: z.ZodOptional<z.ZodEnum<{
                now: "now";
                future: "future";
            }>>;
            providesMinimum: z.ZodOptional<z.ZodBoolean>;
            omitIfZero: z.ZodOptional<z.ZodBoolean>;
            deliveryAddressInput: z.ZodOptional<z.ZodString>;
        }, z.core.$strip>, z.ZodObject<{
            kind: z.ZodLiteral<"handle">;
            name: z.ZodString;
            type: z.ZodEnum<{
                string: "string";
                uint8: "uint8";
                uint16: "uint16";
                uint32: "uint32";
                uint64: "uint64";
                uint128: "uint128";
                uint256: "uint256";
                int128: "int128";
                int256: "int256";
                address: "address";
                bool: "bool";
                bytes: "bytes";
                bytes4: "bytes4";
                bytes32: "bytes32";
            }>;
            mode: z.ZodEnum<{
                linear: "linear";
                copy: "copy";
            }>;
            expose: z.ZodOptional<z.ZodBoolean>;
            units: z.ZodOptional<z.ZodEnum<{
                raw: "raw";
                wad: "wad";
                ray: "ray";
                bps: "bps";
                "token-decimals": "token-decimals";
            }>>;
        }, z.core.$strip>], "kind">>;
        configSchema: z.ZodOptional<z.ZodUnknown>;
    }, z.core.$strip>>;
    guards: z.ZodArray<z.ZodObject<{
        kind: z.ZodString;
        description: z.ZodOptional<z.ZodString>;
        configSchema: z.ZodOptional<z.ZodUnknown>;
        compatibility: z.ZodOptional<z.ZodObject<{
            selectors: z.ZodArray<z.ZodObject<{
                binding: z.ZodString;
                source: z.ZodEnum<{
                    inputs: "inputs";
                    outputs: "outputs";
                }>;
                match: z.ZodObject<{
                    kind: z.ZodUnion<readonly [z.ZodEnum<{
                        resource: "resource";
                        handle: "handle";
                        resource_output: "resource_output";
                    }>, z.ZodArray<z.ZodEnum<{
                        resource: "resource";
                        handle: "handle";
                        resource_output: "resource_output";
                    }>>]>;
                    mode: z.ZodOptional<z.ZodEnum<{
                        linear: "linear";
                        copy: "copy";
                    }>>;
                    type: z.ZodOptional<z.ZodEnum<{
                        native: "native";
                        erc20: "erc20";
                        any: "any";
                    }>>;
                }, z.core.$strip>;
                selection: z.ZodDiscriminatedUnion<[z.ZodObject<{
                    kind: z.ZodLiteral<"config">;
                    configKey: z.ZodString;
                    cardinality: z.ZodEnum<{
                        one: "one";
                        many: "many";
                    }>;
                }, z.core.$strip>, z.ZodObject<{
                    kind: z.ZodLiteral<"all_matching">;
                }, z.core.$strip>], "kind">;
            }, z.core.$strip>>;
        }, z.core.$strip>>;
    }, z.core.$strip>>;
    materialisers: z.ZodArray<z.ZodObject<{
        kind: z.ZodString;
        description: z.ZodOptional<z.ZodString>;
        accepts: z.ZodEnum<{
            resource: "resource";
            any: "any";
            handle: "handle";
        }>;
        configSchema: z.ZodOptional<z.ZodUnknown>;
    }, z.core.$strip>>;
    preconditions: z.ZodOptional<z.ZodArray<z.ZodObject<{
        type: z.ZodString;
        description: z.ZodOptional<z.ZodString>;
        configSchema: z.ZodOptional<z.ZodUnknown>;
    }, z.core.$strip>>>;
}, z.core.$strip>;
type ResourcePort = z.infer<typeof ResourcePortZod>;
type HandlePort = z.infer<typeof HandlePortZod>;
type HandleUnits = z.infer<typeof HandleUnitsZod>;
type StaticSolType = z.infer<typeof StaticSolTypeZod>;
type OpInputPort = z.infer<typeof InputPortZod>;
type ResourceOutputPort = z.infer<typeof ResourceOutputPortZod>;
type OpOutputPort = z.infer<typeof OutputPortZod>;
type ManifestOperation = z.infer<typeof ManifestOperationZod>;
type GuardSelector = z.infer<typeof GuardSelectorZod>;
type GuardCompatibility = z.infer<typeof GuardCompatibilityZod>;
type ManifestGuard = z.infer<typeof ManifestGuardZod>;
type ManifestMaterialiser = z.infer<typeof ManifestMaterialiserZod>;
type ManifestPrecondition = z.infer<typeof ManifestPreconditionZod>;
type ComposeManifest = z.infer<typeof ComposeManifestZod>;

interface Port {
    readonly name: string;
    readonly type: SolType;
    readonly mode: "linear" | "copy";
    readonly availability?: Availability;
    readonly resource?: Resource;
}
declare const isResourceInput: (input: FlowInput) => input is ResourceInput;
declare const flowInputType: (input: FlowInput) => SolType;
declare const flowInputMode: (input: FlowInput) => "linear" | "copy";
declare const flowInputResource: (input: FlowInput) => Resource | undefined;
declare const isResourcePort: (port: OpInputPort) => port is ResourcePort;
declare const isHandlePort: (port: OpInputPort | OpOutputPort) => port is HandlePort;
declare const isResourceOutputPort: (port: OpInputPort | OpOutputPort) => port is ResourceOutputPort;
type ComposeErrorKind = "decode_error" | "validation_error" | "linearity_error" | "resolve_error" | "preparation_error" | "provider_error" | "no_route_error" | "lowering_error" | "simulation_error" | "simulation_setup_error" | "simulation_revert" | "subgraph_simulation_revert" | "guard_error" | "continuation_error" | "compilation_error" | "verification_error" | "price_impact_exceeded" | "fee_resolution_error" | "fee_resolution_unavailable" | "flashloan_unauthorized";
type GenericComposeErrorKind = Exclude<ComposeErrorKind, "preparation_error" | "simulation_revert">;
interface FailedPreparedOp {
    readonly callId: string;
    readonly op: string;
    readonly kind: GenericComposeErrorKind;
    readonly message: string;
    readonly path?: string;
}
interface ComposeErrorBase {
    readonly message: string;
    readonly path?: string;
}
interface PreparationComposeError extends ComposeErrorBase {
    readonly kind: "preparation_error";
    readonly failedOps: readonly FailedPreparedOp[];
    readonly succeededOps: readonly string[];
}
interface SimulationRevertComposeError extends ComposeErrorBase {
    readonly kind: "simulation_revert";
    readonly details?: SimulationRevert;
}
interface GenericComposeError extends ComposeErrorBase {
    readonly kind: GenericComposeErrorKind;
    readonly [key: string]: unknown;
}
type ComposeError = PreparationComposeError | SimulationRevertComposeError | GenericComposeError;
interface MaterialiserInputBase {
    readonly kind: string;
}
type MaterialiserInput = MaterialiserInputBase & Record<string, unknown>;
type MaterialiserInputOf<C extends object> = MaterialiserInputBase & C;
type MaterialiserConfigOf<C extends object> = C;
declare const isMaterialiserInput: (s: InputSpec) => s is MaterialiserInput;
type InputSpec = bigint | string | MaterialiserInput;
interface PreconditionBase {
    readonly type: string;
}
type Precondition = PreconditionBase & Record<string, unknown>;
type PreconditionOf<C extends object> = PreconditionBase & C;
type PreconditionConfigOf<C extends object> = Omit<PreconditionBase, "type"> & C;

declare const PROVIDER_KIND: {
    readonly AAVE_V3: 0;
    readonly ERC3156: 1;
    readonly BALANCER_V2: 2;
    readonly MORPHO_BLUE: 3;
};
declare const providerKindNames: readonly ["aave-v3", "erc3156", "balancer-v2", "morpho-blue"];
type ProviderKindName = (typeof providerKindNames)[number];
declare const providerKindByName: Record<ProviderKindName, number>;
interface FlashloanMaterialiserInput {
    readonly kind: "flashloan";
    readonly providerKind: ProviderKindName;
    readonly amount: string;
}

interface OpHandleOptions {
    readonly expose?: boolean;
    readonly units?: HandleUnits;
}
declare const inputRef: (port: string) => Ref;
declare const outputRef: (node: string, port: string) => Ref;
declare const linear: <N extends string, T extends SolType>(name: N, type: T) => Port & {
    readonly name: N;
    readonly type: T;
    readonly mode: "linear";
};
declare const copy: <N extends string, T extends SolType>(name: N, type: T) => Port & {
    readonly name: N;
    readonly type: T;
    readonly mode: "copy";
};
declare const handle: <N extends string, T extends SolType>(name: N, type: T) => HandleInput & {
    readonly name: N;
    readonly type: T;
};
declare const native: <N extends string>(name: N, chainId: number) => ResourceInput & {
    readonly name: N;
};
declare const erc20: <N extends string>(name: N, token: string, chainId: number) => ResourceInput & {
    readonly name: N;
};
declare const resource: <N extends string, Opt extends boolean = false>(name: N, accepts: "erc20" | "native" | "any", options?: {
    optional?: Opt;
}) => ResourcePort & {
    readonly name: N;
    readonly optional: Opt;
};
declare const readResource: <N extends string>(name: N, accepts: "erc20" | "native" | "any") => ResourcePort & {
    readonly name: N;
    readonly mode: "copy";
};
declare const opHandle: <N extends string, T extends SolType>(name: N, type: T, options?: OpHandleOptions) => HandlePort & {
    readonly name: N;
    readonly type: T;
};
declare const resourceOutput: <N extends string>(name: N, options?: Availability | {
    availability?: Availability;
    providesMinimum?: boolean;
    omitIfZero?: boolean;
    deliveryAddressInput?: string;
}) => ResourceOutputPort & {
    readonly name: N;
};

type ParsedRef = {
    readonly scope: "input";
    readonly port: string;
} | {
    readonly scope: "output";
    readonly node: string;
    readonly port: string;
} | {
    readonly scope: "context";
    readonly key: ContextKey;
};
type RefScope = ParsedRef["scope"];
type ContextKey = "sender" | "executionAddress";
declare const isContextKey: (key: string) => key is ContextKey;
/**
 * Ref prefixes that parseRef intercepts before the fallback `output` scope.
 * A node whose id matches one of these would produce ambiguous refs
 * (e.g. `context.sender` could be a context ref or node-output ref).
 * Validation must reject these as node ids.
 */
declare const RESERVED_REF_SCOPES: ReadonlySet<string>;
declare const isRef: (v: unknown) => v is Ref;
declare const parseRef: (ref: Ref) => ParsedRef;
declare const foldRef: <R>(ref: ParsedRef, cases: {
    readonly input: (port: string) => R;
    readonly context: (key: ContextKey) => R;
    readonly output: (node: string, port: string) => R;
}) => R;
declare const refKey: (ref: Ref) => string;

/**
 * Canonical wire-format types for the standalone `POST /simulate` endpoint.
 *
 * `/simulate` takes a raw, pre-encoded transaction (a `to` address, hex `data`,
 * optional native `value`), funds a sender, runs it in one `eth_call`, and
 * reports the watched balances before and after, their signed deltas, and the
 * inner-call gas. Unlike `POST /compose`, its response body is **un-enveloped**:
 * `{ status, block, timestamp, ... }` lives at the top level (no `{ data }`
 * wrapper).
 *
 * These are the single source of truth for the request/response shapes. The
 * server-side Zod schemas in `@lifi/api-schemas` (`src/routes/simulate.ts`)
 * validate the same contract and are kept in lockstep by a compile-time
 * conformance assertion (`src/routes/simulate.typecheck.ts`).
 *
 * Mirrors the hand-authored style of `src/compile.ts`.
 */
/**
 * Maximum number of watched `(token, owner)` pairs accepted by `POST /simulate`.
 *
 * The limit comes from the VM's hard register budget (~123 usable registers,
 * checked on the final ISA layout). Each pair costs two result registers — a
 * before-read and an after-read — that are both live at the closing abi-encode,
 * so the compiler cannot coalesce them; that `2 × N` is the cost that scales.
 * Token and owner address literals do not scale it, since constant-propagation
 * merges identical-valued literals into one register. The cap leaves headroom
 * for the inner-call / gas-measurement / abi-encode scaffolding.
 */
declare const SIMULATE_MAX_TRACKED_BALANCES = 40;
/**
 * Maximum number of funding `requirements` accepted by `POST /simulate`.
 *
 * Each requirement triggers a slot-discovery cycle (access-list probe + sentinel
 * verification + RPC round trips) in slot-finder, so an unbounded array lets a
 * single request amplify into arbitrary upstream RPC work. Bounded here at the
 * trust boundary and re-enforced server-side in `rawSimulation.ts`.
 */
declare const SIMULATE_MAX_REQUIREMENTS = 40;
/** A `(token, owner)` pair whose balance is watched across the simulation. */
interface TrackedBalance {
    /** Token to watch (use the zero address for native balance). */
    readonly token: string;
    /** Account whose balance of `token` is watched. */
    readonly owner: string;
}
/**
 * Funding instruction: seed an ERC-20 balance on a wallet before simulation.
 * Amounts accept `bigint | string` — the SDK serialises `bigint` to a decimal
 * string; the string side covers values already stringified.
 */
interface Erc20BalanceRequirement {
    readonly type: "Erc20Balance";
    readonly wallet: string;
    readonly token: string;
    readonly balance: bigint | string;
}
/** Funding instruction: seed a native balance on a wallet before simulation. */
interface NativeBalanceRequirement {
    readonly type: "NativeBalance";
    readonly wallet: string;
    readonly balance: bigint | string;
}
/** Funding instruction: seed an ERC-20 allowance before simulation. */
interface Erc20AllowanceRequirement {
    readonly type: "Erc20Allowance";
    readonly owner: string;
    readonly spender: string;
    readonly token: string;
    readonly allowance: bigint | string;
}
/**
 * The funding-instruction union applied before a simulation. Three variants,
 * discriminated by `type`.
 */
type SlotFinderRequirement = Erc20BalanceRequirement | NativeBalanceRequirement | Erc20AllowanceRequirement;
/** Request body for `POST /simulate`. */
interface SimulateRequest {
    /** EVM chain id. */
    readonly chainId: number;
    /**
     * Sender of the simulated transaction. The VM bytecode is injected here so
     * the inner call carries `msg.sender == from`.
     */
    readonly from: string;
    /** Target contract of the raw transaction. */
    readonly to: string;
    /** Pre-encoded transaction calldata (`0x`-prefixed hex). */
    readonly data: string;
    /**
     * Native value (wei) sent with the inner call. Accepts `bigint | string`;
     * defaults to `"0"` server-side when omitted.
     */
    readonly value?: bigint | string;
    /**
     * Block number to simulate against. Omitted ⇒ the chain head. Named tags
     * (e.g. "latest") are rejected with HTTP 400.
     */
    readonly block?: number;
    /** Funding instructions applied before simulation (max 40). */
    readonly requirements?: readonly SlotFinderRequirement[];
    /** Balances to read before and after the transaction (1–40 pairs). */
    readonly trackedBalances: readonly TrackedBalance[];
}
/**
 * One watched balance in a simulation response. `amount` is a decimal string;
 * for `deltas` it is signed (`after - before`).
 */
interface SimulateBalanceEntry {
    readonly token: string;
    readonly owner: string;
    readonly amount: string;
}
/**
 * HTTP 200, `status: "ok"`: the simulation ran successfully. Balance arrays are
 * ordered to match the request `trackedBalances`. `gasUsed` is inner-call
 * execution gas only.
 *
 * Note: the array element types are intentionally mutable (`SimulateBalanceEntry[]`,
 * not `readonly SimulateBalanceEntry[]`) so they stay structurally identical to
 * the Zod-inferred wire types, which `z.array(...)` infers as mutable `T[]`. The
 * bidirectional conformance assertion in `@lifi/api-schemas` relies on this.
 */
interface SimulateOkResult {
    readonly status: "ok";
    readonly block: number;
    readonly timestamp: number;
    readonly balancesBefore: SimulateBalanceEntry[];
    readonly balancesAfter: SimulateBalanceEntry[];
    readonly deltas: SimulateBalanceEntry[];
    readonly gasUsed: string;
}
/** Decoded revert diagnostics, when slot-finder can parse the revert reason. */
interface SimulateRevertDecodeResult {
    readonly errorCandidates?: {
        readonly decodedErrorSignature: string;
        readonly decodedParams: string[];
    }[];
    readonly error?: string;
}
/**
 * HTTP 200, `status: "revert"`: the simulation ran but the transaction reverted
 * on-chain. A revert is a *successful simulation*, not a transport error.
 */
interface SimulateRevertResult {
    readonly status: "revert";
    readonly block: number;
    readonly timestamp: number;
    readonly revertReason?: string;
    readonly code?: number;
    readonly rawErrorBytes?: string;
    readonly decodeResult?: SimulateRevertDecodeResult;
}
/**
 * HTTP 422, `status: "error"`: the request was well-formed but the simulation
 * could not be set up or run. `message` is intentionally generic.
 */
interface SimulateSetupErrorResult {
    readonly status: "error";
    readonly message: string;
}
/**
 * Discriminated result of `POST /simulate`. `switch (result.status)` narrows to
 * one member: `ok` and `revert` come back with HTTP 200, `error` with HTTP 422.
 */
type SimulateResult = SimulateOkResult | SimulateRevertResult | SimulateSetupErrorResult;

type MaterialiserMetadata = {
    readonly kind: 'exact';
    readonly amount: bigint;
} | {
    readonly kind: 'exact-native';
    readonly amount: bigint;
} | {
    readonly kind: 'runtime';
};
interface MaterialiserResolution {
    readonly meta: MaterialiserMetadata;
    readonly preconditions: readonly Precondition[];
}
declare const foldMaterialiserMetadata: <R>(meta: MaterialiserMetadata, cases: {
    readonly exact: (amount: bigint) => R;
    readonly exactNative: (amount: bigint) => R;
    readonly runtime: () => R;
}) => R;

export { type AppliedGuard, AppliedGuardSchema, type ApprovalEntry, type Availability, type BindValue, BindValueSchema, type Call, CallSchema, type ComposeCompilePartialData, type ComposeCompileRequest, type ComposeCompileResult, type ComposeCompileSuccessData, type ComposeContinuation, type ComposeError, type ComposeErrorKind, type ComposeManifest, ComposeManifestZod, type ComposeRun, type ComposeTransactionRequest, type ContextKey, type Continuation, ContinuationSchema, type Erc20AllowanceRequirement, type Erc20BalanceRequirement, type FailedPreparedOp, type FlashloanMaterialiserInput, type Flow, type FlowInput, FlowInputSchema, FlowSchema, type GenericComposeError, type GenericComposeErrorKind, type GuardCompatibility, GuardCompatibilityZod, type GuardSelector, GuardSelectorZod, HANDLE_UNITS, type HandleInput, HandleInputSchema, type HandlePort, HandlePortZod, type HandleUnits, HandleUnitsZod, InputPortZod, type InputSpec, type LiteralBinding, LiteralBindingSchema, type ManifestGuard, ManifestGuardZod, type ManifestMaterialiser, ManifestMaterialiserZod, type ManifestOperation, ManifestOperationZod, type ManifestPrecondition, ManifestPreconditionZod, type MaterialiserConfigOf, type MaterialiserInput, type MaterialiserInputBase, type MaterialiserInputOf, type MaterialiserMetadata, type MaterialiserResolution, type NativeBalanceRequirement, type OpInputPort, type OpOutputPort, type OutputAmount, OutputPortZod, PROVIDER_KIND, type ParsedRef, type Port, type Precondition, type PreconditionBase, type PreconditionConfigOf, type PreconditionOf, type PreparationComposeError, type PriceImpact, type ProducedResource, type ProviderKindName, RESERVED_REF_SCOPES, type Ref, RefSchema, type RefScope, type Resource, type ResourceInput, ResourceInputSchema, type ResourceOutputPort, ResourceOutputPortZod, type ResourcePort, ResourcePortZod, ResourceSchema, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, STATIC_SOL_TYPES, type SimulateBalanceEntry, type SimulateOkResult, type SimulateRequest, type SimulateResult, type SimulateRevertDecodeResult, type SimulateRevertResult, type SimulateSetupErrorResult, type SimulatedAmounts, type SimulationPolicy, type SimulationRevert, type SimulationRevertComposeError, type SlotFinderRequirement, type SolType, SolTypeSchema, type StaticSolType, StaticSolTypeZod, type SweepTo, type TrackedBalance, copy, erc20, erc20Resource, erc20Token, flowInputMode, flowInputResource, flowInputType, foldMaterialiserMetadata, foldRef, foldResource, handle, inputRef, isContextKey, isERC20Resource, isHandlePort, isMaterialiserInput, isNativeResource, isRef, isResourceInput, isResourceOutputPort, isResourcePort, isStaticSolType, linear, native, nativeResource, opHandle, outputRef, parseRef, providerKindByName, providerKindNames, readResource, refKey, resource, resourceKey, resourceOutput, resourcesEqual };
