@lifi/composer-sdk 0.4.0-staging.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +95 -5
  2. package/dist/authoring/raw.cjs +3 -1
  3. package/dist/authoring/raw.cjs.map +1 -1
  4. package/dist/authoring/raw.js +3 -1
  5. package/dist/authoring/raw.js.map +1 -1
  6. package/dist/client.cjs +26 -24
  7. package/dist/client.cjs.map +1 -1
  8. package/dist/client.d.cts +31 -1
  9. package/dist/client.d.ts +31 -1
  10. package/dist/client.js +26 -24
  11. package/dist/client.js.map +1 -1
  12. package/dist/discovery.cjs.map +1 -1
  13. package/dist/discovery.d.cts +13 -0
  14. package/dist/discovery.d.ts +13 -0
  15. package/dist/generated/config.generated.cjs.map +1 -1
  16. package/dist/generated/config.generated.d.cts +15 -3
  17. package/dist/generated/config.generated.d.ts +15 -3
  18. package/dist/generated/materialisers.generated.cjs +2 -8
  19. package/dist/generated/materialisers.generated.cjs.map +1 -1
  20. package/dist/generated/materialisers.generated.d.cts +1 -1
  21. package/dist/generated/materialisers.generated.d.ts +1 -1
  22. package/dist/generated/materialisers.generated.js +1 -6
  23. package/dist/generated/materialisers.generated.js.map +1 -1
  24. package/dist/generated/operations.generated.cjs +4 -39
  25. package/dist/generated/operations.generated.cjs.map +1 -1
  26. package/dist/generated/operations.generated.d.cts +17 -111
  27. package/dist/generated/operations.generated.d.ts +17 -111
  28. package/dist/generated/operations.generated.js +4 -39
  29. package/dist/generated/operations.generated.js.map +1 -1
  30. package/dist/index.cjs +5 -1
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +23 -4
  33. package/dist/index.d.ts +23 -4
  34. package/dist/index.js +4 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/{materialisers.generated-BfWJ-g7t.d.ts → materialisers.generated-BMkBQgWZ.d.ts} +3 -8
  37. package/dist/{materialisers.generated-DaJRwiRe.d.cts → materialisers.generated-BWq5oePO.d.cts} +3 -8
  38. package/dist/routeAmount-DdbJYJyM.d.cts +55 -0
  39. package/dist/routeAmount-DdbJYJyM.d.ts +55 -0
  40. package/dist/routeAmount.cjs +38 -0
  41. package/dist/routeAmount.cjs.map +1 -0
  42. package/dist/routeAmount.d.cts +2 -0
  43. package/dist/routeAmount.d.ts +2 -0
  44. package/dist/routeAmount.js +13 -0
  45. package/dist/routeAmount.js.map +1 -0
  46. package/dist/sdk.cjs +1 -0
  47. package/dist/sdk.cjs.map +1 -1
  48. package/dist/sdk.d.cts +14 -1
  49. package/dist/sdk.d.ts +14 -1
  50. package/dist/sdk.js +1 -0
  51. package/dist/sdk.js.map +1 -1
  52. package/package.json +7 -6
  53. package/src/authoring/raw.ts +3 -2
  54. package/src/client.ts +75 -23
  55. package/src/discovery.ts +13 -0
  56. package/src/examples/lifiZap.ts +4 -0
  57. package/src/examples/lifiZapAsync.ts +88 -0
  58. package/src/examples/routeTokenPair.ts +58 -0
  59. package/src/examples/run.ts +30 -5
  60. package/src/generated/config.generated.ts +21 -3
  61. package/src/generated/materialisers.generated.ts +0 -12
  62. package/src/generated/operations.generated.ts +29 -221
  63. package/src/index.ts +23 -0
  64. package/src/routeAmount.ts +61 -0
  65. package/src/sdk.ts +17 -0
  66. package/src/examples/staged/aaveBorrow.ts +0 -128
  67. package/src/examples/staged/aaveDebtRebalanceExactOut.ts +0 -301
  68. package/src/examples/staged/aaveHealthFactorExplode.ts +0 -70
  69. package/src/examples/staged/aaveToMorphoDebtMigration.ts +0 -200
  70. package/src/examples/staged/aaveToMorphoDebtMigrationWithSwap.ts +0 -231
  71. package/src/examples/staged/aaveToMorphoDebtMigrationWithSwapExactOut.ts +0 -307
  72. package/src/examples/staged/flashloanRepay.ts +0 -142
  73. package/src/examples/staged/manualRelayContinuation.ts +0 -161
  74. package/src/examples/staged/morphoBlueBorrow.ts +0 -93
  75. package/src/examples/staged/morphoBlueRepay.ts +0 -132
  76. package/src/examples/staged/registry.ts +0 -89
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@lifi/composer-sdk` — TypeScript SDK for building and compiling\n * Compose flows into executable EVM calldata.\n *\n * Start by creating an SDK instance with {@link createComposeSdk}, then use\n * {@link ComposeSdk.flow} to build flows and compile them.\n *\n * @packageDocumentation\n */\n\nexport type {\n AbiTypeToOutputKind,\n Address,\n InputDecl,\n InputSchema,\n InputSpecOf,\n IntegerString,\n IntegerStringInput,\n OutputKind,\n TypedGuard,\n TypedRef,\n} from './types.js';\n\nexport type {\n GetZapPacksOptions,\n ZapPackEdge,\n ZapPackOverview,\n} from './discovery.js';\nexport type {\n ComposeError,\n ComposeErrorCode,\n ComposePreparationOps,\n} from './errors.js';\nexport type {\n AppliedGuard,\n ApprovalEntry,\n Call,\n ComposeCompilePartialData,\n ComposeCompileRequest,\n ComposeCompileResult,\n ComposeCompileSuccessData,\n ComposeContinuation,\n ComposeErrorKind,\n ComposeTransactionRequest,\n FailedPreparedOp,\n Flow,\n InputSpec,\n MaterialiserConfigOf,\n MaterialiserInput,\n Precondition,\n PreconditionConfigOf,\n PriceImpact,\n Ref,\n Resource,\n SimulationPolicy,\n SimulationRevert,\n SolType,\n SweepTo,\n SimulateRequest,\n SimulateResult,\n SimulateOkResult,\n SimulateRevertResult,\n SimulateRevertDecodeResult,\n SimulateSetupErrorResult,\n SimulateBalanceEntry,\n TrackedBalance,\n SlotFinderRequirement,\n Erc20BalanceRequirement,\n NativeBalanceRequirement,\n Erc20AllowanceRequirement,\n ContinuationIntent,\n ContinuationOutcome,\n Check,\n CheckComparator,\n Phase1ArtifactWire,\n ContinuationPlanWire,\n} from '@lifi/compose-spec';\nexport {\n SIMULATE_MAX_TRACKED_BALANCES,\n SIMULATE_MAX_REQUIREMENTS,\n} from '@lifi/compose-spec';\nexport { isComposeError, isComposePreparationError } from './errors.js';\n\nexport type {\n Bindable,\n InputHandle,\n ResourceInputHandle,\n OutputHandle,\n AnyHandle,\n} from './authoring/handles.js';\nexport { isInputHandle, isOutputHandle } from './authoring/handles.js';\nexport { ref } from './authoring/raw.js';\n\nexport type { AnyBindable } from './authoring/FlowBuilderCore.js';\nexport type { TypedFlow, FlowOptions } from './authoring/FlowBuilderCore.js';\n\nexport type { ComposeRunInput } from './run/inputs.js';\nexport { materialiser } from './run/inputs.js';\n\nexport { buildSimulateRequest } from './run/simulate.js';\nexport type { BuildSimulateRequestInput } from './run/simulate.js';\n\nexport { createComposeSdk } from './sdk.js';\nexport type { ComposeSdk, ComposeSdkOptions, FlowBuilder } from './sdk.js';\n\nimport * as guardsMod from './generated/guards.generated.js';\nimport * as materialisersMod from './generated/materialisers.generated.js';\nimport * as preconditionsMod from './generated/preconditions.generated.js';\nimport * as rawMod from './raw.js';\nimport * as resourcesMod from './resources.js';\n\n/**\n * Guard factories for protecting operation outputs (e.g. slippage tolerance).\n * Pass guards to an operation's `guards` array.\n *\n * @example\n * ```ts\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.token },\n * config: { resourceOut: resources.native(1) },\n * guards: [guards.slippage({ port: 'amountOut', bps: 300 })],\n * });\n * ```\n */\nexport const guards: typeof guardsMod = guardsMod;\n/**\n * Materialiser factories that tell the runtime how to resolve token input\n * amounts on-chain (e.g. read a wallet balance, accept a direct deposit).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0x...',\n * });\n * ```\n */\nexport const materialisers: typeof materialisersMod = materialisersMod;\n/**\n * Precondition factories for asserting on-chain state before a flow executes\n * (e.g. minimum token balances, ERC-20 allowances).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * preconditions: [\n * preconditions.erc20Balance({ wallet: '0x...', token: '0x...', balance: 1000n }),\n * ],\n * signer: '0x...',\n * });\n * ```\n */\nexport const preconditions: typeof preconditionsMod = preconditionsMod;\n/**\n * Resource declaration helpers for defining token inputs in a flow schema.\n * Use {@link resources.erc20} for ERC-20 tokens and {@link resources.native}\n * for the chain's native coin (ETH, MATIC, etc.).\n *\n * @example\n * ```ts\n * const builder = sdk.flow(1, {\n * inputs: {\n * usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1),\n * eth: resources.native(1),\n * },\n * });\n * ```\n */\nexport const resources: typeof resourcesMod = resourcesMod;\nexport * from './generated/config.generated.js';\n\n/**\n * Low-level escape hatch for constructing flow nodes, guards, and materialiser\n * inputs without the typed builder API. Prefer the generated operation methods\n * on {@link FlowBuilder} and the typed `guards`/`materialisers` namespaces\n * for most use cases.\n */\nexport const raw: typeof rawMod = rawMod;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6EA,0BAGO;AACP,oBAA0D;AAS1D,qBAA8C;AAC9C,iBAAoB;AAMpB,oBAA6B;AAE7B,sBAAqC;AAGrC,iBAAiC;AAGjC,gBAA2B;AAC3B,uBAAkC;AAClC,uBAAkC;AAClC,aAAwB;AACxB,mBAA8B;AA6D9B,0BAAc,4CA1Kd;AA4HO,MAAM,SAA2B;AAajC,MAAM,gBAAyC;AAgB/C,MAAM,gBAAyC;AAgB/C,MAAM,YAAiC;AASvC,MAAM,MAAqB;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@lifi/composer-sdk` — TypeScript SDK for building and compiling\n * Compose flows into executable EVM calldata.\n *\n * Start by creating an SDK instance with {@link createComposeSdk}, then use\n * {@link ComposeSdk.flow} to build flows and compile them.\n *\n * @packageDocumentation\n */\n\nexport type {\n AbiTypeToOutputKind,\n Address,\n InputDecl,\n InputSchema,\n InputSpecOf,\n IntegerString,\n IntegerStringInput,\n OutputKind,\n TypedGuard,\n TypedRef,\n} from './types.js';\n\nexport type {\n GetZapPacksOptions,\n ZapPackEdge,\n ZapPackOverview,\n} from './discovery.js';\nexport type {\n ComposeError,\n ComposeErrorCode,\n ComposePreparationOps,\n} from './errors.js';\nexport type {\n AppliedGuard,\n ApprovalEntry,\n Call,\n ComposeCompilePartialData,\n ComposeCompileRequest,\n ComposeCompileResult,\n ComposeCompileSuccessData,\n ComposeContinuation,\n ComposeErrorKind,\n ComposeRouteRequest,\n ComposeTransactionRequest,\n FailedPreparedOp,\n Flow,\n InputSpec,\n MaterialiserConfigOf,\n MaterialiserInput,\n Precondition,\n PreconditionConfigOf,\n PriceImpact,\n Ref,\n Resource,\n RouteAmount,\n RouteAmountAll,\n RouteAmountExact,\n SimulationPolicy,\n SimulationRevert,\n SolType,\n SweepTo,\n SimulateRequest,\n SimulateResult,\n SimulateOkResult,\n SimulateRevertResult,\n SimulateRevertDecodeResult,\n SimulateSetupErrorResult,\n SimulateBalanceEntry,\n TrackedBalance,\n SlotFinderRequirement,\n Erc20BalanceRequirement,\n NativeBalanceRequirement,\n Erc20AllowanceRequirement,\n ContinuationIntent,\n ContinuationOutcome,\n Check,\n CheckComparator,\n Phase1ArtifactWire,\n ContinuationPlanWire,\n} from '@lifi/compose-spec';\nexport {\n SIMULATE_MAX_TRACKED_BALANCES,\n SIMULATE_MAX_REQUIREMENTS,\n} from '@lifi/compose-spec';\nexport { isComposeError, isComposePreparationError } from './errors.js';\n\nexport type {\n Bindable,\n InputHandle,\n ResourceInputHandle,\n OutputHandle,\n AnyHandle,\n} from './authoring/handles.js';\nexport { isInputHandle, isOutputHandle } from './authoring/handles.js';\nexport { ref } from './authoring/raw.js';\n\nexport type { AnyBindable } from './authoring/FlowBuilderCore.js';\nexport type { TypedFlow, FlowOptions } from './authoring/FlowBuilderCore.js';\n\nexport type { ComposeRunInput } from './run/inputs.js';\nexport { materialiser } from './run/inputs.js';\n\nexport { buildSimulateRequest } from './run/simulate.js';\nexport type { BuildSimulateRequestInput } from './run/simulate.js';\n\nexport { createComposeSdk } from './sdk.js';\nexport type { ComposeSdk, ComposeSdkOptions, FlowBuilder } from './sdk.js';\n\nimport * as guardsMod from './generated/guards.generated.js';\nimport * as materialisersMod from './generated/materialisers.generated.js';\nimport * as preconditionsMod from './generated/preconditions.generated.js';\nimport * as rawMod from './raw.js';\nimport * as resourcesMod from './resources.js';\nimport * as routeAmountMod from './routeAmount.js';\n\n/**\n * Guard factories for protecting operation outputs (e.g. slippage tolerance).\n * Pass guards to an operation's `guards` array.\n *\n * @example\n * ```ts\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.token },\n * config: { resourceOut: resources.native(1) },\n * guards: [guards.slippage({ port: 'amountOut', bps: 300 })],\n * });\n * ```\n */\nexport const guards: typeof guardsMod = guardsMod;\n/**\n * Materialiser factories that tell the runtime how to resolve token input\n * amounts on-chain (e.g. read a wallet balance, accept a direct deposit).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0x...',\n * });\n * ```\n */\nexport const materialisers: typeof materialisersMod = materialisersMod;\n/**\n * Precondition factories for asserting on-chain state before a flow executes\n * (e.g. minimum token balances, ERC-20 allowances).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * preconditions: [\n * preconditions.erc20Balance({ wallet: '0x...', token: '0x...', balance: 1000n }),\n * ],\n * signer: '0x...',\n * });\n * ```\n */\nexport const preconditions: typeof preconditionsMod = preconditionsMod;\n/**\n * Resource declaration helpers for defining token inputs in a flow schema.\n * Use {@link resources.erc20} for ERC-20 tokens and {@link resources.native}\n * for the chain's native coin (ETH, MATIC, etc.).\n *\n * @example\n * ```ts\n * const builder = sdk.flow(1, {\n * inputs: {\n * usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1),\n * eth: resources.native(1),\n * },\n * });\n * ```\n */\nexport const resources: typeof resourcesMod = resourcesMod;\n/**\n * Amount constructors for {@link ComposeSdk.route}. Use\n * {@link routeAmount.exact} to spend a fixed amount of the `fromToken`, and\n * {@link routeAmount.all} to spend the signer's whole balance.\n *\n * @example\n * ```ts\n * // USDC into the Aave v3 aEthUSDC position — one routing-catalog edge.\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n * toToken: '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c',\n * amount: routeAmount.exact(1_000_000n),\n * signer: '0xYourAddress...',\n * });\n * ```\n */\nexport const routeAmount: typeof routeAmountMod = routeAmountMod;\nexport * from './generated/config.generated.js';\n\n/**\n * Low-level escape hatch for constructing flow nodes, guards, and materialiser\n * inputs without the typed builder API. Prefer the generated operation methods\n * on {@link FlowBuilder} and the typed `guards`/`materialisers` namespaces\n * for most use cases.\n */\nexport const raw: typeof rawMod = rawMod;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiFA,0BAGO;AACP,oBAA0D;AAS1D,qBAA8C;AAC9C,iBAAoB;AAMpB,oBAA6B;AAE7B,sBAAqC;AAGrC,iBAAiC;AAGjC,gBAA2B;AAC3B,uBAAkC;AAClC,uBAAkC;AAClC,aAAwB;AACxB,mBAA8B;AAC9B,qBAAgC;AA+EhC,0BAAc,4CAjMd;AAiIO,MAAM,SAA2B;AAajC,MAAM,gBAAyC;AAgB/C,MAAM,gBAAyC;AAgB/C,MAAM,YAAiC;AAkBvC,MAAM,cAAqC;AAS3C,MAAM,MAAqB;","names":[]}
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { AbiTypeToOutputKind, Address, InputDecl, InputSchema, InputSpecOf, IntegerString, IntegerStringInput, OutputKind, TypedGuard, TypedRef } from './types.cjs';
2
2
  export { GetZapPacksOptions, ZapPackEdge, ZapPackOverview } from './discovery.cjs';
