UNPKG

@lifi/composer-sdk

Version:

Public Composer SDK for building and submitting flows

86 lines (84 loc) 3.22 kB
/** * Types for the Compose discovery API (`GET /compose/zap-packs`, `GET /chains`). * * 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 chain the Compose deployment supports. */ interface ChainSummary { /** EVM chain ID. The stable identifier — key on this. */ readonly chainId: number; /** * Human-readable label, suitable for display in a chain selector. * * Maintained by the deployment rather than derived from canonical chain * branding, so it can differ from a chain's marketed name and can change * without notice. Never treat it as an identifier, and never match on it. * A chain the deployment has no configured label for reports `Chain <id>`. */ readonly name: string; } /** * 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 { ChainSummary, GetZapPacksOptions, ZapPackEdge, ZapPackOverview };