UNPKG

@lifi/compose-spec

Version:

Public wire-format types and schemas for Compose flows

1,018 lines (1,007 loc) 38.4 kB
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; 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 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 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, STATIC_SOL_TYPES, type SimulatedAmounts, type SimulationPolicy, type SimulationRevert, type SimulationRevertComposeError, type SolType, SolTypeSchema, type StaticSolType, StaticSolTypeZod, type SweepTo, 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 };