3
3
  export { ComposeError, ComposeErrorCode, ComposePreparationOps, isComposeError, isComposePreparationError } from './errors.cjs';
4
- export { AppliedGuard, ApprovalEntry, Call, Check, CheckComparator, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeContinuation, ComposeErrorKind, ComposeTransactionRequest, ContinuationIntent, ContinuationOutcome, ContinuationPlanWire, Erc20AllowanceRequirement, Erc20BalanceRequirement, FailedPreparedOp, Flow, InputSpec, MaterialiserConfigOf, MaterialiserInput, NativeBalanceRequirement, Phase1ArtifactWire, Precondition, PreconditionConfigOf, PriceImpact, Ref, Resource, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SlotFinderRequirement, SolType, SweepTo, TrackedBalance } from '@lifi/compose-spec';
4
+ export { AppliedGuard, ApprovalEntry, Call, Check, CheckComparator, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeContinuation, ComposeErrorKind, ComposeRouteRequest, ComposeTransactionRequest, ContinuationIntent, ContinuationOutcome, ContinuationPlanWire, Erc20AllowanceRequirement, Erc20BalanceRequirement, FailedPreparedOp, Flow, InputSpec, MaterialiserConfigOf, MaterialiserInput, NativeBalanceRequirement, Phase1ArtifactWire, Precondition, PreconditionConfigOf, PriceImpact, Ref, Resource, RouteAmount, RouteAmountAll, RouteAmountExact, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SlotFinderRequirement, SolType, SweepTo, TrackedBalance } from '@lifi/compose-spec';
5
5
  export { AnyHandle, Bindable, InputHandle, OutputHandle, ResourceInputHandle, isInputHandle, isOutputHandle } from './authoring/handles.cjs';
6
6
  export { ref } from './authoring/raw.cjs';
7
7
  export { AnyBindable, FlowOptions, TypedFlow } from './authoring/FlowBuilderCore.cjs';
@@ -9,11 +9,12 @@ export { ComposeRunInput, materialiser } from './run/inputs.cjs';
9
9
  export { BuildSimulateRequestInput, buildSimulateRequest } from './run/simulate.cjs';
10
10
  export { ComposeSdk, ComposeSdkOptions, FlowBuilder, createComposeSdk } from './sdk.cjs';
11
11
  import { g as guardsMod } from './guards.generated-M3VAIevI.cjs';
12
- import { m as materialisersMod } from './materialisers.generated-DaJRwiRe.cjs';
12
+ import { m as materialisersMod } from './materialisers.generated-BWq5oePO.cjs';
13
13
  import { p as preconditionsMod } from './preconditions.generated-DblS13Wq.cjs';
14
14
  import { r as rawMod } from './raw-Dj_2rBSQ.cjs';
15
15
  import { r as resourcesMod } from './resources-BKlFxjo8.cjs';
