@lifi/composer-sdk
Version:
Public Composer SDK for building and submitting flows
70 lines (68 loc) • 2.58 kB
TypeScript
/**
* Types for the Compose discovery API (`GET /compose/zap-packs`).
*
* These are SDK-facing presentation types — not part of the core compile
* contract in compose-spec. The backend response is the source of truth;
* the SDK provides typed access.
*
* The `type` field on edges is a plain `string` rather than a strict union
* so the SDK remains forward-compatible when the backend introduces new
* edge types. Known values at time of writing:
* `"enter-position"`, `"exit-position"`, `"wrap"`, `"unwrap"`, `"mint"`, `"burn"`.
*/
/**
* A single routing edge representing a supported token-to-token path
* through a DeFi protocol.
*/
interface ZapPackEdge {
/** Edge type (e.g. `"enter-position"`, `"exit-position"`, `"wrap"`). */
readonly type: string;
/** Input token. */
readonly in: {
readonly address: string;
readonly chainId: number;
};
/** Output token. */
readonly out: {
readonly address: string;
readonly chainId: number;
};
/** Minimum input amount accepted (stringified integer), if constrained. */
readonly inAmountMin?: string;
/** Maximum input amount accepted (stringified integer), if constrained. */
readonly inAmountMax?: string;
/**
* Recipient binding obligation. `"required"` means the zap must bind its
* `recipient` input. The output is externally owned, terminal, and unswept.
* The loose string type preserves forward compatibility with new values.
*/
readonly recipient?: string;
/**
* Output availability. `"future"` means the output becomes available only
* after the initiating transaction settles; route via `lifi.zapAsync` with
* a bound recipient. Absent means the output is available synchronously.
* The loose string type preserves forward compatibility with new values.
*/
readonly availability?: string;
}
/**
* All routing edges for a single protocol.
*/
interface ZapPackOverview {
/** Protocol identifier (e.g. `"aave"`, `"morpho"`). */
readonly protocol: string;
/** Available routing edges for this protocol. */
readonly edges: readonly ZapPackEdge[];
}
/**
* Options for {@link ComposeClient.getZapPacks}.
*/
interface GetZapPacksOptions {
/**
* Filter to specific protocols. Pass a single string or an array.
* Only edges belonging to the listed protocols are returned.
* Omit to fetch all available protocols.
*/
readonly protocols?: string | readonly string[];
}
export type { GetZapPacksOptions, ZapPackEdge, ZapPackOverview };