@lifi/composer-sdk
Version:
Public Composer SDK for building and submitting flows
104 lines (103 loc) • 3.98 kB
JavaScript
import { isComposeDeliveryError, isComposeError, isComposePreparationError, isComposeSdkOutdatedError, isComposeServerOutdatedError } from "./errors.js";
import { buildReachability } from "./reachability.js";
import { isInputHandle, isOutputHandle } from "./authoring/handles.js";
import { ref } from "./authoring/raw.js";
import { materialiser } from "./run/inputs.js";
import { buildSimulateRequest } from "./run/simulate.js";
import { terminalOutputs } from "./outputs.js";
import { createComposeSdk } from "./sdk.js";
import { guards_generated_exports } from "./generated/guards.generated.js";
import { materialisers_generated_exports } from "./generated/materialisers.generated.js";
import { preconditions_generated_exports } from "./generated/preconditions.generated.js";
import { raw_exports } from "./raw.js";
import { resources_exports } from "./resources.js";
import { routeAmount_exports } from "./routeAmount.js";
import { SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES } from "@lifi/compose-spec";
//#region src/index.ts
/**
* Guard factories for protecting operation outputs (e.g. slippage tolerance).
* Pass guards to an operation's `guards` array.
*
* @example
* ```ts
* builder.lifi.swap('swap1', {
* bind: { amountIn: builder.inputs.token },
* config: { resourceOut: resources.native(1) },
* guards: [guards.slippage({ port: 'amountOut', bps: 300 })],
* });
* ```
*/
const guards = guards_generated_exports;
/**
* Materialiser factories that tell the runtime how to resolve token input
* amounts on-chain (e.g. read a wallet balance, accept a direct deposit).
*
* @example
* ```ts
* await builder.compile({
* inputs: { token: materialisers.balanceOf({}) },
* signer: '0x...',
* });
* ```
*/
const materialisers = materialisers_generated_exports;
/**
* Precondition factories for asserting on-chain state before a flow executes
* (e.g. minimum token balances, ERC-20 allowances).
*
* @example
* ```ts
* await builder.compile({
* inputs: { token: materialisers.balanceOf({}) },
* preconditions: [
* preconditions.erc20Balance({ wallet: '0x...', token: '0x...', balance: 1000n }),
* ],
* signer: '0x...',
* });
* ```
*/
const preconditions = preconditions_generated_exports;
/**
* Resource declaration helpers for defining token inputs in a flow schema.
* Use {@link resources.erc20} for ERC-20 tokens and {@link resources.native}
* for the chain's native coin (ETH, MATIC, etc.).
*
* @example
* ```ts
* const builder = sdk.flow(1, {
* inputs: {
* usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1),
* eth: resources.native(1),
* },
* });
* ```
*/
const resources = resources_exports;
/**
* Amount constructors for {@link ComposeSdk.route}. Use
* {@link routeAmount.exact} to spend a fixed amount of the `fromToken`, and
* {@link routeAmount.all} to spend the signer's whole balance.
*
* @example
* ```ts
* // USDC into the Aave v3 aEthUSDC position — one routing-catalog edge.
* const result = await sdk.route({
* chainId: 1,
* fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
* toToken: '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c',
* amount: routeAmount.exact(1_000_000n),
* signer: '0xYourAddress...',
* });
* ```
*/
const routeAmount = routeAmount_exports;
/**
* Low-level escape hatch for constructing flow nodes, guards, and materialiser
* inputs without the typed builder API. Prefer the generated operation methods
* on {@link FlowBuilder} and the typed `guards`/`materialisers` namespaces
* for most use cases.
*/
const raw = raw_exports;
//#endregion
export { SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, buildReachability, buildSimulateRequest, createComposeSdk, guards, isComposeDeliveryError, isComposeError, isComposePreparationError, isComposeSdkOutdatedError, isComposeServerOutdatedError, isInputHandle, isOutputHandle, materialiser, materialisers, preconditions, raw, ref, resources, routeAmount, terminalOutputs };
//# sourceMappingURL=index.js.map