16
- export { AaveBorrowConfig, AaveClaimRewardsConfig, AaveGetHealthFactorConfig, AaveRepayConfig, AaveRepayWithATokensConfig, AaveSetEModeConfig, BalanceOfMaterialiserConfig, Between010000, Between0255, CallMaterialiserConfig, ContinuationAssertReadyConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreEmitEvent1Config, CoreEmitEvent2Config, CoreEmitEvent3Config, CoreEmitEvent4Config, CoreInvokeConfig, CoreNumericInvariantGuardConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, FlashloanMaterialiserConfig, InvariantEqConfig, InvariantGtConfig, InvariantGteConfig, InvariantLtConfig, InvariantLteConfig, InvariantNeqConfig, InvariantNumericConfig, InvariantNumericInRangeConfig, LifiFlashloanRepayConfig, LifiSwapConfig, LifiZapConfig, MaxItems50, MaxLength64, MaxLength65536, MorphoBlueBorrowConfig, MorphoBlueGetPositionConfig, MorphoBlueRepayConfig, MorphoBlueSupplyCollateralConfig, MorphoBlueSupplyConfig, MorphoBlueWithdrawCollateralConfig, MorphoBlueWithdrawConfig, NativeBalancePreconditionConfig, NonNegative, ParaswapBuyConfig, Positive, SlippageGuardConfig, StartsWith0X } from './generated/config.generated.cjs';
16
+ import { r as routeAmountMod } from './routeAmount-DdbJYJyM.cjs';
17
+ export { AaveBorrowConfig, AaveClaimRewardsConfig, AaveGetHealthFactorConfig, AaveRepayConfig, AaveRepayWithATokensConfig, AaveSetEModeConfig, BalanceOfMaterialiserConfig, Between010000, Between0255, CallMaterialiserConfig, ContinuationAssertReadyConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreEmitEvent1Config, CoreEmitEvent2Config, CoreEmitEvent3Config, CoreEmitEvent4Config, CoreInvokeConfig, CoreNumericInvariantGuardConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, FlashloanMaterialiserConfig, InvariantEqConfig, InvariantGtConfig, InvariantGteConfig, InvariantLtConfig, InvariantLteConfig, InvariantNeqConfig, InvariantNumericConfig, InvariantNumericInRangeConfig, LifiFlashloanRepayConfig, LifiSwapConfig, LifiZapAsyncConfig, LifiZapConfig, MaxItems50, MaxLength64, MaxLength65536, MorphoBlueBorrowConfig, MorphoBlueGetPositionConfig, MorphoBlueRepayConfig, MorphoBlueSupplyCollateralConfig, MorphoBlueSupplyConfig, MorphoBlueWithdrawCollateralConfig, MorphoBlueWithdrawConfig, NativeBalancePreconditionConfig, NonNegative, ParaswapBuyConfig, Positive, SlippageGuardConfig, StartsWith0X } from './generated/config.generated.cjs';
17
18
  import './client.cjs';
18
19
  import './generated/operations.generated.cjs';
19
20
  import './authoring/signatureArgs.cjs';
@@ -88,6 +89,24 @@ declare const preconditions: typeof preconditionsMod;
88
89
  * ```
89
90
  */
90
91
  declare const resources: typeof resourcesMod;
92
+ /**
93
+ * Amount constructors for {@link ComposeSdk.route}. Use
94
+ * {@link routeAmount.exact} to spend a fixed amount of the `fromToken`, and
95
+ * {@link routeAmount.all} to spend the signer's whole balance.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * // USDC into the Aave v3 aEthUSDC position — one routing-catalog edge.
100
+ * const result = await sdk.route({
101
+ * chainId: 1,
102
+ * fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
103
+ * toToken: '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c',
104
+ * amount: routeAmount.exact(1_000_000n),
105
+ * signer: '0xYourAddress...',
106
+ * });
107
+ * ```
108
+ */
109
+ declare const routeAmount: typeof routeAmountMod;
91
110
 
92
111
  /**
93
112
  * Low-level escape hatch for constructing flow nodes, guards, and materialiser
@@ -97,4 +116,4 @@ declare const resources: typeof resourcesMod;
97
116
  */
98
117
  declare const raw: typeof rawMod;
99
118
 
100
- export { guards, materialisers, preconditions, raw, resources };
119
+ export { guards, materialisers, preconditions, raw, resources, routeAmount };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { AbiTypeToOutputKind, Address, InputDecl, InputSchema, InputSpecOf, IntegerString, IntegerStringInput, OutputKind, TypedGuard, TypedRef } from './types.js';
2
2
  export { GetZapPacksOptions, ZapPackEdge, ZapPackOverview } from './discovery.js';
3
3
  export { ComposeError, ComposeErrorCode, ComposePreparationOps, isComposeError, isComposePreparationError } from './errors.js';
4
- export { AppliedGuard, ApprovalEntry, Call, Check, CheckComparator, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeContinuation, ComposeErrorKind, ComposeTransactionRequest, ContinuationIntent, ContinuationOutcome, ContinuationPlanWire, Erc20AllowanceRequirement, Erc20BalanceRequirement, FailedPreparedOp, Flow, InputSpec, MaterialiserConfigOf, MaterialiserInput, NativeBalanceRequirement, Phase1ArtifactWire, Precondition, PreconditionConfigOf, PriceImpact, Ref, Resource, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SlotFinderRequirement, SolType, SweepTo, TrackedBalance } from '@lifi/compose-spec';
4
+ export { AppliedGuard, ApprovalEntry, Call, Check, CheckComparator, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeContinuation, ComposeErrorKind, ComposeRouteRequest, ComposeTransactionRequest, ContinuationIntent, ContinuationOutcome, ContinuationPlanWire, Erc20AllowanceRequirement, Erc20BalanceRequirement, FailedPreparedOp, Flow, InputSpec, MaterialiserConfigOf, MaterialiserInput, NativeBalanceRequirement, Phase1ArtifactWire, Precondition, PreconditionConfigOf, PriceImpact, Ref, Resource, RouteAmount, RouteAmountAll, RouteAmountExact, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SlotFinderRequirement, SolType, SweepTo, TrackedBalance } from '@lifi/compose-spec';
5
5
  export { AnyHandle, Bindable, InputHandle, OutputHandle, ResourceInputHandle, isInputHandle, isOutputHandle } from './authoring/handles.js';
6
6
  export { ref } from './authoring/raw.js';
7
7
  export { AnyBindable, FlowOptions, TypedFlow } from './authoring/FlowBuilderCore.js';
@@ -9,11 +9,12 @@ export { ComposeRunInput, materialiser } from './run/inputs.js';
9
9
  export { BuildSimulateRequestInput, buildSimulateRequest } from './run/simulate.js';
10
10
  export { ComposeSdk, ComposeSdkOptions, FlowBuilder, createComposeSdk } from './sdk.js';
11
11
  import { g as guardsMod } from './guards.generated-BPLFwe7y.js';
12
- import { m as materialisersMod } from './materialisers.generated-BfWJ-g7t.js';
12
+ import { m as materialisersMod } from './materialisers.generated-BMkBQgWZ.js';
13
13
  import { p as preconditionsMod } from './preconditions.generated-U7YpVh30.js';
14
14
  import { r as rawMod } from './raw-IxCF_bSS.js';
15
15
  import { r as resourcesMod } from './resources-CYis1_DS.js';
16
- export { AaveBorrowConfig, AaveClaimRewardsConfig, AaveGetHealthFactorConfig, AaveRepayConfig, AaveRepayWithATokensConfig, AaveSetEModeConfig, BalanceOfMaterialiserConfig, Between010000, Between0255, CallMaterialiserConfig, ContinuationAssertReadyConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreEmitEvent1Config, CoreEmitEvent2Config, CoreEmitEvent3Config, CoreEmitEvent4Config, CoreInvokeConfig, CoreNumericInvariantGuardConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, FlashloanMaterialiserConfig, InvariantEqConfig, InvariantGtConfig, InvariantGteConfig, InvariantLtConfig, InvariantLteConfig, InvariantNeqConfig, InvariantNumericConfig, InvariantNumericInRangeConfig, LifiFlashloanRepayConfig, LifiSwapConfig, LifiZapConfig, MaxItems50, MaxLength64, MaxLength65536, MorphoBlueBorrowConfig, MorphoBlueGetPositionConfig, MorphoBlueRepayConfig, MorphoBlueSupplyCollateralConfig, MorphoBlueSupplyConfig, MorphoBlueWithdrawCollateralConfig, MorphoBlueWithdrawConfig, NativeBalancePreconditionConfig, NonNegative, ParaswapBuyConfig, Positive, SlippageGuardConfig, StartsWith0X } from './generated/config.generated.js';
16
+ import { r as routeAmountMod } from './routeAmount-DdbJYJyM.js';
17
+ export { AaveBorrowConfig, AaveClaimRewardsConfig, AaveGetHealthFactorConfig, AaveRepayConfig, AaveRepayWithATokensConfig, AaveSetEModeConfig, BalanceOfMaterialiserConfig, Between010000, Between0255, CallMaterialiserConfig, ContinuationAssertReadyConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreEmitEvent1Config, CoreEmitEvent2Config, CoreEmitEvent3Config, CoreEmitEvent4Config, CoreInvokeConfig, CoreNumericInvariantGuardConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, FlashloanMaterialiserConfig, InvariantEqConfig, InvariantGtConfig, InvariantGteConfig, InvariantLtConfig, InvariantLteConfig, InvariantNeqConfig, InvariantNumericConfig, InvariantNumericInRangeConfig, LifiFlashloanRepayConfig, LifiSwapConfig, LifiZapAsyncConfig, LifiZapConfig, MaxItems50, MaxLength64, MaxLength65536, MorphoBlueBorrowConfig, MorphoBlueGetPositionConfig, MorphoBlueRepayConfig, MorphoBlueSupplyCollateralConfig, MorphoBlueSupplyConfig, MorphoBlueWithdrawCollateralConfig, MorphoBlueWithdrawConfig, NativeBalancePreconditionConfig, NonNegative, ParaswapBuyConfig, Positive, SlippageGuardConfig, StartsWith0X } from './generated/config.generated.js';
17
18
  import './client.js';
18
19
  import './generated/operations.generated.js';
19
20
  import './authoring/signatureArgs.js';
@@ -88,6 +89,24 @@ declare const preconditions: typeof preconditionsMod;
88
89
  * ```
89
90
  */
90
91
  declare const resources: typeof resourcesMod;
92
+ /**
93
+ * Amount constructors for {@link ComposeSdk.route}. Use
94
+ * {@link routeAmount.exact} to spend a fixed amount of the `fromToken`, and
95
+ * {@link routeAmount.all} to spend the signer's whole balance.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * // USDC into the Aave v3 aEthUSDC position — one routing-catalog edge.
100
+ * const result = await sdk.route({
101
+ * chainId: 1,
102
+ * fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
103
+ * toToken: '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c',
104
+ * amount: routeAmount.exact(1_000_000n),
105
+ * signer: '0xYourAddress...',
106
+ * });
107
+ * ```
108
+ */
109
+ declare const routeAmount: typeof routeAmountMod;
91
110
 
