Skip to main content
This page enumerates the public API of @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 methods builder.core.add(id, args), subtract, multiply, divideDown, divideUp, bpsDown, bpsUp — one method per arithmetic op.
Each method returns a typed 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.
Throws a 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 default simulationPolicy: 'strict' when the compile and simulation both succeed.
  • status: 'partial' — returned only when simulationPolicy: 'allow-revert' was passed on the run and the simulation reverted. The transactionRequest is still present; the revert diagnostics are exposed for the caller to surface.
Both shapes carry the core fields: 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 in authoring/handles.ts.
  • InputHandle<T>{ _tag: 'input', inputName, __outputKind?: T }. Carries the input’s output kind as a phantom type parameter.
  • ResourceInputHandleInputHandle<'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).
Convert handles to raw refs with 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 a TypedRef<T>; raw.guard(kind, config?) builds an AppliedGuard for guard kinds not yet covered by a typed helper; raw.materialiser(kind, config?) builds a MaterialiserInput for 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 Error codes for the full catalog and the HTTP status each kind maps to.

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.