@lifi/composer-sdk. For the authoritative TypeScript types, browse the package source at unpkg.com/browse/@lifi/composer-sdk.
There is no
sdk.compile(). Compile lives on the builder: builder.compile(run). sdk.request(flow, run) is the escape hatch for custom transports.createComposeSdk(options)
Declared in sdk.ts.
ComposeSdkOptions
ComposeSdk
Members:
sdk.flow(chainId, options) → FlowBuilder
FlowOptions<T>
The generic
T carries through to typed handles at builder.inputs.<name>.
FlowBuilder<T>
A FlowBuilder is a FlowBuilderCore<T> (declared in FlowBuilderCore.ts) augmented with a typed method per op plus a compile method.
Inherited FlowBuilderCore members
Op methods
The SDK exposes a typed method per op the Composer API supports. Examples:builder.lifi.swap(id, args),builder.lifi.zap(id, args)builder.core.call(id, args),builder.core.asResource(id, args),builder.core.balanceOf(id, args), and the arithmetic methodsbuilder.core.add(id, args),subtract,multiply,divideDown,divideUp,bpsDown,bpsUp— one method per arithmetic op.
Record<portName, OutputHandle> for the op’s outputs. See the live Ops catalog.
builder.compile(run)
One-shot: calls build(), forms a ComposeCompileRequest via sdk.request, POSTs it to /compose, and returns a ComposeCompileResult.
ComposeError on network, validation, or server errors.
sdk.request(flow, run) → ComposeCompileRequest
Use when you need the raw request payload — queueing, server-side proxy, signing the request, inspection in tests.
sdk.client
The low-level HTTP client. Most integrations only need builder.compile(); reach for the client when you build a request via sdk.request() and submit it yourself, or when you need protocol/manifest discovery.
getZapPacks accepts an optional { protocols?: string | readonly string[] } filter. Results are not cached by the SDK — cache as appropriate for your refresh needs. See the routing edges catalog for the rendered live view.
ComposeCompileResult
A discriminated union on the status field. Branch on result.status before accessing shape-specific fields.
status: 'success'— returned under the defaultsimulationPolicy: 'strict'when the compile and simulation both succeed.status: 'partial'— returned only whensimulationPolicy: 'allow-revert'was passed on the run and the simulation reverted. ThetransactionRequestis still present; the revert diagnostics are exposed for the caller to surface.
transactionRequest, userProxy, producedResources, producedHandles (values for any output handles marked expose: true), optional approvals, optional priceImpact, and optional fees.
ComposeRunInput<T>
Declared in run/inputs.ts.
Handles
Declared inauthoring/handles.ts.
InputHandle<T>—{ _tag: 'input', inputName, __outputKind?: T }. Carries the input’s output kind as a phantom type parameter.ResourceInputHandle—InputHandle<'resource'> & { resource: Resource }.OutputHandle<T>—{ _tag: 'output', nodeId, portName, __outputKind?: T }.Bindable<T>— the union of values accepted in a typed bind slot:InputHandle<T>,OutputHandle<T>,TypedRef<T>. For'uint256'slots,'resource'-tagged handles are also accepted (resources are uint256 amounts).
handleToRef (exported from the same module).
Namespaces
resources— helpers to declare token resources (resources.erc20(token, chainId),resources.native(chainId)).materialisers— generated helpers for registered materialisers (materialisers.directDeposit({ amount }),materialisers.balanceOf({ ... }), …).guards— generated helpers for registered guards (guards.slippage({ port, bps }), …).raw— low-level escape hatches:raw.ref<T>(path)creates aTypedRef<T>;raw.guard(kind, config?)builds anAppliedGuardfor guard kinds not yet covered by a typed helper;raw.materialiser(kind, config?)builds aMaterialiserInputfor the same reason.
TypedFlow<T>
The Flow document returned by builder.build(). Structurally identical to Flow from @lifi/compose-spec, with a phantom __inputs?: T carrying the input schema through TypeScript inference (__inputs does not exist at runtime).
Error types
ComposeError (re-exported from @lifi/compose-spec) carries:
See also
- Quickstart — five-minute first-flow walkthrough.
- Build a Flow — production setup, inputs, ops, materialisers, guards, preconditions, submission.
- Flow wire format — the JSON the SDK produces.