92
111
  /**
93
112
  * Low-level escape hatch for constructing flow nodes, guards, and materialiser
@@ -97,4 +116,4 @@ declare const resources: typeof resourcesMod;
97
116
  */
98
117
  declare const raw: typeof rawMod;
99
118
 
100
- export { guards, materialisers, preconditions, raw, resources };
119
+ export { guards, materialisers, preconditions, raw, resources, routeAmount };
package/dist/index.js CHANGED
@@ -13,10 +13,12 @@ import * as materialisersMod from "./generated/materialisers.generated.js";
13
13
  import * as preconditionsMod from "./generated/preconditions.generated.js";
14
14
  import * as rawMod from "./raw.js";
15
15
  import * as resourcesMod from "./resources.js";
16
+ import * as routeAmountMod from "./routeAmount.js";
16
17
  const guards = guardsMod;
17
18
  const materialisers = materialisersMod;
18
19
  const preconditions = preconditionsMod;
19
20
  const resources = resourcesMod;
21
+ const routeAmount = routeAmountMod;
20
22
  export * from "./generated/config.generated.js";
21
23
  const raw = rawMod;
22
24
  export {
@@ -34,6 +36,7 @@ export {
34
36
  preconditions,
35
37
  raw,
36
38
  ref,
37
- resources
39
+ resources,
40
+ routeAmount
38
41
  };
39
42
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@lifi/composer-sdk` — TypeScript SDK for building and compiling\n * Compose flows into executable EVM calldata.\n *\n * Start by creating an SDK instance with {@link createComposeSdk}, then use\n * {@link ComposeSdk.flow} to build flows and compile them.\n *\n * @packageDocumentation\n */\n\nexport type {\n AbiTypeToOutputKind,\n Address,\n InputDecl,\n InputSchema,\n InputSpecOf,\n IntegerString,\n IntegerStringInput,\n OutputKind,\n TypedGuard,\n TypedRef,\n} from './types.js';\n\nexport type {\n GetZapPacksOptions,\n ZapPackEdge,\n ZapPackOverview,\n} from './discovery.js';\nexport type {\n ComposeError,\n ComposeErrorCode,\n ComposePreparationOps,\n} from './errors.js';\nexport type {\n AppliedGuard,\n ApprovalEntry,\n Call,\n ComposeCompilePartialData,\n ComposeCompileRequest,\n ComposeCompileResult,\n ComposeCompileSuccessData,\n ComposeContinuation,\n ComposeErrorKind,\n ComposeTransactionRequest,\n FailedPreparedOp,\n Flow,\n InputSpec,\n MaterialiserConfigOf,\n MaterialiserInput,\n Precondition,\n PreconditionConfigOf,\n PriceImpact,\n Ref,\n Resource,\n SimulationPolicy,\n SimulationRevert,\n SolType,\n SweepTo,\n SimulateRequest,\n SimulateResult,\n SimulateOkResult,\n SimulateRevertResult,\n SimulateRevertDecodeResult,\n SimulateSetupErrorResult,\n SimulateBalanceEntry,\n TrackedBalance,\n SlotFinderRequirement,\n Erc20BalanceRequirement,\n NativeBalanceRequirement,\n Erc20AllowanceRequirement,\n ContinuationIntent,\n ContinuationOutcome,\n Check,\n CheckComparator,\n Phase1ArtifactWire,\n ContinuationPlanWire,\n} from '@lifi/compose-spec';\nexport {\n SIMULATE_MAX_TRACKED_BALANCES,\n SIMULATE_MAX_REQUIREMENTS,\n} from '@lifi/compose-spec';\nexport { isComposeError, isComposePreparationError } from './errors.js';\n\nexport type {\n Bindable,\n InputHandle,\n ResourceInputHandle,\n OutputHandle,\n AnyHandle,\n} from './authoring/handles.js';\nexport { isInputHandle, isOutputHandle } from './authoring/handles.js';\nexport { ref } from './authoring/raw.js';\n\nexport type { AnyBindable } from './authoring/FlowBuilderCore.js';\nexport type { TypedFlow, FlowOptions } from './authoring/FlowBuilderCore.js';\n\nexport type { ComposeRunInput } from './run/inputs.js';\nexport { materialiser } from './run/inputs.js';\n\nexport { buildSimulateRequest } from './run/simulate.js';\nexport type { BuildSimulateRequestInput } from './run/simulate.js';\n\nexport { createComposeSdk } from './sdk.js';\nexport type { ComposeSdk, ComposeSdkOptions, FlowBuilder } from './sdk.js';\n\nimport * as guardsMod from './generated/guards.generated.js';\nimport * as materialisersMod from './generated/materialisers.generated.js';\nimport * as preconditionsMod from './generated/preconditions.generated.js';\nimport * as rawMod from './raw.js';\nimport * as resourcesMod from './resources.js';\n\n/**\n * Guard factories for protecting operation outputs (e.g. slippage tolerance).\n * Pass guards to an operation's `guards` array.\n *\n * @example\n * ```ts\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.token },\n * config: { resourceOut: resources.native(1) },\n * guards: [guards.slippage({ port: 'amountOut', bps: 300 })],\n * });\n * ```\n */\nexport const guards: typeof guardsMod = guardsMod;\n/**\n * Materialiser factories that tell the runtime how to resolve token input\n * amounts on-chain (e.g. read a wallet balance, accept a direct deposit).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0x...',\n * });\n * ```\n */\nexport const materialisers: typeof materialisersMod = materialisersMod;\n/**\n * Precondition factories for asserting on-chain state before a flow executes\n * (e.g. minimum token balances, ERC-20 allowances).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * preconditions: [\n * preconditions.erc20Balance({ wallet: '0x...', token: '0x...', balance: 1000n }),\n * ],\n * signer: '0x...',\n * });\n * ```\n */\nexport const preconditions: typeof preconditionsMod = preconditionsMod;\n/**\n * Resource declaration helpers for defining token inputs in a flow schema.\n * Use {@link resources.erc20} for ERC-20 tokens and {@link resources.native}\n * for the chain's native coin (ETH, MATIC, etc.).\n *\n * @example\n * ```ts\n * const builder = sdk.flow(1, {\n * inputs: {\n * usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1),\n * eth: resources.native(1),\n * },\n * });\n * ```\n */\nexport const resources: typeof resourcesMod = resourcesMod;\nexport * from './generated/config.generated.js';\n\n/**\n * Low-level escape hatch for constructing flow nodes, guards, and materialiser\n * inputs without the typed builder API. Prefer the generated operation methods\n * on {@link FlowBuilder} and the typed `guards`/`materialisers` namespaces\n * for most use cases.\n */\nexport const raw: typeof rawMod = rawMod;\n"],"mappings":"AA6EA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,iCAAiC;AAS1D,SAAS,eAAe,sBAAsB;AAC9C,SAAS,WAAW;AAMpB,SAAS,oBAAoB;AAE7B,SAAS,4BAA4B;AAGrC,SAAS,wBAAwB;AAGjC,YAAY,eAAe;AAC3B,YAAY,sBAAsB;AAClC,YAAY,sBAAsB;AAClC,YAAY,YAAY;AACxB,YAAY,kBAAkB;AAevB,MAAM,SAA2B;AAajC,MAAM,gBAAyC;AAgB/C,MAAM,gBAAyC;AAgB/C,MAAM,YAAiC;AAC9C,cAAc;AAQP,MAAM,MAAqB;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@lifi/composer-sdk` — TypeScript SDK for building and compiling\n * Compose flows into executable EVM calldata.\n *\n * Start by creating an SDK instance with {@link createComposeSdk}, then use\n * {@link ComposeSdk.flow} to build flows and compile them.\n *\n * @packageDocumentation\n */\n\nexport type {\n AbiTypeToOutputKind,\n Address,\n InputDecl,\n InputSchema,\n InputSpecOf,\n IntegerString,\n IntegerStringInput,\n OutputKind,\n TypedGuard,\n TypedRef,\n} from './types.js';\n\nexport type {\n GetZapPacksOptions,\n ZapPackEdge,\n ZapPackOverview,\n} from './discovery.js';\nexport type {\n ComposeError,\n ComposeErrorCode,\n ComposePreparationOps,\n} from './errors.js';\nexport type {\n AppliedGuard,\n ApprovalEntry,\n Call,\n ComposeCompilePartialData,\n ComposeCompileRequest,\n ComposeCompileResult,\n ComposeCompileSuccessData,\n ComposeContinuation,\n ComposeErrorKind,\n ComposeRouteRequest,\n ComposeTransactionRequest,\n FailedPreparedOp,\n Flow,\n InputSpec,\n MaterialiserConfigOf,\n MaterialiserInput,\n Precondition,\n PreconditionConfigOf,\n PriceImpact,\n Ref,\n Resource,\n RouteAmount,\n RouteAmountAll,\n RouteAmountExact,\n SimulationPolicy,\n SimulationRevert,\n SolType,\n SweepTo,\n SimulateRequest,\n SimulateResult,\n SimulateOkResult,\n SimulateRevertResult,\n SimulateRevertDecodeResult,\n SimulateSetupErrorResult,\n SimulateBalanceEntry,\n TrackedBalance,\n SlotFinderRequirement,\n Erc20BalanceRequirement,\n NativeBalanceRequirement,\n Erc20AllowanceRequirement,\n ContinuationIntent,\n ContinuationOutcome,\n Check,\n CheckComparator,\n Phase1ArtifactWire,\n ContinuationPlanWire,\n} from '@lifi/compose-spec';\nexport {\n SIMULATE_MAX_TRACKED_BALANCES,\n SIMULATE_MAX_REQUIREMENTS,\n} from '@lifi/compose-spec';\nexport { isComposeError, isComposePreparationError } from './errors.js';\n\nexport type {\n Bindable,\n InputHandle,\n ResourceInputHandle,\n OutputHandle,\n AnyHandle,\n} from './authoring/handles.js';\nexport { isInputHandle, isOutputHandle } from './authoring/handles.js';\nexport { ref } from './authoring/raw.js';\n\nexport type { AnyBindable } from './authoring/FlowBuilderCore.js';\nexport type { TypedFlow, FlowOptions } from './authoring/FlowBuilderCore.js';\n\nexport type { ComposeRunInput } from './run/inputs.js';\nexport { materialiser } from './run/inputs.js';\n\nexport { buildSimulateRequest } from './run/simulate.js';\nexport type { BuildSimulateRequestInput } from './run/simulate.js';\n\nexport { createComposeSdk } from './sdk.js';\nexport type { ComposeSdk, ComposeSdkOptions, FlowBuilder } from './sdk.js';\n\nimport * as guardsMod from './generated/guards.generated.js';\nimport * as materialisersMod from './generated/materialisers.generated.js';\nimport * as preconditionsMod from './generated/preconditions.generated.js';\nimport * as rawMod from './raw.js';\nimport * as resourcesMod from './resources.js';\nimport * as routeAmountMod from './routeAmount.js';\n\n/**\n * Guard factories for protecting operation outputs (e.g. slippage tolerance).\n * Pass guards to an operation's `guards` array.\n *\n * @example\n * ```ts\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.token },\n * config: { resourceOut: resources.native(1) },\n * guards: [guards.slippage({ port: 'amountOut', bps: 300 })],\n * });\n * ```\n */\nexport const guards: typeof guardsMod = guardsMod;\n/**\n * Materialiser factories that tell the runtime how to resolve token input\n * amounts on-chain (e.g. read a wallet balance, accept a direct deposit).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0x...',\n * });\n * ```\n */\nexport const materialisers: typeof materialisersMod = materialisersMod;\n/**\n * Precondition factories for asserting on-chain state before a flow executes\n * (e.g. minimum token balances, ERC-20 allowances).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * preconditions: [\n * preconditions.erc20Balance({ wallet: '0x...', token: '0x...', balance: 1000n }),\n * ],\n * signer: '0x...',\n * });\n * ```\n */\nexport const preconditions: typeof preconditionsMod = preconditionsMod;\n/**\n * Resource declaration helpers for defining token inputs in a flow schema.\n * Use {@link resources.erc20} for ERC-20 tokens and {@link resources.native}\n * for the chain's native coin (ETH, MATIC, etc.).\n *\n * @example\n * ```ts\n * const builder = sdk.flow(1, {\n * inputs: {\n * usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1),\n * eth: resources.native(1),\n * },\n * });\n * ```\n */\nexport const resources: typeof resourcesMod = resourcesMod;\n/**\n * Amount constructors for {@link ComposeSdk.route}. Use\n * {@link routeAmount.exact} to spend a fixed amount of the `fromToken`, and\n * {@link routeAmount.all} to spend the signer's whole balance.\n *\n * @example\n * ```ts\n * // USDC into the Aave v3 aEthUSDC position — one routing-catalog edge.\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n * toToken: '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c',\n * amount: routeAmount.exact(1_000_000n),\n * signer: '0xYourAddress...',\n * });\n * ```\n */\nexport const routeAmount: typeof routeAmountMod = routeAmountMod;\nexport * from './generated/config.generated.js';\n\n/**\n * Low-level escape hatch for constructing flow nodes, guards, and materialiser\n * inputs without the typed builder API. Prefer the generated operation methods\n * on {@link FlowBuilder} and the typed `guards`/`materialisers` namespaces\n * for most use cases.\n */\nexport const raw: typeof rawMod = rawMod;\n"],"mappings":"AAiFA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,iCAAiC;AAS1D,SAAS,eAAe,sBAAsB;AAC9C,SAAS,WAAW;AAMpB,SAAS,oBAAoB;AAE7B,SAAS,4BAA4B;AAGrC,SAAS,wBAAwB;AAGjC,YAAY,eAAe;AAC3B,YAAY,sBAAsB;AAClC,YAAY,sBAAsB;AAClC,YAAY,YAAY;AACxB,YAAY,kBAAkB;AAC9B,YAAY,oBAAoB;AAezB,MAAM,SAA2B;AAajC,MAAM,gBAAyC;AAgB/C,MAAM,gBAAyC;AAgB/C,MAAM,YAAiC;AAkBvC,MAAM,cAAqC;AAClD,cAAc;AAQP,MAAM,MAAqB;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import { MaterialiserConfigOf, MaterialiserInput } from '@lifi/compose-spec';
2
- import { BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfig$1, CallMaterialiserConfig as CallMaterialiserConfig$1, DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfig$1, FlashloanMaterialiserConfig as FlashloanMaterialiserConfig$1 } from './generated/config.generated.js';
2
+ import { BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfig$1, CallMaterialiserConfig as CallMaterialiserConfig$1, DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfig$1 } from './generated/config.generated.js';
3
3
 
