@lifi/compose-spec
Version:
Public wire-format types and schemas for Compose flows
2,451 lines • 95 kB
TypeScript
import { ParseResult, Schema } from "effect";
import z from "zod";
//#region src/flowSchema.d.ts
export declare const SolTypeSchema: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
export declare const EVMAddressString: Schema.refine<string, typeof Schema.String>;
export declare const IntegerString: Schema.filter<typeof Schema.String>;
/**
* THE chain-capabilities chokepoint.
*
* `ResourceSchema` is a decode transform: it parses the plain `native | erc20`
* wire union (`RawResourceSchema`) and then runs `normalizeResource`, so on
* `as-erc20` chains (e.g. Tempo) a `{ kind: "native", chainId }` resource is
* rewritten to its ERC-20 form (PathUSD) before any application code sees it.
* Because every Resource-bearing schema embeds this one — `FlowSchema` for flow
* inputs, op `configSchema`s for op configs — making the schema itself
* chain-aware covers every parsed entry point in one place.
*
* The `encode` direction is the identity: the ERC-20 form is itself valid wire
* format, and the rewrite is deliberately not reversible (we never want to
* re-introduce a `native` resource when serialising). `JSONSchema.make` derives
* the published wire format from the encoded (`from`) side, so the manifest
* keeps advertising the plain union with both arms.
*/
export declare const ResourceSchema: Schema.transform<Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["native"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>, Schema.Struct<{
kind: Schema.Literal<["erc20"]>;
token: Schema.refine<string, typeof Schema.String>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>]>, Schema.SchemaClass<{
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, {
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, never>>;
export declare const ResourceInputSchema: Schema.Struct<{
name: typeof Schema.String;
resource: Schema.transform<Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["native"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>, Schema.Struct<{
kind: Schema.Literal<["erc20"]>;
token: Schema.refine<string, typeof Schema.String>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>]>, Schema.SchemaClass<{
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, {
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, never>>;
}>;
export 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"]>;
}>;
export declare const FlowInputSchema: Schema.Union<[Schema.Struct<{
name: typeof Schema.String;
resource: Schema.transform<Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["native"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>, Schema.Struct<{
kind: Schema.Literal<["erc20"]>;
token: Schema.refine<string, typeof Schema.String>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>]>, Schema.SchemaClass<{
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, {
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, never>>;
}>, Schema.Struct<{
name: typeof Schema.String;
type: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
}>]>;
export declare const RefSchema: Schema.Struct<{
$ref: Schema.filter<typeof Schema.String>;
}>;
export 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;
}>;
export 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;
}>]>;
export declare const AppliedGuardSchema: Schema.TypeLiteral<{
kind: typeof Schema.String;
}, readonly [{
readonly key: typeof Schema.String;
readonly value: typeof Schema.Unknown;
}]>;
export declare const CallSchema: Schema.Struct<{
id: Schema.filter<Schema.filter<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;
}]>>>;
}>;
export declare const UuidSchema: Schema.filter<typeof Schema.String>;
export declare const LineageSchema: Schema.Struct<{
journeyId: Schema.filter<typeof Schema.String>;
parentRequestId: Schema.filter<typeof Schema.String>;
}>;
export declare const ForwardToSchema: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
$ref: Schema.filter<typeof Schema.String>;
}>]>;
export declare const EpilogueForwardSchema: Schema.Struct<{
resource: Schema.transform<Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["native"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>, Schema.Struct<{
kind: Schema.Literal<["erc20"]>;
token: Schema.refine<string, typeof Schema.String>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>]>, Schema.SchemaClass<{
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, {
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, never>>;
to: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
$ref: Schema.filter<typeof Schema.String>;
}>]>;
}>;
export declare const EpilogueSchema: Schema.filter<Schema.Struct<{
forwards: Schema.optional<Schema.NonEmptyArray<Schema.Struct<{
resource: Schema.transform<Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["native"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>, Schema.Struct<{
kind: Schema.Literal<["erc20"]>;
token: Schema.refine<string, typeof Schema.String>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>]>, Schema.SchemaClass<{
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, {
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, never>>;
to: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
$ref: Schema.filter<typeof Schema.String>;
}>]>;
}>>>;
remainder: Schema.optional<Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
$ref: Schema.filter<typeof Schema.String>;
}>]>>;
}>>;
export 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.transform<Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["native"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>, Schema.Struct<{
kind: Schema.Literal<["erc20"]>;
token: Schema.refine<string, typeof Schema.String>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>]>, Schema.SchemaClass<{
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, {
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, never>>;
}>, 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: Schema.filter<Schema.filter<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;
}]>>>;
}>>;
lineage: Schema.optional<Schema.Struct<{
journeyId: Schema.filter<typeof Schema.String>;
parentRequestId: Schema.filter<typeof Schema.String>;
}>>;
epilogue: Schema.optional<Schema.filter<Schema.Struct<{
forwards: Schema.optional<Schema.NonEmptyArray<Schema.Struct<{
resource: Schema.transform<Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["native"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>, Schema.Struct<{
kind: Schema.Literal<["erc20"]>;
token: Schema.refine<string, typeof Schema.String>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>]>, Schema.SchemaClass<{
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, {
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, never>>;
to: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
$ref: Schema.filter<typeof Schema.String>;
}>]>;
}>>>;
remainder: Schema.optional<Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
$ref: Schema.filter<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 Lineage = typeof LineageSchema.Type;
type ForwardTo = typeof ForwardToSchema.Type;
type EpilogueForward = typeof EpilogueForwardSchema.Type;
type Epilogue = typeof EpilogueSchema.Type;
type Flow = typeof FlowSchema.Type;
//#endregion
//#region src/continuation.d.ts
export declare const CONTINUATION_COMMITMENT_OP_ID = "continuation.commitment";
export declare const ContinuationOutcomeSchema: Schema.transform<Schema.Schema<{
readonly chainId: number;
readonly token: string;
readonly minAmount?: string | undefined;
readonly destination: string;
}, {
readonly chainId: number;
readonly token: string;
readonly destination: string;
readonly minAmount?: string | undefined;
}, never>, Schema.SchemaClass<{
readonly chainId: number;
readonly token: string;
readonly minAmount?: string | undefined;
readonly destination: string;
}, {
readonly chainId: number;
readonly token: string;
readonly minAmount?: string | undefined;
readonly destination: string;
}, never>>;
export declare const CommittedOutcomeSchema: Schema.transform<Schema.Schema<{
readonly chainId: number;
readonly token: string;
readonly minAmount: string;
readonly destination: string;
}, {
readonly chainId: number;
readonly token: string;
readonly minAmount: string;
readonly destination: string;
}, never>, Schema.SchemaClass<{
readonly chainId: number;
readonly token: string;
readonly minAmount: string;
readonly destination: string;
}, {
readonly chainId: number;
readonly token: string;
readonly minAmount: string;
readonly destination: string;
}, never>>;
export declare const ContinuationIntentSchema: Schema.Struct<{
outcomes: Schema.Array$<Schema.transform<Schema.Schema<{
readonly chainId: number;
readonly token: string;
readonly minAmount?: string | undefined;
readonly destination: string;
}, {
readonly chainId: number;
readonly token: string;
readonly destination: string;
readonly minAmount?: string | undefined;
}, never>, Schema.SchemaClass<{
readonly chainId: number;
readonly token: string;
readonly minAmount?: string | undefined;
readonly destination: string;
}, {
readonly chainId: number;
readonly token: string;
readonly minAmount?: string | undefined;
readonly destination: string;
}, never>>>;
continuationFlow: Schema.optional<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.transform<Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["native"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>, Schema.Struct<{
kind: Schema.Literal<["erc20"]>;
token: Schema.refine<string, typeof Schema.String>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>]>, Schema.SchemaClass<{
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, {
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, never>>;
}>, 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: Schema.filter<Schema.filter<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;
}]>>>;
}>>;
lineage: Schema.optional<Schema.Struct<{
journeyId: Schema.filter<typeof Schema.String>;
parentRequestId: Schema.filter<typeof Schema.String>;
}>>;
epilogue: Schema.optional<Schema.filter<Schema.Struct<{
forwards: Schema.optional<Schema.NonEmptyArray<Schema.Struct<{
resource: Schema.transform<Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["native"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>, Schema.Struct<{
kind: Schema.Literal<["erc20"]>;
token: Schema.refine<string, typeof Schema.String>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>]>, Schema.SchemaClass<{
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, {
readonly kind: "native";
readonly chainId: number;
} | {
readonly kind: "erc20";
readonly chainId: number;
readonly token: string;
}, never>>;
to: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
$ref: Schema.filter<typeof Schema.String>;
}>]>;
}>>>;
remainder: Schema.optional<Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
$ref: Schema.filter<typeof Schema.String>;
}>]>>;
}>>>;
}>>;
validity: Schema.Struct<{
expiresAtMs: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>;
provider: Schema.optional<typeof Schema.String>;
funding: Schema.optional<Schema.Literal<["inline", "external"]>>;
refund: Schema.optional<Schema.filter<Schema.refine<string, typeof Schema.String>>>;
exact: Schema.optional<typeof Schema.Boolean>;
}>;
export declare const HexStringSchema: Schema.filter<typeof Schema.String>;
export declare const Phase1ArtifactSchema: Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["transaction"]>;
funding: Schema.Literal<["inline", "external", "delivered"]>;
transactionRequest: Schema.optional<Schema.Struct<{
to: typeof Schema.String;
data: typeof Schema.String;
value: typeof Schema.String;
chainId: typeof Schema.Number;
}>>;
escrow: Schema.optional<Schema.Struct<{
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
address: Schema.filter<typeof Schema.String>;
token: Schema.filter<typeof Schema.String>;
amount: typeof Schema.String;
cap: typeof Schema.String;
floor: typeof Schema.String;
owner: Schema.filter<typeof Schema.String>;
refund: Schema.filter<typeof Schema.String>;
expiresAtMs: Schema.filter<Schema.filter<typeof Schema.Number>>;
}>>;
binding: Schema.optional<Schema.Struct<{
executionTarget: Schema.filter<typeof Schema.String>;
payload: Schema.filter<typeof Schema.String>;
payloadHash: Schema.filter<typeof Schema.String>;
calldata: Schema.filter<typeof Schema.String>;
approvals: Schema.Array$<Schema.Struct<{
token: Schema.filter<typeof Schema.String>;
spender: Schema.filter<typeof Schema.String>;
}>>;
}>>;
}>, Schema.Struct<{
kind: Schema.Literal<["signables"]>;
typedData: Schema.Array$<typeof Schema.Unknown>;
}>, Schema.Struct<{
kind: Schema.Literal<["none"]>;
}>]>;
export declare const AssertionOwnerSchema: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Literal<["escrow", "delivery"]>]>;
type AssertionOwner = typeof AssertionOwnerSchema.Type;
export declare const Erc20BalanceGteSpecSchema: Schema.Struct<{
kind: Schema.Literal<["erc20BalanceGte"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
token: Schema.refine<string, typeof Schema.String>;
owner: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Literal<["escrow", "delivery"]>]>;
minAmount: Schema.filter<typeof Schema.String>;
}>;
export declare const NativeBalanceGteSpecSchema: Schema.Struct<{
kind: Schema.Literal<["nativeBalanceGte"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
owner: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Literal<["escrow", "delivery"]>]>;
minAmount: Schema.filter<typeof Schema.String>;
}>;
export declare const CallCheckSpecSchema: Schema.Struct<{
kind: Schema.Literal<["call"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
to: Schema.refine<string, typeof Schema.String>;
signature: typeof Schema.String;
args: Schema.Array$<typeof Schema.String>;
comparator: Schema.Literal<["gte", "eq", "lte"]>;
threshold: Schema.filter<typeof Schema.String>;
}>;
export declare const AssertionSpecSchema: Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["erc20BalanceGte"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
token: Schema.refine<string, typeof Schema.String>;
owner: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Literal<["escrow", "delivery"]>]>;
minAmount: Schema.filter<typeof Schema.String>;
}>, Schema.Struct<{
kind: Schema.Literal<["nativeBalanceGte"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
owner: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Literal<["escrow", "delivery"]>]>;
minAmount: Schema.filter<typeof Schema.String>;
}>, Schema.Struct<{
kind: Schema.Literal<["call"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
to: Schema.refine<string, typeof Schema.String>;
signature: typeof Schema.String;
args: Schema.Array$<typeof Schema.String>;
comparator: Schema.Literal<["gte", "eq", "lte"]>;
threshold: Schema.filter<typeof Schema.String>;
}>]>;
type ContinuationOutcome = typeof ContinuationOutcomeSchema.Type;
type CommittedOutcome = typeof CommittedOutcomeSchema.Type;
type ContinuationIntent = typeof ContinuationIntentSchema.Type;
type Phase1Artifact = typeof Phase1ArtifactSchema.Type;
type AssertionSpec = typeof AssertionSpecSchema.Type;
type CallCheckSpec = typeof CallCheckSpecSchema.Type;
export declare const settledOutcome: <I extends {
readonly outcomes: readonly unknown[];
}>(intent: I) => I["outcomes"][number] | undefined;
//#endregion
//#region src/descriptor.d.ts
export declare const Bytes32HexSchema: Schema.filter<typeof Schema.String>;
export declare const AssertedPredicateSchema: Schema.transformOrFail<Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["erc20BalanceGte"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
token: Schema.refine<string, typeof Schema.String>;
owner: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Literal<["escrow", "delivery"]>]>;
minAmount: Schema.filter<typeof Schema.String>;
}>, Schema.Struct<{
kind: Schema.Literal<["nativeBalanceGte"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
owner: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Literal<["escrow", "delivery"]>]>;
minAmount: Schema.filter<typeof Schema.String>;
}>, Schema.Struct<{
kind: Schema.Literal<["call"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
to: Schema.refine<string, typeof Schema.String>;
signature: typeof Schema.String;
args: Schema.Array$<typeof Schema.String>;
comparator: Schema.Literal<["gte", "eq", "lte"]>;
threshold: Schema.filter<typeof Schema.String>;
}>]>, Schema.SchemaClass<{
readonly kind: "nativeBalanceGte";
readonly chainId: number;
readonly minAmount: string;
readonly owner: string;
} | {
readonly kind: "erc20BalanceGte";
readonly chainId: number;
readonly token: string;
readonly minAmount: string;
readonly owner: string;
} | {
readonly kind: "call";
readonly chainId: number;
readonly to: string;
readonly signature: string;
readonly args: readonly string[];
readonly comparator: "gte" | "eq" | "lte";
readonly threshold: string;
}, {
readonly kind: "nativeBalanceGte";
readonly chainId: number;
readonly minAmount: string;
readonly owner: string;
} | {
readonly kind: "erc20BalanceGte";
readonly chainId: number;
readonly token: string;
readonly minAmount: string;
readonly owner: string;
} | {
readonly kind: "call";
readonly chainId: number;
readonly to: string;
readonly signature: string;
readonly args: readonly string[];
readonly comparator: "gte" | "eq" | "lte";
readonly threshold: string;
}, never>, never>;
export declare const VerificationDescriptorSchema: Schema.Struct<{
validationProgramHash: Schema.filter<typeof Schema.String>;
paramsHash: Schema.filter<typeof Schema.String>;
assertedPredicate: Schema.Array$<Schema.transformOrFail<Schema.Union<[Schema.Struct<{
kind: Schema.Literal<["erc20BalanceGte"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
token: Schema.refine<string, typeof Schema.String>;
owner: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Literal<["escrow", "delivery"]>]>;
minAmount: Schema.filter<typeof Schema.String>;
}>, Schema.Struct<{
kind: Schema.Literal<["nativeBalanceGte"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
owner: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Literal<["escrow", "delivery"]>]>;
minAmount: Schema.filter<typeof Schema.String>;
}>, Schema.Struct<{
kind: Schema.Literal<["call"]>;
chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
to: Schema.refine<string, typeof Schema.String>;
signature: typeof Schema.String;
args: Schema.Array$<typeof Schema.String>;
comparator: Schema.Literal<["gte", "eq", "lte"]>;
threshold: Schema.filter<typeof Schema.String>;
}>]>, Schema.SchemaClass<{
readonly kind: "nativeBalanceGte";
readonly chainId: number;
readonly minAmount: string;
readonly owner: string;
} | {
readonly kind: "erc20BalanceGte";
readonly chainId: number;
readonly token: string;
readonly minAmount: string;
readonly owner: string;
} | {
readonly kind: "call";
readonly chainId: number;
readonly to: string;
readonly signature: string;
readonly args: readonly string[];
readonly comparator: "gte" | "eq" | "lte";
readonly threshold: string;
}, {
readonly kind: "nativeBalanceGte";
readonly chainId: number;
readonly minAmount: string;
readonly owner: string;
} | {
readonly kind: "erc20BalanceGte";
readonly chainId: number;
readonly token: string;
readonly minAmount: string;
readonly owner: string;
} | {
readonly kind: "call";
readonly chainId: number;
readonly to: string;
readonly signature: string;
readonly args: readonly string[];
readonly comparator: "gte" | "eq" | "lte";
readonly threshold: string;
}, never>, never>>;
}>;
export declare const canonicalAssertedPredicate: (specs: readonly AssertionSpec[]) => string;
type VerificationDescriptor = typeof VerificationDescriptorSchema.Type;
type AssertedPredicate = AssertionSpec;
//#endregion
//#region src/resource.d.ts
type Availability = 'now' | 'future';
interface OutputAmount {
readonly expected: bigint;
readonly min?: bigint;
}
interface NativeResource {
readonly kind: 'native';
readonly chainId: number;
}
interface ERC20Resource {
readonly kind: 'erc20';
readonly token: string;
readonly chainId: number;
}
type Resource = NativeResource | ERC20Resource;
export declare const erc20Resource: (token: string, chainId: number) => Resource;
export declare const nativeResource: (chainId: number) => Resource;
export declare const isERC20Resource: (r: Resource) => r is ERC20Resource;
export declare const isNativeResource: (r: Resource) => r is NativeResource;
export declare const resourcesEqual: (a: Resource, b: Resource) => boolean;
export declare const foldResource: <R>(r: Resource, cases: {
readonly native: (r: NativeResource) => R;
readonly erc20: (r: ERC20Resource) => R;
}) => R;
export declare const resourceToken: (r: Resource) => string;
export declare const resourceKey: (r: Resource) => string;
export declare const erc20Token: (r: Resource) => string;
//#endregion
//#region src/output.d.ts
type EstimateBasis = 'simulated' | 'quoted';
type MinimumBasis = 'guard' | 'op' | 'input' | 'declared';
interface Estimate {
readonly basis: EstimateBasis;
readonly value: bigint;
}
interface Minimum {
readonly basis: MinimumBasis;
readonly value: bigint;
}
interface Amount {
readonly estimate?: Estimate;
readonly minimum?: Minimum;
}
type Delivery = {
readonly when: 'now';
} | {
readonly when: 'future';
readonly etaSeconds?: number;
readonly provider?: string;
readonly trackingId?: string;
};
interface OutputBase {
readonly resource: Resource;
readonly amount: Amount;
}
interface ConsumedOutput extends OutputBase {
readonly role: 'consumed';
readonly consumedBy: string;
}
interface TerminalOutput extends OutputBase {
readonly role: 'terminal';
readonly owner: string;
readonly delivery: Delivery;
}
type Output = ConsumedOutput | TerminalOutput;
type Outputs = Record<string, Output>;
//#endregion
//#region src/zodSchemas.d.ts
export 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>;
export declare const HANDLE_UNITS: readonly ["raw", "wad", "ray", "bps", "token-decimals"];
export declare const STATIC_SOL_TYPES: readonly ["uint256", "uint128", "uint64", "uint32", "uint16", "uint8", "address", "bool", "bytes32"];
export declare const HandleUnitsZod: z.ZodEnum<{
raw: "raw";
wad: "wad";
ray: "ray";
bps: "bps";
"token-decimals": "token-decimals";
}>;
export declare const StaticSolTypeZod: z.ZodEnum<{
uint8: "uint8";
uint16: "uint16";
uint32: "uint32";
uint64: "uint64";
uint128: "uint128";
uint256: "uint256";
address: "address";
bool: "bool";
bytes32: "bytes32";
}>;
export declare const isStaticSolType: (value: string) => value is StaticSolType;
export 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";
}>>;
optional: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>;
export 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";
}>>;
optional: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>], "kind">;
export 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>;
countFrom: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
export 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>;
countFrom: 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";
}>>;
optional: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>], "kind">;
export 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";
}>>;
optional: z.ZodOptional<z.ZodBoolean>;
}, 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>;
countFrom: 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";
}>>;
optional: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>], "kind">>;
configSchema: z.ZodOptional<z.ZodUnknown>;
}, z.core.$strip>;
export 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>;
export 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>;
export 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>;
export 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>;
export declare const ManifestPreconditionZod: z.ZodObject<{
type: z.ZodString;
description: z.ZodOptional<z.ZodString>;
configSchema: z.ZodOptional<z.ZodUnknown>;
}, z.core.$strip>;
export declare const ManifestRoutingZod: z.ZodObject<{
maxRouteHops: z.ZodNumber;
swapHops: z.ZodEnum<{
none: "none";
head: "head";
}>;
}, z.core.$strip>;
export 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";
}>>;
optional: z.ZodOptional<z.ZodBoolean>;
}, 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>;
countFrom: 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";
}>>;
optional: z.ZodOptional<z.ZodBoolean>;
}, 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>>>;
routing: z.ZodOptional<z.ZodObject<{
maxRouteHops: z.ZodNumber;
swapHops: z.ZodEnum<{
none: "none";
head: "head";
}>;
}, z.core.$strip>>;
}, z.core.$strip>;
declare const SettlementEscrowZod: z.ZodObject<{
chainId: z.ZodNumber;
address: z.ZodString;
token: z.ZodString;
amount: z.ZodString;
cap: z.ZodString;
floor: z.ZodString;
owner: z.ZodString;
refund: z.ZodString;
expiresAtMs: z.ZodNumber;
}, z.core.$strip>;
declare const SettlementBindingZod: z.ZodObject<{
executionTarget: z.ZodString;
payload: z.ZodString;
payloadHash: z.ZodString;
calldata: z.ZodString;
approvals: z.ZodReadonly<z.ZodArray<z.ZodObject<{
token: z.ZodString;
spender: z.ZodString;
}, z.core.$strip>>>;
}, z.core.$strip>;
export declare const AssertionSpecZod: z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"erc20BalanceGte">;
chainId: z.ZodNumber;
token: z.ZodString;
owner: z.ZodUnion<readonly [z.ZodString, z.ZodEnum<{
escrow: "escrow";
delivery: "delivery";
}>]>;
minAmount: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
kind: z.ZodLiteral<"nativeBalanceGte">;
chainId: z.ZodNumber;
owner: z.ZodUnion<readonly [z.ZodString, z.ZodEnum<{
escrow: "escrow";
delivery: "delivery";
}>]>;
minAmount: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
kind: z.ZodLiteral<"call">;
chainId: z.ZodNumber;
to: z.ZodString;
signature: z.ZodString;
args: z.ZodReadonly<z.ZodArray<z.ZodString>>;
comparator: z.ZodEnum<{
gte: "gte";
eq: "eq";
lte: "lte";
}>;
threshold: z.ZodString;
}, z.core.$strip>], "kind">;
type AssertionSpecWire = z.infer<typeof AssertionSpecZod>;
export declare const VerificationDescriptorZod: z.ZodObject<{
validationProgramHash: z.ZodString;
paramsHash: z.ZodString;
assertedPredicate: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"erc20BalanceGte">;
chainId: z.ZodNumber;
token: z.ZodString;
owner: z.ZodUnion<readonly [z.ZodString, z.ZodEnum<{
escrow: "escrow";
delivery: "delivery";
}>]>;
minAmount: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
kind: z.ZodLiteral<"nativeBalanceGte">;
chainId: z.ZodNumber;
owner: z.ZodUnion<readonly [z.ZodString, z.ZodEnum<{
escrow: "escrow";
delivery: "delivery";
}>]>;
minAmount: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
kind: z.ZodLiteral<"call">;
chainId: z.ZodNumber;
to: z.ZodString;
signature: z.ZodString;
args: z.ZodReadonly<z.ZodArray<z.ZodString>>;
comparator: z.ZodEnum<{
gte: "gte";
eq: "eq";
lte: "lte";
}>;
threshold: z.ZodString;
}, z.core.$strip>], "kind">>>;
}, z.core.$strip>;
type VerificationDescriptorWire = z.infer<typeof VerificationDescriptorZod>;
export declare const SettlementZod: z.ZodObject<{
escrow: z.ZodOptional<z.ZodObject<{
chainId: z.ZodNumber;
address: z.ZodString;
token: z.ZodString;
amount: z.ZodString;
cap: z.ZodString;
floor: z.ZodString;
owner: z.ZodString;
refund: z.ZodString;
expiresAtMs: z.ZodNumber;
}, z.core.$strip>>;
binding: z.ZodOptional<z.ZodObject<{
executionTarget: z.ZodString;
payload: z.ZodString;
payloadHash: z.ZodString;
calldata: z.ZodString;
approvals: z.ZodReadonly<z.ZodArray<z.ZodObject<{
token: z.ZodString;
spender: z.ZodString;
}, z.core.$strip>>>;
}, z.core.$strip>>;
}, z.core.$strip>;
export declare const ShortfallZod: z.ZodObject<{
required: z.ZodString;
available: z.ZodString;
}, 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 ManifestRouting = z.infer<typeof ManifestRoutingZod>;
type ComposeManifest = z.infer<typeof ComposeManifestZod>;
type SettlementEscrowWire = z.infer<typeof SettlementEscrowZod>;
type SettlementBindingWire = z.infer<typeof SettlementBindingZod>;
type SettlementWire = z.infer<typeof SettlementZod>;
type Shortfall = z.infer<typeof ShortfallZod>;
//#endregion
//#region src/compile.d.ts
type SimulationPolicy = 'strict' | 'allow-revert';
interface ComposeRun {
readonly inputs: Record<string, InputSpec>;
readonly preconditions?: readonly Precondition[];
readonly signer: string;
readonly assumptions?: Record<string, bigint>;
readonly referrer?: string;
readonly maxPriceImpactBps?: number;
readonly sweepTo?: ForwardTo;
readonly simulationPolicy?: SimulationPolicy;
/**
* Also simulate the final user-facing transaction. Defaults to `false`;
* reverts honour `simulationPolicy` and a success is echoed back as
* `userProgramSimulation`.
*/
readonly simulateUserProgram?: boolean;
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 chainId: number;
readonly data: string;
readonly value: string;
readonly gasLimit?: string;
}
type ComposeAction = {
readonly kind: 'transaction';
readonly purpose: 'approval' | 'execute';
readonly submitter: 'signer' | 'anyone';
readonly transactionRequest: ComposeTransactionRequest;
} | {
readonly kind: 'transaction';
readonly purpose: 'fundEscrow';
readonly submitter: 'signer' | 'anyone';
readonly transactionRequest: ComposeTransactionRequest;
readonly nodeId: string;
} | {
readonly kind: 'typedData';
readonly purpose: 'signOrder';
readonly submitter: 'signer';
readonly nodeId: string;
readonly typedData: readonly unknown[];
};
interface ComposeContinuationData {
readonly settlements?: Record<string, SettlementWire>;
}
interface SpendEntry {
readonly input: string;
readonly token: string;
readonly chainId: number;
readonly amount: string;
readonly nodeId?: string;
}
interface ComposeUserProgramSimulation {
readonly status: 'ok';
readonly returnData: string;
}
interface ComposeWarning {
readonly kind: string;
readonly message: string;
readonly path?: string;
readonly port?: string;
readonly fix?: string;
}
interface ComposeFill {
readonly spends: readonly SpendEntry[];
readonly validUntilMs?: number;
}
interface ExecutedForward {
readonly resource: Resource;
readonly to: string;
readonly amount: bigint;
}
interface ExecutedEpilogue {
readonly forwards: readonly ExecutedForward[];
readonly remainder?: string;
}
interface ComposeCompileSuccessData extends ComposeContinuationData {
readonly outputs: Outputs;
readonly epilogue?: ExecutedEpilogue;
readonly transactionRequest?: ComposeTransactionRequest;
readonly actions?: readonly ComposeAction[];
readonly userProxy: string;
readonly priceImpact?: PriceImpact;
readonly approvals?: readonly ApprovalEntry[];
readonly userProgramSimulation?: ComposeUserProgramSimulation;
readonly fill?: ComposeFill;
readonly verificationByNode?: Record<string, VerificationDescriptor>;
readonly warnings?: readonly ComposeWarning[];
}
interface ComposeCompilePartialData extends ComposeContinuationData {
readonly outputs: Outputs;
readonly transactionRequest: ComposeTransactionRequest;
readonly userProxy: string;
readonly simulationRevert: SimulationRevert;
readonly approvals?: readonly ApprovalEntry[];
readonly actions?: readonly ComposeAction[];
readonly userProgramSimulation?: ComposeUserProgramSimulation;
readonly warnings?: readonly ComposeWarning[];
}
type ComposeCompileResult = (ComposeCompileSuccessData & {
readonly status: 'success';
}) | (ComposeCompilePartialData & {
readonly status: 'partial';
readonly error: {
readonly kind: string;
readonly message: string;
};
});
//#endregion
//#region src/flow.d.ts
interface Port {
readonly name: string;
readonly type: SolType;
readonly mode: 'linear' | 'copy';
readonly availability?: Availability;
readonly resource?: Resource;
}
export declare const isResourceInput: (input: FlowInput) => input is ResourceInput;
export declare const flowInputType: (input: FlowInput) => SolType;
export declare const flowInputMode: (input: FlowInput) => "linear" | "copy";
export declare const flowInputResource: (input: FlowInput) => Resource | undefined;
export declare const isResourcePort: (port: OpInputPort) => port is ResourcePort;
export declare const isHandlePort: (port: OpInputPort | OpOutputPort) => port is HandlePort;
export declare const isResourceOutputPort: (port: OpInputPort | OpOutputPort) => port is ResourceOutputPort;
export declare const isFutureResourceOutput: (port: OpInputPort | OpOutputPort) => boolean;
type ComposeErrorKind = 'decode_error' | 'validation_error' | 'linearity_error' | 'resolve_error' | 'preparation_error' | 'provider_error' | 'no_route_error' | 'resolution_error' | 'resolution_rejected' | 'lowering_error' | 'empty_program' | 'simulation_error' | 'simulation_setup_error' | 'simulation_insufficient_funds' | 'simulation_gas_limit' | 'simulation_rpc_error' | 'simulation_revert' | 'subgraph_simulation_revert' | 'guard_error' | 'continuation_error' | 'compilation_error' | 'verification_error' | 'price_impact_exceeded' | 'flashloan_unauthorized' | 'delivery_error' | 'deadline_exceeded';
/**
* Errors raised by compose routes outside the compile pipeline.
*/
type ComposeRouteErrorKind = 'chain_validation_error' | 'unsupported_token' | 'zero_output' | 'service_unavailable' | 'verification_unavailable' | 'deployment_check_unavailable' | 'manifest_error' | 'sdk_outdated' | 'server_outdated';
type GenericComposeErrorKind = Exclude<ComposeErrorKind, 'preparation_error' | 'simulation_revert' | 'delivery_error'>;
interface FailedPreparedOp {
readonly callId: string;
readonly op: string;
readonly kind: GenericComposeErrorKind;
readonly message: string;
readonly path?: string;
readonly port?: string;
readonly fix?: string;
readonly shortfall?: Shortfall;
}
interface ComposeErrorBase {
readonly message: string;
readonly path?: string;
readonly port?: string;
readonly fix?: string;
readonly shortfall?: Shortfall;
}
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;
}
type DeliveryErrorReason = 'floor_drift' | 'eta_exceeds_expiry' | 'quote_failed';
interface DeliveryErrorDetails {
readonly reason: DeliveryErrorReason;
readonly cause?: ComposeErrorKind;
readonly quoted: {
readonly min: string;
readonly expected: string;
readonly etaSeconds?: number;
};
readonly escrow?: {
readonly chainId: number;
readonly address: string;
readonly floor: string;
readonly expiresAtMs: number;
};
}
interface DeliveryComposeError extends ComposeErrorBase {
readonly kind: 'delivery_error';
readonly details: DeliveryErrorDetails;
}
interface GenericComposeError extends ComposeErrorBase {
readonly kind: GenericComposeErrorKind;
readonly [key: string]: unknown;
}
type ComposeError = PreparationComposeError | SimulationRevertComposeError | DeliveryComposeError | 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;
export 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;
//#endregion
//#region src/flashloan.d.ts
export declare const PROVIDER_KIND: {
readonly AAVE_V3: 0;
readonly ERC3156: 1;
readonly BALANCER_V2: 2;
readonly MORPHO_BLUE: 3;
};
export declare const providerKindNames: readonly ["aave-v3", "erc3156", "balancer-v2", "morpho-blue"];
type ProviderKindName = (typeof providerKindNames)[number];
export declare const providerKindByName: Record<ProviderKindName, number>;
interface FlashloanMaterialiserInput {
readonly kind: 'flashloan';
readonly providerKind: ProviderKindName;
readonly amount: string;
}
//#endregion
//#region src/constructors.d.ts
interface OpHandleOptions<Opt extends boolean = boolean> {
readonly expose?: boolean;
readonly units?: HandleUnits;
readonly optional?: Opt;
}
export declare const linear: <N extends string, T extends SolType>(name: N, type: T) => Port & {
readonly name: N;
readonly type: T;
readonly mode: "linear";
};
export declare const copy: <N extends string, T extends SolType>(name: N, type: T) => Port & {
readonly name: N;
readonly type: T;
readonly mode: "copy";
};
export declare const handle: <N extends string, T extends SolType>(name: N, type: T) => HandleInput & {
readonly name: N;
readonly type: T;
};
export declare const native: <N extends string>(name: N, chainId: number) => ResourceInput & {
readonly name: N;
};
export declare const erc20: <N extends string>(name: N, token: string, chainId: number) => ResourceInput & {
readonly name: N;
};
export declare const resource: <N extends string, Opt extends boolean = false>(name: N, accepts: "erc20" | "native" | "any", options?: {
readonly optional?: Opt;
}) => ResourcePort & {
readonly name: N;
readonly optional: NoInfer<Opt>;
};
export declare const readResource: <N extends string>(name: N, accepts: "erc20" | "native" | "any") => ResourcePort & {
readonly name: N;
readonly mode: "copy";
};
export declare const opHandle: <N extends string, T extends SolType, Opt extends boolean = false>(name: N, type: T, options?: OpHandleOptions<Opt>) => HandlePort & {
readonly name: N;
readonly type: T;
readonly optional: NoInfer<Opt>;
};
type ResourceOutputOptions = Availability | {
readonly availability?: Availability;
readonly providesMinimum?: boolean;
readonly omitIfZero?: boolean;
readonly deliveryAddressInput?: string;
readonly countFrom?: string;
};
type OutputCountFrom<O> = O extends {
readonly countFrom: infer K extends string;
} ? {
readonly countFrom: K;
} : unknown;
type OutputAvailability<O> = [O] extends ['future'] ? 'future' : [O] extends ['now'] ? 'now' : [O] extends [string] ? Availability : O extends {
readonly availability: infer A;
} ? [A] extends ['future'] ? 'future' : [A] extends ['now'] ? 'now' : Availability : 'now';
export declare const resourceOutput: <N extends string, const O extends ResourceOutputOptions = "now">(name: N, options?: O) => ResourceOutputPort & {
readonly name: N;
readonly availability: OutputAvailability<O>;
} & OutputCountFrom<O>;
//#endregion
//#region src/outputFamilies.d.ts
type OutputFamilyPort = ResourceOutputPort & {
readonly countFrom: string;
};
export declare const isOutputFamily: (port: OpOutputPort) => port is OutputFamilyPort;
export declare const instancePortName: (family: string, index: number) => string;
export declare const familySize: (family: Pick<OutputFamilyPort, "name" | "countFrom">, config: Call["config"]) => number;
export declare const expandOutputPorts: (declared: readonly OpOutputPort[], config: Call["config"]) => readonly OpOutputPort[];
//#endregion
//#region src/ref.d.ts
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';
export 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.
*/
export declare const RESERVED_REF_SCOPES: ReadonlySet<string>;
export declare const isRef: (v: unknown) => v is Ref;
export declare const parseRef: (ref: Ref) => ParsedRef;
/** A ref path: a dotpath such as `input.amount` or `nodeId.port`. */
type RefPath = `${string}.${string}`;
/**
* Builds a bind ref. `ref.input(port)` for a flow input, `ref.context.*` for a
* context ref, and a dotpath for a node output (`ref('deposit.shares')`).
* Prefer the named forms: `parseRef` reads an unrecognised prefix as a node id,
* so a misspelled `input.`/`context.` silently becomes an output ref.
*/
interface RefBuilder {
(path: RefPath): Ref;
input(port: string): Ref;
readonly context: { readonly [K in ContextKey]: Ref; };
}
export declare const ref: RefBuilder;
export 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;
export declare const refKey: (ref: Ref) => string;
//#endregion
//#region src/chainCapabilities.d.ts
/**
* Per-chain native-asset semantics.
*
* Most EVM chains have an ETH-style native gas coin sent via `msg.value` (the
* `evm-native` policy). A small number express their "native" coin as an
* ERC-20 token: on `as-erc20` chains (Tempo) no `msg.value` coin exists at
* all, while on `native-mirrored-erc20` chains (Arc) a real `msg.value` coin
* exists but is canonically routed through an ERC-20 facade that mirrors the
* native balance (`balanceOf == native wei / nativeScale`, with no balance
* storage of its own). Code that needs to lower or simulate a `Resource` of
* kind `"native"` should consult `getChainCapabilities(chainId)` rather than
* hardcoding chain IDs.
*
* The compose compiler uses this registry to transparently normalise native
* resources into ERC-20 resources on both ERC-20-canonical kinds at
* schema-decode time (see `normalizeResource` below and the `ResourceSchema`
* transform in `flowSchema.ts`).
*
* The two ERC-20-canonical kinds behave identically at the resource level —
* `hasErc20CanonicalNative` is the predicate for that shared behaviour. They
* diverge only at the simulation layer: `as-erc20` balances live in ordinary
* token storage, while `native-mirrored-erc20` balances have no storage slot
* and are satisfied by a native balance override scaled by `nativeScale`
* (see compose-core's `rewritePreconditions`).
*
* This union is the extension point for future native-asset policies. A chain
* with no canonical native asset would get a `reject-native` arm, under which a
* `{ kind: "native" }` resource becomes a validation error rather than being
* rewritten. No such chain exists yet, so the arm is not defined here.
*/
type ChainCapabilities = {
readonly kind: 'evm-native';
readonly chainId: number;
} | {
readonly kind: 'as-erc20';
readonly chainId: number;
readonly nativeErc20: NativeErc20;
} | {
readonly kind: 'native-mirrored-erc20';
readonly chainId: number;
readonly nativeErc20: NativeErc20;
/** Native wei per 1 unit of the facade ERC-20 (1e12 on Arc: 18-dec native, 6-dec USDC). */
readonly nativeScale: bigint;
};
interface NativeErc20 {
readonly token: `0x${string}`;
readonly symbol: string;
readonly decimals: number;
}
/**
* The zero-address sentinel that represents the native gas coin on
* EVM-native chains. Exported so tests and call-sites can reference it
* by name rather than inlining 40 zeros.
*
* Inlined as a literal rather than imported from `@lifi/utils`: `compose-spec`
* is the wire-format leaf package and carries no `@lifi/*` dependencies
* (enforced by `scripts/check-compose-boundaries.mjs`).
*/
export declare const EVM_NATIVE_SENTINEL: `0x${string}`;
export declare const TEMPO_CHAIN_ID = 4217;
export declare const TEMPO_NATIVE_ERC20: NativeErc20;
export declare const ARC_CHAIN_ID = 5042;
/**
* Arc's native gas coin is USDC (18-decimal wei at the EVM level). The USDC
* ERC-20 at this address is a view over native balances: `balanceOf` returns
* `native wei / 1e12` and has no balance storage slot; allowances live in
* regular storage. The composer interacts with USDC exclusively through this
* facade, never via `msg.value`.
*/
export declare const ARC_NATIVE_ERC20: NativeErc20;
export declare const ARC_NATIVE_SCALE: bigint;
export declare const getChainCapabilities: (chainId: number) => ChainCapabilities;
/**
* Structural fold over the `ChainCapabilities` union — the capabilities
* counterpart of `foldResource`/`foldRef`. Dispatches on `kind` and hands each
* case its narrowed fields, so consumers that must branch on the native-asset
* policy (e.g. compose-core's `rewritePreconditions`) do so through one
* combinator whose exhaustiveness the compiler enforces: adding a new arm to
* the union above turns every `foldChainCapabilities` call into a type error
* until it handles the new case.
*/
export declare const foldChainCapabilities: <R>(caps: ChainCapabilities, cases: {
readonly evmNative: (chainId: number) => R;
readonly asErc20: (nativeErc20: NativeErc20, chainId: number) => R;
readonly nativeMirroredErc20: (nativeErc20: NativeErc20, nativeScale: bigint, chainId: number) => R;
}) => R;
/**
* What a wire-level native-balance check (`nativeBalanceGte`) must become on
* a chain, decided once here from the native-asset policy:
*
* - `keep` — `evm-native`: the native read is the right read.
* - `rewrite` — `as-erc20` (Tempo): no `msg.value` coin exists, so the check
* becomes an `erc20BalanceGte` of `token`, the stand-in ERC-20. Amounts were
* always facade-denominated, so `minAmount` carries over verbatim.
* - `reject` — `native-mirrored-erc20` (Arc): a native read returns real
* 18-decimal wei, `nativeScale`× the facade's units, so no interpretation of
* `minAmount` is safe — reusing it on a facade read is 1e12 too strict for a
* wei-denominated check, keeping the native read lets a facade-denominated
* check pass 1e12 too easily. The check must be authored as
* `erc20BalanceGte` of the facade; `reason` says so.
*
* Consumers (the `AssertedPredicateSchema` decode and compose-core's derive
* backstop) are adapters over this result, so the unit rule lives in one place
* and the fold's exhaustiveness reaches every site.
*/
type NativeCheckPolicy = {
readonly kind: 'keep';
} | {
readonly kind: 'rewrite';
readonly token: `0x${string}`;
} | {
readonly kind: 'reject';
readonly reason: string;
};
export declare const nativeCheckPolicy: (chainId: number) => NativeCheckPolicy;
/**
* Exact-kind check for `as-erc20` (currently Tempo only) — the rare case that
* genuinely means "no `msg.value` coin exists on this chain". Most consumers
* want `hasErc20CanonicalNative` instead, which also covers
* `native-mirrored-erc20` chains (Arc), where the composer's ERC-20-only
* policy applies even though `msg.value` works. Code that must treat the two
* ERC-20-native kinds differently goes through `foldChainCapabilities` or
* `nativeCheckPolicy`, never a second exact-kind predicate.
*/
export declare const isAsErc20Chain: (chainId: number) => boolean;
/**
* Whether the chain's canonical native asset is an ERC-20 — true for both
* `as-erc20` chains (Tempo: no `msg.value` coin exists) and
* `native-mirrored-erc20` chains (Arc: `msg.value` exists but is never used).
* This is the predicate for the shared resource-level behaviour: native
* resources are rewritten to the ERC-20, native routing edges are dropped, and
* a surviving native resource is a compile error.
*/
export declare const hasErc20CanonicalNative: (chainId: number) => boolean;
/**
* The address that represents the chain's native asset.
*
* On EVM-native chains this is the zero-address sentinel `0x0…0`. On chains
* whose canonical native asset is an ERC-20 it is the chain's stand-in token
* (PathUSD on Tempo, the USDC facade on Arc).
*/
export declare const canonicalNativeAddress: (chainId: number) => `0x${string}`;
/**
* Whether `address` represents the native asset of `chainId`.
*
* On EVM-native chains, this is the case-insensitive zero-address check. On
* chains whose canonical native asset is an ERC-20, the literal zero address
* returns `false` — only the chain's stand-in ERC-20 address matches.
*/
export declare const isNativeAddressForChain: (chainId: number, address: string) => boolean;
/**
* Whether `address` on `chainId` is the genuine `msg.value`-style native coin:
* an `evm-native` chain's zero-address sentinel.
*
* This is the single predicate that gates `msg.value` semantics — choosing a
* `NativeBalance` over an `Erc20Balance` simulation requirement, and skipping
* the ERC-20 approval a native input would otherwise need. It returns `false`
* for every address on a chain whose canonical native asset is an ERC-20
* (including the zero sentinel): on `as-erc20` chains the "native" coin is a
* real ERC-20 moved via `transferFrom`, never `msg.value`, and on
* `native-mirrored-erc20` chains `msg.value` works but the composer's policy
* is to move the coin exclusively through the ERC-20 facade. Use this rather
* than re-deriving the check at call sites, and rather than
* `isNativeAddressForChain`, which returns `true` for the stand-in ERC-20
* (PathUSD on Tempo) and would wrongly route it to `msg.value`.
*/
export declare const isMsgValueNative: (chainId: number, address: string) => boolean;
/**
* Rewrite a single `Resource` according to its chain's capabilities.
*
* On chains with the default `evm-native` policy, every resource is returned
* unchanged. On chains whose canonical native asset is an ERC-20 (`as-erc20`
* Tempo, `native-mirrored-erc20` Arc), a resource of kind `"native"` is
* rewritten into the equivalent ERC-20 resource pointing at the chain's
* stand-in token (PathUSD on Tempo, the USDC facade on Arc).
*
* This is the rewrite primitive behind the `ResourceSchema` decode transform
* (see `flowSchema.ts`), which is THE chokepoint: it runs every time a
* `Resource` is parsed — flow inputs via `FlowSchema`, op configs via
* `decodeConfig` — so every downstream pass (`normalizeFlow`, `resolve`,
* `lower`, `simulate`) sees only ERC-20 resources on those chains.
*
* The function preserves referential identity when nothing changes (returns the
* input `r` unchanged on evm-native chains and for ERC-20 resources) and is
* idempotent: running it on an already-rewritten resource is a no-op.
*/
export declare const normalizeResource: (r: Resource) => Resource;
/**
* Address-level counterpart of `normalizeResource` for wire fields that carry a
* native asset as a bare token string (a continuation outcome's `token`). On
* chains whose canonical native asset is an ERC-20, the native sentinel is
* rewritten to the chain's stand-in ERC-20; every other address passes through.
*/
export declare const normalizeNativeTokenAddress: (token: string, chainId: number) => string;
//#endregion
//#region src/route.d.ts
/**
* Spend an exact amount of `fromToken`.
*
* `amount` is in the token's smallest unit. Accepts `bigint | string`; the wire
* format is a non-negative decimal string.
*/
interface RouteAmountExact {
readonly type: 'EXACT';
readonly amount: bigint | string;
}
/**
* Spend the signer's entire `fromToken` balance, whatever it is at execution
* time.
*
* The on-chain amount is resolved by a deposit-all materialiser, so it is not
* known when the route is compiled. `simAmount` is the stand-in the server
* quotes and simulates against — make it a realistic estimate of the balance,
* because it determines the quote and the derived preconditions, not the amount
* actually moved. Accepts `bigint | string`; the wire format is a non-negative
* decimal string.
*
* Not supported when `fromToken` is the chain's native sentinel: a gas coin
* arrives via `msg.value`, so there is no on-chain balance to sweep, and the
* server rejects the combination with a `validation_error`. Use
* {@link RouteAmountExact} for native inputs.
*
* On a route that begins with an aggregator swap the swap's input amount is
* pinned to the quoted amount derived from `simAmount`: a runtime balance below
* that pinned amount reverts, and a balance above it leaves the remainder as
* `unspentIn`, which may be most of the input and which `sweepTo` receives.
* Under `EXACT` the deposit and the pinned quote are the same number, so the
* `unspentIn` output is zero and omitted; any pre-existing dust of the sold
* token in the proxy is moved to `sweepTo` by the whole-balance sweep
* independently of that output.
*/
interface RouteAmountAll {
readonly type: 'ALL';
readonly simAmount: bigint | string;
}
/**
* How much of `fromToken` a route spends. Two variants, discriminated by
* `type`.
*/
type RouteAmount = RouteAmountExact | RouteAmountAll;
/** Request body for `POST /compose/route`. */
interface ComposeRouteRequest {
/** EVM chain id. Both tokens must live on this chain — routes are same-chain. */
readonly chainId: number;
/**
* Token to spend. Use the chain's native sentinel address for the gas coin
* (the zero address on EVM-native chains).
*/
readonly fromToken: string;
/** Token to receive. */
readonly toToken: string;
/** How much of `fromToken` to spend — an exact amount or the whole balance. */
readonly amount: RouteAmount;
/** Address that funds the route and, by default, owns its output. */
readonly signer: string;
/**
* Slippage tolerance in basis points. Range 0–10000. Defaults to `100` (1%)
* server-side when omitted. It is an end-to-end tolerance: the floor is the
* simulated final output of the whole route, so a multi-hop route is not
* bounded hop by hop. When the route begins with an aggregator swap the same
* value is also the swap's own tolerance, which nests inside the end-to-end
* floor rather than compounding with it.
*/
readonly slippageBps?: number;
/**
* Reject the route when its quoted price impact exceeds this many basis
* points. Range 0–10000. Omitted ⇒ the server's default of 500 bps applies;
* `0` disables the check.
*/
readonly maxPriceImpactBps?: number;
/** Opaque referrer tag forwarded to the underlying quote provider. */
readonly referrer?: string;
/**
* Owner of every asset the route leaves behind; defaults to `signer` on a
* route with no aggregator swap. Routes whose protocol mints to a named
* receiver (surfaced as `recipient: 'required'` by `GET /compose/zap-packs`)
* and asynchronous routes bind this address at mint time rather than
* transferring afterwards; otherwise the proxy's whole balance of each
* asset the route leaves is transferred here.
*
* **Required when the route includes an aggregator swap.** Such a route can
* leave an asset the caller did not plan for — the swap's unspent input —
* and this address receives it alongside the terminal output, so it must be
* named explicitly; omitting it fails with `validation_error`.
*
* Accepts an address or `{ $ref: 'context.sender' }` (which counts as
* explicit); `{ $ref: 'context.executionAddress' }` is rejected.
*/
readonly sweepTo?: ForwardTo;
/**
* `'strict'` (the default) fails the request when simulation detects a
* revert; `'allow-revert'` returns a partial result with revert diagnostics
* instead.
*/
readonly simulationPolicy?: SimulationPolicy;
/**
* Also simulate the final user-facing transaction after the structured
* simulation succeeds. Reverts honour `simulationPolicy`. Defaults to `false`.
*/
readonly simulateUserProgram?: boolean;
/**
* Filter the returned `approvals` against current on-chain allowances,
* omitting approvals that are already sufficient. Defaults to `false`.
*/
readonly checkOnChainAllowances?: boolean;
/**
* Accept a route whose output is delivered only after the initiating
* transaction settles (`delivery.when: 'future'` on the terminal output).
* Such a route obliges you to track settlement rather than treat the
* transaction as completing the job, and carries no slippage floor, so it is
* opt-in. Defaults to `false` server-side, which leaves a pair reachable
* only asynchronously rejected with `no_route_error` and guarantees every
* terminal output is `delivery.when: 'now'`.
*
* It widens reach, it is not a preference: a synchronous route wins at any
* length, so a pair with both a one-hop asynchronous edge and a longer
* synchronous route is served synchronously. Opting in never costs you a
* synchronous route.
*/
readonly allowAsyncRoutes?: boolean;
}
//#endregion
//#region src/preconditions.d.ts
/**
* The three concrete precondition shapes the stack exchanges today. One
* definition serves every producer and consumer: op/materialiser declarations,
* `rewritePreconditions`, the simulator's funding requirements (`simulate.ts`
* aliases these as `*Requirement`), and the zap-backend approval derivation.
*
* Amounts accept `bigint | string`: the SDK serialises `bigint` to a decimal
* string; the string side covers values already stringified.
*/
type Erc20BalancePrecondition = {
readonly type: 'Erc20Balance';
readonly wallet: string;
readonly token: string;
readonly balance: bigint | string;
};
type NativeBalancePrecondition = {
readonly type: 'NativeBalance';
readonly wallet: string;
readonly balance: bigint | string;
};
type Erc20AllowancePrecondition = {
readonly type: 'Erc20Allowance';
readonly owner: string;
readonly spender: string;
readonly token: string;
readonly allowance: bigint | string;
};
export declare const erc20Balance: (config: Omit<Erc20BalancePrecondition, "type">) => Erc20BalancePrecondition;
export declare const nativeBalance: (config: Omit<NativeBalancePrecondition, "type">) => NativeBalancePrecondition;
export declare const erc20Allowance: (config: Omit<Erc20AllowancePrecondition, "type">) => Erc20AllowancePrecondition;
export declare const isErc20BalancePrecondition: (p: Precondition) => p is Erc20BalancePrecondition;
export declare const isErc20AllowancePrecondition: (p: Precondition) => p is Erc20AllowancePrecondition;
export declare const isNativeBalancePrecondition: (p: Precondition) => p is NativeBalancePrecondition;
//#endregion
//#region src/simulate.d.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.
*/
export 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`.
*/
export 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. */
type Erc20BalanceRequirement = Erc20BalancePrecondition;
/** Funding instruction: seed a native balance on a wallet before simulation. */
type NativeBalanceRequirement = NativeBalancePrecondition;
/** Funding instruction: seed an ERC-20 allowance before simulation. */
type Erc20AllowanceRequirement = Erc20AllowancePrecondition;
/**
* Funding instruction: seed a Uniswap Permit2 `AllowanceTransfer` allowance
* before simulation, so a `Permit2.transferFrom(owner, _, amount, token)` sent
* by `spender` passes Permit2's own check.
*
* slot-finder writes two overrides: Permit2's `allowance[owner][token][spender]`
* (no expiry, the owner's live nonce kept) and the ERC-20 allowance
* `owner` → Permit2 that the pull spends. It does not fund the owner's token
* balance: add an `Erc20Balance` for that. Only the canonical Permit2 address
* `0x000000000022D473030F116dDEE9F6B43aC78BA3` is supported; on a chain
* without code there the simulation answers HTTP 422.
*
* Unlike the other variants this is not a compile precondition: no op declares
* a Permit2 allowance, so only a `POST /simulate` caller sends one.
*/
type Permit2AllowanceRequirement = {
readonly type: 'Permit2Allowance';
/** Address whose tokens Permit2 pulls. */
readonly owner: string;
/** ERC-20 token Permit2 pulls. */
readonly token: string;
/** Address that calls `Permit2.transferFrom`. */
readonly spender: string;
/** Permit2 allowance amount, in the token's base units. */
readonly amount: bigint | string;
};
/**
* The funding-instruction union applied before a simulation. Four variants,
* discriminated by `type`.
*/
type SlotFinderRequirement = Erc20BalanceRequirement | NativeBalanceRequirement | Erc20AllowanceRequirement | Permit2AllowanceRequirement;
/** 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;
//#endregion
//#region src/headers.d.ts
/**
* HTTP header names on the compose wire.
*
* Both the SDK (which sends the request header) and the backend (which reads it
* and answers with the response header) are part of the same handshake, so the
* names belong to the wire format rather than to either side of it.
*/
/** Compose contract version the client was built against. Sent on every request. */
export declare const COMPOSER_SDK_VERSION_HEADER = "x-lifi-composer-sdk";
/** Compose contract version the backend serves. Returned on every compose response. */
export declare const COMPOSE_VERSION_HEADER = "x-lifi-composer-version";
//#endregion
//#region src/version.d.ts
/**
* Compose contract version compatibility.
*
* The version triple carries the compatibility class, and the rule is
* permanent: 1.0 does not change it. A patch bump is additive: new ops, edge
* families, materialisers, guards, preconditions, or new optional config
* fields. A minor or major bump is breaking: anything removed, any existing
* schema changed, or a semantics change under an unchanged wire shape. Both
* sides of the handshake (see `headers.ts`) decide with `checkCompatibility`,
* so the rule lives in exactly one place.
*/
interface ComposeVersion {
readonly major: number;
readonly minor: number;
readonly patch: number;
}
type VersionCompatibility = 'compatible' | 'sdk_outdated' | 'server_outdated';
/**
* Parses the numeric triple of a semantic version. Prerelease and build
* suffixes are accepted and ignored: `0.5.1-staging.3` compares as `0.5.1`.
* Returns `undefined` for anything that is not a complete semver string,
* including the `dev` sentinel the SDK sends when it runs unbundled.
*/
export declare const parseVersion: (version: string) => ComposeVersion | undefined;
/**
* Decides whether a client built against `client` may talk to a server that
* serves `server` and accepts clients down to `minimum`.
*
* - A client ahead of the server in any component is `server_outdated`. Even
* a patch-ahead client may send a field the server has never seen, and the
* guarantee must not depend on every server schema staying strict. This is
* the rollout window between an npm publish and the prod image bump.
* - A client below `minimum` is `sdk_outdated`: the server no longer serves
* the contract that client speaks.
* - Anything in between is compatible. Patch releases only add, so a client
* at or behind the server's patch never emits anything the server lacks;
* a client on an older minor is served because the server still emits the
* shapes that minor reads.
*
* `minimum` defaults to the server's own `major.minor.0`, which makes every
* minor bump a hard cutover. The backend passes its explicit floor so a minor
* bump can ship with the previous line still accepted; the SDK passes no floor
* because the server, not the client, decides how far back it serves.
*/
export declare const checkCompatibility: (client: ComposeVersion, server: ComposeVersion, minimum?: ComposeVersion) => VersionCompatibility;
//#endregion
//#region src/materialiserMetadata.d.ts
type MaterialiserMetadata = {
readonly kind: 'exact';
readonly amount: bigint;
} | {
readonly kind: 'exact-native';
readonly amount: bigint;
} | {
readonly kind: 'capped';
readonly amount: bigint;
readonly min?: bigint;
} | {
readonly kind: 'runtime';
readonly min?: bigint;
};
interface MaterialiserResolution {
readonly meta: MaterialiserMetadata;
readonly preconditions: readonly Precondition[];
}
export declare const foldMaterialiserMetadata: <R>(meta: MaterialiserMetadata, cases: {
readonly exact: (amount: bigint) => R;
readonly exactNative: (amount: bigint) => R;
readonly capped: (amount: bigint, min: bigint | undefined) => R;
readonly runtime: (min: bigint | undefined) => R;
}) => R;
//#endregion
export type { Amount, AppliedGuard, ApprovalEntry, AssertedPredicate, AssertionOwner, AssertionSpec, AssertionSpecWire, Availability, BindValue, Call, CallCheckSpec, ChainCapabilities, CommittedOutcome, ComposeAction, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeError, ComposeErrorKind, ComposeFill, ComposeManifest, ComposeRouteErrorKind, ComposeRouteRequest, ComposeRun, ComposeTransactionRequest, ComposeUserProgramSimulation, ComposeVersion, ComposeWarning, ConsumedOutput, ContextKey, ContinuationIntent, ContinuationOutcome, Delivery, DeliveryComposeError, DeliveryErrorDetails, DeliveryErrorReason, ERC20Resource, Epilogue, EpilogueForward, Erc20AllowancePrecondition, Erc20AllowanceRequirement, Erc20BalancePrecondition, Erc20BalanceRequirement, Estimate, EstimateBasis, ExecutedEpilogue, ExecutedForward, FailedPreparedOp, FlashloanMaterialiserInput, Flow, FlowInput, ForwardTo, GenericComposeError, GenericComposeErrorKind, GuardCompatibility, GuardSelector, HandleInput, HandlePort, HandleUnits, InputSpec, Lineage, LiteralBinding, ManifestGuard, ManifestMaterialiser, ManifestOperation, ManifestPrecondition, ManifestRouting, MaterialiserConfigOf, MaterialiserInput, MaterialiserInputBase, MaterialiserInputOf, MaterialiserMetadata, MaterialiserResolution, Minimum, MinimumBasis, NativeBalancePrecondition, NativeBalanceRequirement, NativeCheckPolicy, NativeErc20, NativeResource, OpInputPort, OpOutputPort, Output, OutputAmount, OutputFamilyPort, Outputs, ParsedRef, Permit2AllowanceRequirement, Phase1Artifact, Port, Precondition, PreconditionBase, PreconditionConfigOf, PreconditionOf, PreparationComposeError, PriceImpact, ProviderKindName, Ref, RefBuilder, RefPath, RefScope, Resource, ResourceInput, ResourceOutputPort, ResourcePort, RouteAmount, RouteAmountAll, RouteAmountExact, SettlementBindingWire, SettlementEscrowWire, SettlementWire, Shortfall, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SimulationRevertComposeError, SlotFinderRequirement, SolType, SpendEntry, StaticSolType, TerminalOutput, TrackedBalance, VerificationDescriptor, VerificationDescriptorWire, VersionCompatibility };