4
4
  type BalanceOfMaterialiserConfig = MaterialiserConfigOf<BalanceOfMaterialiserConfig$1>;
5
5
  /** Read the on-chain token balance of an address as the input amount — accepts: resource */
@@ -10,20 +10,15 @@ declare const directDeposit: (config: DirectDepositMaterialiserConfig) => Materi
10
10
  type CallMaterialiserConfig = MaterialiserConfigOf<CallMaterialiserConfig$1>;
11
11
  /** Execute an arbitrary contract call and measure the resulting token balance diff — accepts: resource */
12
12
  declare const call: (config: CallMaterialiserConfig) => MaterialiserInput;
13
- type FlashloanMaterialiserConfig = MaterialiserConfigOf<FlashloanMaterialiserConfig$1>;
14
- /** Borrow tokens from a flashloan provider; amount becomes a register populated by the proxy at callback time — accepts: resource */
15
- declare const flashloan: (config: FlashloanMaterialiserConfig) => MaterialiserInput;
16
13
 
17
14
  type materialisersMod_BalanceOfMaterialiserConfig = BalanceOfMaterialiserConfig;
18
15
  type materialisersMod_CallMaterialiserConfig = CallMaterialiserConfig;
19
16
  type materialisersMod_DirectDepositMaterialiserConfig = DirectDepositMaterialiserConfig;
20
- type materialisersMod_FlashloanMaterialiserConfig = FlashloanMaterialiserConfig;
21
17
  declare const materialisersMod_balanceOf: typeof balanceOf;
22
18
  declare const materialisersMod_call: typeof call;
23
19
  declare const materialisersMod_directDeposit: typeof directDeposit;
24
- declare const materialisersMod_flashloan: typeof flashloan;
25
20
  declare namespace materialisersMod {
26
- export { type materialisersMod_BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfig, type materialisersMod_CallMaterialiserConfig as CallMaterialiserConfig, type materialisersMod_DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfig, type materialisersMod_FlashloanMaterialiserConfig as FlashloanMaterialiserConfig, materialisersMod_balanceOf as balanceOf, materialisersMod_call as call, materialisersMod_directDeposit as directDeposit, materialisersMod_flashloan as flashloan };
21
+ export { type materialisersMod_BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfig, type materialisersMod_CallMaterialiserConfig as CallMaterialiserConfig, type materialisersMod_DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfig, materialisersMod_balanceOf as balanceOf, materialisersMod_call as call, materialisersMod_directDeposit as directDeposit };
27
22
  }
28
23
 
29
- export { type BalanceOfMaterialiserConfig as B, type CallMaterialiserConfig as C, type DirectDepositMaterialiserConfig as D, type FlashloanMaterialiserConfig as F, balanceOf as b, call as c, directDeposit as d, flashloan as f, materialisersMod as m };
24
+ export { type BalanceOfMaterialiserConfig as B, type CallMaterialiserConfig as C, type DirectDepositMaterialiserConfig as D, balanceOf as b, call as c, directDeposit as d, materialisersMod as m };
@@ -1,5 +1,5 @@
1
1
  import { MaterialiserConfigOf, MaterialiserInput } from '@lifi/compose-spec';
2
- import { BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfig$1, CallMaterialiserConfig as CallMaterialiserConfig$1, DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfig$1, FlashloanMaterialiserConfig as FlashloanMaterialiserConfig$1 } from './generated/config.generated.cjs';
2
+ import { BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfig$1, CallMaterialiserConfig as CallMaterialiserConfig$1, DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfig$1 } from './generated/config.generated.cjs';
3
3
 
4
4
  type BalanceOfMaterialiserConfig = MaterialiserConfigOf<BalanceOfMaterialiserConfig$1>;
5
5
  /** Read the on-chain token balance of an address as the input amount — accepts: resource */
@@ -10,20 +10,15 @@ declare const directDeposit: (config: DirectDepositMaterialiserConfig) => Materi
10
10
  type CallMaterialiserConfig = MaterialiserConfigOf<CallMaterialiserConfig$1>;
11
11
  /** Execute an arbitrary contract call and measure the resulting token balance diff — accepts: resource */
12
12
  declare const call: (config: CallMaterialiserConfig) => MaterialiserInput;
13
- type FlashloanMaterialiserConfig = MaterialiserConfigOf<FlashloanMaterialiserConfig$1>;
14
- /** Borrow tokens from a flashloan provider; amount becomes a register populated by the proxy at callback time — accepts: resource */
15
- declare const flashloan: (config: FlashloanMaterialiserConfig) => MaterialiserInput;
16
13
 
17
14
  type materialisersMod_BalanceOfMaterialiserConfig = BalanceOfMaterialiserConfig;
18
15
  type materialisersMod_CallMaterialiserConfig = CallMaterialiserConfig;
19
16
  type materialisersMod_DirectDepositMaterialiserConfig = DirectDepositMaterialiserConfig;
20
- type materialisersMod_FlashloanMaterialiserConfig = FlashloanMaterialiserConfig;
21
17
  declare const materialisersMod_balanceOf: typeof balanceOf;
22
18
  declare const materialisersMod_call: typeof call;
23
19
  declare const materialisersMod_directDeposit: typeof directDeposit;
24
- declare const materialisersMod_flashloan: typeof flashloan;
25
20
  declare namespace materialisersMod {
26
- export { type materialisersMod_BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfig, type materialisersMod_CallMaterialiserConfig as CallMaterialiserConfig, type materialisersMod_DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfig, type materialisersMod_FlashloanMaterialiserConfig as FlashloanMaterialiserConfig, materialisersMod_balanceOf as balanceOf, materialisersMod_call as call, materialisersMod_directDeposit as directDeposit, materialisersMod_flashloan as flashloan };
21
+ export { type materialisersMod_BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfig, type materialisersMod_CallMaterialiserConfig as CallMaterialiserConfig, type materialisersMod_DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfig, materialisersMod_balanceOf as balanceOf, materialisersMod_call as call, materialisersMod_directDeposit as directDeposit };
27
22
  }
28
23
 
29
- export { type BalanceOfMaterialiserConfig as B, type CallMaterialiserConfig as C, type DirectDepositMaterialiserConfig as D, type FlashloanMaterialiserConfig as F, balanceOf as b, call as c, directDeposit as d, flashloan as f, materialisersMod as m };
24
+ export { type BalanceOfMaterialiserConfig as B, type CallMaterialiserConfig as C, type DirectDepositMaterialiserConfig as D, balanceOf as b, call as c, directDeposit as d, materialisersMod as m };
@@ -0,0 +1,55 @@
1
+ import { RouteAmountAll, RouteAmountExact } from '@lifi/compose-spec';
2
+
3
+ /**
4
+ * Spend an exact amount of the route's `fromToken`.
5
+ *
6
+ * @param amount - Amount in the token's smallest unit. `bigint` is serialised
7
+ * to a decimal string when the request is sent.
8
+ * @returns The `EXACT` member of the route amount union.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const result = await sdk.route({
13
+ * chainId: 1,
14
+ * fromToken: NATIVE_ETH,
15
+ * toToken: WETH,
16
+ * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped
17
+ * signer: OWNER,
18
+ * });
19
+ * ```
20
+ */
21
+ declare const exact: (amount: bigint | string) => RouteAmountExact;
22
+ /**
23
+ * Spend the signer's entire `fromToken` balance, resolved on-chain at execution
24
+ * time.
25
+ *
26
+ * Not supported when `fromToken` is the chain's native sentinel — the server
27
+ * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain
28
+ * balance to sweep; use {@link exact} for native inputs.
29
+ *
30
+ * @param simAmount - A realistic estimate of that balance, in the token's
31
+ * smallest unit. The server quotes and simulates against this value, so it
32
+ * shapes the returned quote and preconditions — but the amount actually moved
33
+ * is whatever the balance turns out to be.
34
+ * @returns The `ALL` member of the route amount union.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const result = await sdk.route({
39
+ * chainId: 1,
40
+ * fromToken: USDC,
41
+ * toToken: A_ETH_USDC,
42
+ * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand
43
+ * signer: OWNER,
44
+ * });
45
+ * ```
46
+ */
47
+ declare const all: (simAmount: bigint | string) => RouteAmountAll;
48
+
49
+ declare const routeAmountMod_all: typeof all;
50
+ declare const routeAmountMod_exact: typeof exact;
51
+ declare namespace routeAmountMod {
52
+ export { routeAmountMod_all as all, routeAmountMod_exact as exact };
53
+ }
54
+
55
+ export { all as a, exact as e, routeAmountMod as r };
@@ -0,0 +1,55 @@
1
+ import { RouteAmountAll, RouteAmountExact } from '@lifi/compose-spec';
2
+
3
+ /**
4
+ * Spend an exact amount of the route's `fromToken`.
5
+ *
6
+ * @param amount - Amount in the token's smallest unit. `bigint` is serialised
7
+ * to a decimal string when the request is sent.
8
+ * @returns The `EXACT` member of the route amount union.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const result = await sdk.route({
13
+ * chainId: 1,
14
+ * fromToken: NATIVE_ETH,
15
+ * toToken: WETH,
16
+ * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped
17
+ * signer: OWNER,
18
+ * });
19
+ * ```
20
+ */
21
+ declare const exact: (amount: bigint | string) => RouteAmountExact;
22
+ /**
23
+ * Spend the signer's entire `fromToken` balance, resolved on-chain at execution
24
+ * time.
25
+ *
26
+ * Not supported when `fromToken` is the chain's native sentinel — the server
27
+ * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain
28
+ * balance to sweep; use {@link exact} for native inputs.
29
+ *
30
+ * @param simAmount - A realistic estimate of that balance, in the token's
31
+ * smallest unit. The server quotes and simulates against this value, so it
32
+ * shapes the returned quote and preconditions — but the amount actually moved
33
+ * is whatever the balance turns out to be.
34
+ * @returns The `ALL` member of the route amount union.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const result = await sdk.route({
39
+ * chainId: 1,
40
+ * fromToken: USDC,
41
+ * toToken: A_ETH_USDC,
42
+ * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand
43
+ * signer: OWNER,
44
+ * });
45
+ * ```
46
+ */
47
+ declare const all: (simAmount: bigint | string) => RouteAmountAll;
48
+
49
+ declare const routeAmountMod_all: typeof all;
50
+ declare const routeAmountMod_exact: typeof exact;
51
+ declare namespace routeAmountMod {
52
+ export { routeAmountMod_all as all, routeAmountMod_exact as exact };
53
+ }
54
+
55
+ export { all as a, exact as e, routeAmountMod as r };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all2) => {
7
+ for (var name in all2)
8
+ __defProp(target, name, { get: all2[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var routeAmount_exports = {};
20
+ __export(routeAmount_exports, {
21
+ all: () => all,
22
+ exact: () => exact
23
+ });
24
+ module.exports = __toCommonJS(routeAmount_exports);
25
+ const exact = (amount) => ({
26
+ type: "EXACT",
27
+ amount
28
+ });
29
+ const all = (simAmount) => ({
30
+ type: "ALL",
31
+ simAmount
32
+ });
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ all,
36
+ exact
37
+ });
38
+ //# sourceMappingURL=routeAmount.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/routeAmount.ts"],"sourcesContent":["import type { RouteAmountAll, RouteAmountExact } from '@lifi/compose-spec';\n\n// Constructors for the `amount` member of a `ComposeRouteRequest`. The wire\n// union is discriminated by `type` and — deliberately, because the two variants\n// mean different things — names its payload field differently in each variant:\n// `amount` is the sum actually moved, `simAmount` is only a quoting stand-in for\n// a balance resolved on-chain. These helpers keep call sites from having to\n// remember which name goes with which discriminant.\n\n/**\n * Spend an exact amount of the route's `fromToken`.\n *\n * @param amount - Amount in the token's smallest unit. `bigint` is serialised\n * to a decimal string when the request is sent.\n * @returns The `EXACT` member of the route amount union.\n *\n * @example\n * ```ts\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: NATIVE_ETH,\n * toToken: WETH,\n * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped\n * signer: OWNER,\n * });\n * ```\n */\nexport const exact = (amount: bigint | string): RouteAmountExact => ({\n type: 'EXACT',\n amount,\n});\n\n/**\n * Spend the signer's entire `fromToken` balance, resolved on-chain at execution\n * time.\n *\n * Not supported when `fromToken` is the chain's native sentinel — the server\n * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain\n * balance to sweep; use {@link exact} for native inputs.\n *\n * @param simAmount - A realistic estimate of that balance, in the token's\n * smallest unit. The server quotes and simulates against this value, so it\n * shapes the returned quote and preconditions — but the amount actually moved\n * is whatever the balance turns out to be.\n * @returns The `ALL` member of the route amount union.\n *\n * @example\n * ```ts\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: USDC,\n * toToken: A_ETH_USDC,\n * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand\n * signer: OWNER,\n * });\n * ```\n */\nexport const all = (simAmount: bigint | string): RouteAmountAll => ({\n type: 'ALL',\n simAmount,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BO,MAAM,QAAQ,CAAC,YAA+C;AAAA,EACnE,MAAM;AAAA,EACN;AACF;AA2BO,MAAM,MAAM,CAAC,eAAgD;AAAA,EAClE,MAAM;AAAA,EACN;AACF;","names":[]}
@@ -0,0 +1,2 @@
1
+ import '@lifi/compose-spec';
2
+ export { a as all, e as exact } from './routeAmount-DdbJYJyM.cjs';
@@ -0,0 +1,2 @@
1
+ import '@lifi/compose-spec';
2
+ export { a as all, e as exact } from './routeAmount-DdbJYJyM.js';
@@ -0,0 +1,13 @@
1
+ const exact = (amount) => ({
2
+ type: "EXACT",
3
+ amount
4
+ });
5
+ const all = (simAmount) => ({
6
+ type: "ALL",
7
+ simAmount
8
+ });
9
+ export {
10
+ all,
11
+ exact
12
+ };
13
+ //# sourceMappingURL=routeAmount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/routeAmount.ts"],"sourcesContent":["import type { RouteAmountAll, RouteAmountExact } from '@lifi/compose-spec';\n\n// Constructors for the `amount` member of a `ComposeRouteRequest`. The wire\n// union is discriminated by `type` and — deliberately, because the two variants\n// mean different things — names its payload field differently in each variant:\n// `amount` is the sum actually moved, `simAmount` is only a quoting stand-in for\n// a balance resolved on-chain. These helpers keep call sites from having to\n// remember which name goes with which discriminant.\n\n/**\n * Spend an exact amount of the route's `fromToken`.\n *\n * @param amount - Amount in the token's smallest unit. `bigint` is serialised\n * to a decimal string when the request is sent.\n * @returns The `EXACT` member of the route amount union.\n *\n * @example\n * ```ts\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: NATIVE_ETH,\n * toToken: WETH,\n * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped\n * signer: OWNER,\n * });\n * ```\n */\nexport const exact = (amount: bigint | string): RouteAmountExact => ({\n type: 'EXACT',\n amount,\n});\n\n/**\n * Spend the signer's entire `fromToken` balance, resolved on-chain at execution\n * time.\n *\n * Not supported when `fromToken` is the chain's native sentinel — the server\n * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain\n * balance to sweep; use {@link exact} for native inputs.\n *\n * @param simAmount - A realistic estimate of that balance, in the token's\n * smallest unit. The server quotes and simulates against this value, so it\n * shapes the returned quote and preconditions — but the amount actually moved\n * is whatever the balance turns out to be.\n * @returns The `ALL` member of the route amount union.\n *\n * @example\n * ```ts\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: USDC,\n * toToken: A_ETH_USDC,\n * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand\n * signer: OWNER,\n * });\n * ```\n */\nexport const all = (simAmount: bigint | string): RouteAmountAll => ({\n type: 'ALL',\n simAmount,\n});\n"],"mappings":"AA2BO,MAAM,QAAQ,CAAC,YAA+C;AAAA,EACnE,MAAM;AAAA,EACN;AACF;AA2BO,MAAM,MAAM,CAAC,eAAgD;AAAA,EAClE,MAAM;AAAA,EACN;AACF;","names":[]}
package/dist/sdk.cjs CHANGED
@@ -56,6 +56,7 @@ const createComposeSdk = (options) => {
56
56
  client: composeClient,
57
57
  flow,
58
58
  request,
59
+ route: composeClient.route,
59
60
  simulate: composeClient.simulate
60
61
  };
61
62
  };
package/dist/sdk.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sdk.ts"],"sourcesContent":["import type {\n ComposeCompileRequest,\n ComposeCompileResult,\n InputSpec,\n SimulateRequest,\n SimulateResult,\n} from '@lifi/compose-spec';\n\nimport {\n createFlowBuilderCore,\n type FlowBuilderCore,\n type FlowOptions,\n type TypedFlow,\n} from './authoring/FlowBuilderCore.js';\nimport { type ComposeClient, createComposeClient } from './client.js';\nimport {\n bindGeneratedOps,\n type GeneratedOps,\n} from './generated/operations.generated.js';\nimport { buildRun, type ComposeRunInput } from './run/inputs.js';\nimport type { InputSchema } from './types.js';\n\nexport type { ComposeRunInput };\n\n/**\n * A flow builder augmented with generated operation methods and a `compile` method\n * that submits the flow to the Compose backend for compilation.\n *\n * Created via {@link ComposeSdk.flow}.\n *\n * @typeParam T - The input schema describing the flow's required inputs.\n */\nexport type FlowBuilder<T extends InputSchema = InputSchema> =\n FlowBuilderCore<T> &\n GeneratedOps & {\n /**\n * Builds the flow document from the current builder state and submits it\n * to the Compose API for compilation.\n *\n * @param run - Runtime inputs, preconditions, and signer address.\n * @returns The compiled transaction calldata and metadata.\n * @throws {@link ComposeError} on network, validation, or server errors.\n *\n * @example\n * ```ts\n * const result = await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0xYourAddress...',\n * });\n * console.log(result.calldata);\n * ```\n */\n readonly compile: (\n run: ComposeRunInput<T>,\n ) => Promise<ComposeCompileResult>;\n };\n\n/**\n * Configuration for creating a Compose SDK instance.\n */\nexport interface ComposeSdkOptions {\n /** Base URL of the Compose API (e.g. `\"https://li.quest\"`). */\n readonly baseUrl: string;\n /** Optional custom `fetch` implementation. Defaults to `globalThis.fetch`. */\n readonly fetch?: typeof globalThis.fetch;\n /** LI.FI API key, sent as the `x-lifi-api-key` header on every request. Required — the Compose API rejects unauthenticated requests. */\n readonly apiKey: string;\n}\n\n/**\n * The top-level Compose SDK interface.\n *\n * Provides methods to build flows, compile them into executable calldata, and\n * interact with the Compose API directly.\n *\n * @example\n * ```ts\n * import { createComposeSdk, resources, materialisers } from '@lifi/composer-sdk';\n *\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest', apiKey: 'YOUR_API_KEY' });\n *\n * const builder = sdk.flow(1, {\n * inputs: { usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1) },\n * });\n *\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.usdc },\n * config: { resourceOut: resources.native(1) },\n * });\n *\n * const result = await builder.compile({\n * inputs: { usdc: materialisers.balanceOf({}) },\n * signer: '0xYourAddress...',\n * });\n * ```\n */\nexport interface ComposeSdk {\n /** Low-level HTTP client for the Compose API. */\n readonly client: ComposeClient;\n /**\n * Creates a new flow builder targeting the given chain.\n * @param chainId - The EVM chain ID (e.g. `1` for Ethereum mainnet).\n * @param options - Flow configuration including input declarations.\n * @returns A {@link FlowBuilder} with generated operation methods and a `compile` method.\n * @throws Error if any resource input's `chainId` doesn't match the flow's `chainId`.\n */\n readonly flow: <T extends InputSchema>(\n chainId: number,\n options: FlowOptions<T>,\n ) => FlowBuilder<T>;\n /**\n * Builds a raw compile request without sending it. Useful for inspecting the\n * request payload or submitting it through a custom transport.\n * @param flow - A built flow document (from `builder.build()`).\n * @param run - Runtime inputs, preconditions, and signer address.\n * @returns A {@link ComposeCompileRequest} ready to send to the Compose API.\n */\n readonly request: <T extends InputSchema>(\n flow: TypedFlow<T>,\n run: ComposeRunInput<T>,\n ) => ComposeCompileRequest;\n /**\n * Simulates a raw, pre-encoded transaction. Thin pass-through to\n * {@link ComposeClient.simulate}; see it for the `ok` / `revert` / `error`\n * result discrimination and error behaviour. Pair with `buildSimulateRequest`\n * to assemble the request from a compile result.\n *\n * @param request - The raw transaction plus funding `requirements` and\n * `trackedBalances`.\n * @returns A {@link SimulateResult} (`ok` / `revert` / `error`).\n * @throws {@link ComposeError} on network, validation, or server errors.\n */\n readonly simulate: (request: SimulateRequest) => Promise<SimulateResult>;\n}\n\n/**\n * Creates a new Compose SDK instance.\n *\n * @param options - SDK configuration including the API base URL, required API key, and optional fetch implementation.\n * @returns A {@link ComposeSdk} instance.\n *\n * @example\n * ```ts\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest', apiKey: 'YOUR_API_KEY' });\n * ```\n */\nexport const createComposeSdk = (options: ComposeSdkOptions): ComposeSdk => {\n const composeClient = createComposeClient(options);\n\n const request = <T extends InputSchema>(\n flowDoc: TypedFlow<T>,\n run: ComposeRunInput<T>,\n ): ComposeCompileRequest => ({\n flow: flowDoc,\n run: buildRun({\n inputs: run.inputs as Record<string, InputSpec>,\n preconditions: run.preconditions,\n signer: run.signer,\n assumptions: run.assumptions as Record<string, bigint> | undefined,\n referrer: run.referrer,\n integratorFeeBps: run.integratorFeeBps,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n });\n\n const flow = <T extends InputSchema>(\n chainId: number,\n opts: FlowOptions<T>,\n ): FlowBuilder<T> => {\n const core = createFlowBuilderCore(chainId, opts);\n const builder = Object.assign(core, bindGeneratedOps(core));\n\n const compile = async (\n run: ComposeRunInput<T>,\n ): Promise<ComposeCompileResult> => {\n const flowDoc = builder.build();\n const req = request(flowDoc, run);\n return composeClient.compile(req);\n };\n\n return Object.assign(builder, { compile });\n };\n\n return {\n client: composeClient,\n flow,\n request,\n simulate: composeClient.simulate,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,6BAKO;AACP,oBAAwD;AACxD,kCAGO;AACP,oBAA+C;AA+HxC,MAAM,mBAAmB,CAAC,YAA2C;AAC1E,QAAM,oBAAgB,mCAAoB,OAAO;AAEjD,QAAM,UAAU,CACd,SACA,SAC2B;AAAA,IAC3B,MAAM;AAAA,IACN,SAAK,wBAAS;AAAA,MACZ,QAAQ,IAAI;AAAA,MACZ,eAAe,IAAI;AAAA,MACnB,QAAQ,IAAI;AAAA,MACZ,aAAa,IAAI;AAAA,MACjB,UAAU,IAAI;AAAA,MACd,kBAAkB,IAAI;AAAA,MACtB,mBAAmB,IAAI;AAAA,MACvB,SAAS,IAAI;AAAA,MACb,kBAAkB,IAAI;AAAA,MACtB,wBAAwB,IAAI;AAAA,IAC9B,CAAC;AAAA,EACH;AAEA,QAAM,OAAO,CACX,SACA,SACmB;AACnB,UAAM,WAAO,8CAAsB,SAAS,IAAI;AAChD,UAAM,UAAU,OAAO,OAAO,UAAM,8CAAiB,IAAI,CAAC;AAE1D,UAAM,UAAU,OACd,QACkC;AAClC,YAAM,UAAU,QAAQ,MAAM;AAC9B,YAAM,MAAM,QAAQ,SAAS,GAAG;AAChC,aAAO,cAAc,QAAQ,GAAG;AAAA,IAClC;AAEA,WAAO,OAAO,OAAO,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC3C;AAEA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA,UAAU,cAAc;AAAA,EAC1B;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/sdk.ts"],"sourcesContent":["import type {\n ComposeCompileRequest,\n ComposeCompileResult,\n ComposeRouteRequest,\n InputSpec,\n SimulateRequest,\n SimulateResult,\n} from '@lifi/compose-spec';\n\nimport {\n createFlowBuilderCore,\n type FlowBuilderCore,\n type FlowOptions,\n type TypedFlow,\n} from './authoring/FlowBuilderCore.js';\nimport { type ComposeClient, createComposeClient } from './client.js';\nimport {\n bindGeneratedOps,\n type GeneratedOps,\n} from './generated/operations.generated.js';\nimport { buildRun, type ComposeRunInput } from './run/inputs.js';\nimport type { InputSchema } from './types.js';\n\nexport type { ComposeRunInput };\n\n/**\n * A flow builder augmented with generated operation methods and a `compile` method\n * that submits the flow to the Compose backend for compilation.\n *\n * Created via {@link ComposeSdk.flow}.\n *\n * @typeParam T - The input schema describing the flow's required inputs.\n */\nexport type FlowBuilder<T extends InputSchema = InputSchema> =\n FlowBuilderCore<T> &\n GeneratedOps & {\n /**\n * Builds the flow document from the current builder state and submits it\n * to the Compose API for compilation.\n *\n * @param run - Runtime inputs, preconditions, and signer address.\n * @returns The compiled transaction calldata and metadata.\n * @throws {@link ComposeError} on network, validation, or server errors.\n *\n * @example\n * ```ts\n * const result = await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0xYourAddress...',\n * });\n * console.log(result.calldata);\n * ```\n */\n readonly compile: (\n run: ComposeRunInput<T>,\n ) => Promise<ComposeCompileResult>;\n };\n\n/**\n * Configuration for creating a Compose SDK instance.\n */\nexport interface ComposeSdkOptions {\n /** Base URL of the Compose API (e.g. `\"https://li.quest\"`). */\n readonly baseUrl: string;\n /** Optional custom `fetch` implementation. Defaults to `globalThis.fetch`. */\n readonly fetch?: typeof globalThis.fetch;\n /** LI.FI API key, sent as the `x-lifi-api-key` header on every request. Required — the Compose API rejects unauthenticated requests. */\n readonly apiKey: string;\n}\n\n/**\n * The top-level Compose SDK interface.\n *\n * Provides methods to build flows, compile them into executable calldata, and\n * interact with the Compose API directly.\n *\n * @example\n * ```ts\n * import { createComposeSdk, resources, materialisers } from '@lifi/composer-sdk';\n *\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest', apiKey: 'YOUR_API_KEY' });\n *\n * const builder = sdk.flow(1, {\n * inputs: { usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1) },\n * });\n *\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.usdc },\n * config: { resourceOut: resources.native(1) },\n * });\n *\n * const result = await builder.compile({\n * inputs: { usdc: materialisers.balanceOf({}) },\n * signer: '0xYourAddress...',\n * });\n * ```\n */\nexport interface ComposeSdk {\n /** Low-level HTTP client for the Compose API. */\n readonly client: ComposeClient;\n /**\n * Creates a new flow builder targeting the given chain.\n * @param chainId - The EVM chain ID (e.g. `1` for Ethereum mainnet).\n * @param options - Flow configuration including input declarations.\n * @returns A {@link FlowBuilder} with generated operation methods and a `compile` method.\n * @throws Error if any resource input's `chainId` doesn't match the flow's `chainId`.\n */\n readonly flow: <T extends InputSchema>(\n chainId: number,\n options: FlowOptions<T>,\n ) => FlowBuilder<T>;\n /**\n * Builds a raw compile request without sending it. Useful for inspecting the\n * request payload or submitting it through a custom transport.\n * @param flow - A built flow document (from `builder.build()`).\n * @param run - Runtime inputs, preconditions, and signer address.\n * @returns A {@link ComposeCompileRequest} ready to send to the Compose API.\n */\n readonly request: <T extends InputSchema>(\n flow: TypedFlow<T>,\n run: ComposeRunInput<T>,\n ) => ComposeCompileRequest;\n /**\n * Compiles a token pair on one chain — as of today a single zap step over\n * one routing-catalog edge. Thin pass-through to\n * {@link ComposeClient.route}; see it for the current single-step limit,\n * when to prefer `flow(...).compile(...)`, the `success` / `partial`\n * discrimination, and error behaviour. Build the `amount` with\n * `routeAmount.exact(...)` / `routeAmount.all(...)`.\n *\n * @param request - The from/to token pair, amount, signer, and route options.\n * @returns A discriminated result: `status: 'success'` or `status: 'partial'`.\n * @throws {@link ComposeError} on network, validation, or server errors.\n */\n readonly route: (\n request: ComposeRouteRequest,\n ) => Promise<ComposeCompileResult>;\n /**\n * Simulates a raw, pre-encoded transaction. Thin pass-through to\n * {@link ComposeClient.simulate}; see it for the `ok` / `revert` / `error`\n * result discrimination and error behaviour. Pair with `buildSimulateRequest`\n * to assemble the request from a compile result.\n *\n * @param request - The raw transaction plus funding `requirements` and\n * `trackedBalances`.\n * @returns A {@link SimulateResult} (`ok` / `revert` / `error`).\n * @throws {@link ComposeError} on network, validation, or server errors.\n */\n readonly simulate: (request: SimulateRequest) => Promise<SimulateResult>;\n}\n\n/**\n * Creates a new Compose SDK instance.\n *\n * @param options - SDK configuration including the API base URL, required API key, and optional fetch implementation.\n * @returns A {@link ComposeSdk} instance.\n *\n * @example\n * ```ts\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest', apiKey: 'YOUR_API_KEY' });\n * ```\n */\nexport const createComposeSdk = (options: ComposeSdkOptions): ComposeSdk => {\n const composeClient = createComposeClient(options);\n\n const request = <T extends InputSchema>(\n flowDoc: TypedFlow<T>,\n run: ComposeRunInput<T>,\n ): ComposeCompileRequest => ({\n flow: flowDoc,\n run: buildRun({\n inputs: run.inputs as Record<string, InputSpec>,\n preconditions: run.preconditions,\n signer: run.signer,\n assumptions: run.assumptions as Record<string, bigint> | undefined,\n referrer: run.referrer,\n integratorFeeBps: run.integratorFeeBps,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n });\n\n const flow = <T extends InputSchema>(\n chainId: number,\n opts: FlowOptions<T>,\n ): FlowBuilder<T> => {\n const core = createFlowBuilderCore(chainId, opts);\n const builder = Object.assign(core, bindGeneratedOps(core));\n\n const compile = async (\n run: ComposeRunInput<T>,\n ): Promise<ComposeCompileResult> => {\n const flowDoc = builder.build();\n const req = request(flowDoc, run);\n return composeClient.compile(req);\n };\n\n return Object.assign(builder, { compile });\n };\n\n return {\n client: composeClient,\n flow,\n request,\n route: composeClient.route,\n simulate: composeClient.simulate,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,6BAKO;AACP,oBAAwD;AACxD,kCAGO;AACP,oBAA+C;AA8IxC,MAAM,mBAAmB,CAAC,YAA2C;AAC1E,QAAM,oBAAgB,mCAAoB,OAAO;AAEjD,QAAM,UAAU,CACd,SACA,SAC2B;AAAA,IAC3B,MAAM;AAAA,IACN,SAAK,wBAAS;AAAA,MACZ,QAAQ,IAAI;AAAA,MACZ,eAAe,IAAI;AAAA,MACnB,QAAQ,IAAI;AAAA,MACZ,aAAa,IAAI;AAAA,MACjB,UAAU,IAAI;AAAA,MACd,kBAAkB,IAAI;AAAA,MACtB,mBAAmB,IAAI;AAAA,MACvB,SAAS,IAAI;AAAA,MACb,kBAAkB,IAAI;AAAA,MACtB,wBAAwB,IAAI;AAAA,IAC9B,CAAC;AAAA,EACH;AAEA,QAAM,OAAO,CACX,SACA,SACmB;AACnB,UAAM,WAAO,8CAAsB,SAAS,IAAI;AAChD,UAAM,UAAU,OAAO,OAAO,UAAM,8CAAiB,IAAI,CAAC;AAE1D,UAAM,UAAU,OACd,QACkC;AAClC,YAAM,UAAU,QAAQ,MAAM;AAC9B,YAAM,MAAM,QAAQ,SAAS,GAAG;AAChC,aAAO,cAAc,QAAQ,GAAG;AAAA,IAClC;AAEA,WAAO,OAAO,OAAO,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC3C;AAEA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA,OAAO,cAAc;AAAA,IACrB,UAAU,cAAc;AAAA,EAC1B;AACF;","names":[]}
package/dist/sdk.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ComposeCompileResult, ComposeCompileRequest, SimulateRequest, SimulateResult } from '@lifi/compose-spec';
1
+ import { ComposeCompileResult, ComposeCompileRequest, ComposeRouteRequest, SimulateRequest, SimulateResult } from '@lifi/compose-spec';
2
2
  import { FlowOptions, FlowBuilderCore, TypedFlow } from './authoring/FlowBuilderCore.cjs';
3
3
  import { ComposeClient } from './client.cjs';
4
4
  import { GeneratedOps } from './generated/operations.generated.cjs';
@@ -95,6 +95,19 @@ interface ComposeSdk {
95
95
  * @returns A {@link ComposeCompileRequest} ready to send to the Compose API.
96
96
  */
97
97
  readonly request: <T extends InputSchema>(flow: TypedFlow<T>, run: ComposeRunInput<T>) => ComposeCompileRequest;
98
+ /**
99
+ * Compiles a token pair on one chain — as of today a single zap step over
100
+ * one routing-catalog edge. Thin pass-through to
101
+ * {@link ComposeClient.route}; see it for the current single-step limit,
102
+ * when to prefer `flow(...).compile(...)`, the `success` / `partial`
103
+ * discrimination, and error behaviour. Build the `amount` with
104
+ * `routeAmount.exact(...)` / `routeAmount.all(...)`.
105
+ *
106
+ * @param request - The from/to token pair, amount, signer, and route options.
107
+ * @returns A discriminated result: `status: 'success'` or `status: 'partial'`.
108
+ * @throws {@link ComposeError} on network, validation, or server errors.
109
+ */
110
+ readonly route: (request: ComposeRouteRequest) => Promise<ComposeCompileResult>;
98
111
  /**
99
112
  * Simulates a raw, pre-encoded transaction. Thin pass-through to
100
113
  * {@link ComposeClient.simulate}; see it for the `ok` / `revert` / `error`
package/dist/sdk.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ComposeCompileResult, ComposeCompileRequest, SimulateRequest, SimulateResult } from '@lifi/compose-spec';
1
+ import { ComposeCompileResult, ComposeCompileRequest, ComposeRouteRequest, SimulateRequest, SimulateResult } from '@lifi/compose-spec';
2
2
  import { FlowOptions, FlowBuilderCore, TypedFlow } from './authoring/FlowBuilderCore.js';
3
3
  import { ComposeClient } from './client.js';
4
4
  import { GeneratedOps } from './generated/operations.generated.js';
@@ -95,6 +95,19 @@ interface ComposeSdk {
95
95
  * @returns A {@link ComposeCompileRequest} ready to send to the Compose API.
96
96
  */
97
97
  readonly request: <T extends InputSchema>(flow: TypedFlow<T>, run: ComposeRunInput<T>) => ComposeCompileRequest;
98
+ /**
99
+ * Compiles a token pair on one chain — as of today a single zap step over
100
+ * one routing-catalog edge. Thin pass-through to
101
+ * {@link ComposeClient.route}; see it for the current single-step limit,
102
+ * when to prefer `flow(...).compile(...)`, the `success` / `partial`
103
+ * discrimination, and error behaviour. Build the `amount` with
104
+ * `routeAmount.exact(...)` / `routeAmount.all(...)`.
105
+ *
106
+ * @param request - The from/to token pair, amount, signer, and route options.
107
+ * @returns A discriminated result: `status: 'success'` or `status: 'partial'`.
108
+ * @throws {@link ComposeError} on network, validation, or server errors.
109
+ */
110
+ readonly route: (request: ComposeRouteRequest) => Promise<ComposeCompileResult>;
98
111
  /**
99
112
  * Simulates a raw, pre-encoded transaction. Thin pass-through to
100
113
  * {@link ComposeClient.simulate}; see it for the `ok` / `revert` / `error`
package/dist/sdk.js CHANGED
@@ -37,6 +37,7 @@ const createComposeSdk = (options) => {
37
37
  client: composeClient,
38
38
  flow,
39
39
  request,
40
+ route: composeClient.route,
40
41
  simulate: composeClient.simulate
41
42
  };
42
43
  };