@lifi/composer-sdk 0.11.3 → 0.12.0

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 (46) hide show
  1. package/README.md +0 -2
  2. package/dist/authoring/raw.cjs +10 -2
  3. package/dist/authoring/raw.cjs.map +1 -1
  4. package/dist/authoring/raw.d.cts +10 -2
  5. package/dist/authoring/raw.d.ts +10 -2
  6. package/dist/authoring/raw.js +10 -2
  7. package/dist/authoring/raw.js.map +1 -1
  8. package/dist/authoring/signatureArgs.cjs +10 -3
  9. package/dist/authoring/signatureArgs.cjs.map +1 -1
  10. package/dist/authoring/signatureArgs.d.cts +23 -16
  11. package/dist/authoring/signatureArgs.d.ts +23 -16
  12. package/dist/authoring/signatureArgs.js +10 -3
  13. package/dist/authoring/signatureArgs.js.map +1 -1
  14. package/dist/client.cjs +1 -1
  15. package/dist/client.js +1 -1
  16. package/dist/generated/config.generated.d.cts +3 -2
  17. package/dist/generated/config.generated.d.ts +3 -2
  18. package/dist/generated/operations.generated.cjs.map +1 -1
  19. package/dist/generated/operations.generated.d.cts +1 -1
  20. package/dist/generated/operations.generated.d.ts +1 -1
  21. package/dist/generated/operations.generated.js.map +1 -1
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +2 -2
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/run/inputs.cjs +0 -1
  27. package/dist/run/inputs.cjs.map +1 -1
  28. package/dist/run/inputs.d.cts +0 -8
  29. package/dist/run/inputs.d.ts +0 -8
  30. package/dist/run/inputs.js +0 -1
  31. package/dist/run/inputs.js.map +1 -1
  32. package/dist/sdk.cjs +0 -1
  33. package/dist/sdk.cjs.map +1 -1
  34. package/dist/sdk.js +0 -1
  35. package/dist/sdk.js.map +1 -1
  36. package/package.json +2 -2
  37. package/src/authoring/raw.ts +10 -2
  38. package/src/authoring/signatureArgs.ts +53 -23
  39. package/src/examples/continuationBridgeSettle.ts +1 -2
  40. package/src/examples/continuationSettle.ts +1 -1
  41. package/src/generated/config.generated.ts +3 -2
  42. package/src/generated/operations.generated.ts +1 -1
  43. package/src/index.ts +1 -1
  44. package/src/run/inputs.ts +0 -9
  45. package/src/sdk.ts +0 -1
  46. package/src/examples/swapWithFee.ts +0 -59
@@ -1 +1 @@
1
- {"version":3,"file":"inputs.cjs","names":[],"sources":["../../src/run/inputs.ts"],"sourcesContent":["import type {\n ComposeRun,\n ForwardTo,\n InputSpec,\n MaterialiserInput,\n Precondition,\n SimulationPolicy,\n} from '@lifi/compose-spec';\n\nimport type { Address, InputSchema, InputSpecOf } from '../types.js';\n\n/**\n * Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.\n *\n * @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.\n */\nexport interface ComposeRunInput<T extends InputSchema = InputSchema> {\n /**\n * Concrete values for each declared flow input. Resource inputs accept a\n * materialiser or a literal integer amount; scalar inputs accept the matching type.\n */\n readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]> };\n /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */\n readonly preconditions?: readonly Precondition[];\n /** The `0x`-prefixed address of the transaction signer. */\n readonly signer: Address;\n /**\n * Optional assumed token amounts for resource inputs, keyed by input name.\n * When a materialiser resolves amounts at execution time rather than upfront,\n * assumptions let the compiler plan routes using estimated values. The keys\n * must match the input names declared in the flow schema.\n */\n readonly assumptions?: { readonly [K in keyof T]?: bigint };\n /** Optional integrator referrer identifier. */\n readonly referrer?: string;\n /**\n * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).\n * A non-zero value requires the request to be authenticated with an\n * integration-scoped API key — the integration is derived from the key, not\n * this field. Defaults to `0` (no fee) when omitted.\n */\n readonly integratorFeeBps?: number;\n /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */\n readonly maxPriceImpactBps?: number;\n /**\n * Destination for sweeping all proxy-held terminal resources after execution.\n * Pass a literal `0x`-prefixed address or `{ $ref: \"context.sender\" }` to\n * send remaining tokens to the signer.\n */\n readonly sweepTo?: ForwardTo;\n /**\n * Controls behavior when simulation detects a revert.\n * `'strict'` (default) returns an error; `'allow-revert'` returns a partial\n * result with the transaction and revert diagnostics.\n */\n readonly simulationPolicy?: SimulationPolicy;\n /**\n * When `true`, the server also simulates the final user-facing transaction\n * after the structured simulation succeeds; reverts honour\n * `simulationPolicy`. On success the result is echoed back on the response as\n * `userProgramSimulation`. Defaults to `false`.\n */\n readonly simulateUserProgram?: boolean;\n /**\n * When `true`, the server checks on-chain ERC-20 allowances and omits\n * approvals that are already sufficient. Defaults to `false`.\n */\n readonly checkOnChainAllowances?: boolean;\n}\n\n/**\n * Creates an untyped materialiser input spec. This is a low-level escape hatch\n * for materialiser kinds not yet covered by the generated helpers.\n *\n * Prefer the typed helpers in the `materialisers` namespace (e.g.\n * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide\n * compile-time config validation.\n *\n * @param kind - The materialiser type (e.g. `\"balanceOf\"`, `\"directDeposit\"`).\n * @param config - Optional materialiser-specific configuration.\n * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.\n *\n * @example\n * ```ts\n * const run = {\n * inputs: { token: materialiser('customKind', { myParam: '0x...' }) },\n * signer: '0x...',\n * };\n * ```\n */\nexport const materialiser = (\n kind: string,\n config: Record<string, unknown> = {},\n): MaterialiserInput => ({\n kind,\n ...config,\n});\n\n/**\n * Drops the keys whose value is `undefined`, so optional fields are omitted\n * from the wire payload rather than serialized as `null`.\n *\n * A local copy of `pickDefined` from `@lifi/utils`: this package is published\n * to npm and `@lifi/utils` is a private workspace package, so it cannot be a\n * runtime dependency here.\n */\nconst pickDefined = <S extends Record<string, unknown>>(\n obj: S,\n): Partial<{ [K in keyof S]: Exclude<S[K], undefined> }> =>\n Object.fromEntries(\n Object.entries(obj).filter(([, value]) => value !== undefined),\n ) as Partial<{ [K in keyof S]: Exclude<S[K], undefined> }>;\n\n/**\n * Assembles a {@link ComposeRun} object from individual parameters.\n * Used internally by the SDK; prefer {@link ComposeRunInput} for external use.\n *\n * @internal\n */\nexport const buildRun = (run: {\n inputs: Record<string, InputSpec>;\n preconditions?: readonly Precondition[];\n signer: string;\n assumptions?: Record<string, bigint>;\n referrer?: string;\n integratorFeeBps?: number;\n maxPriceImpactBps?: number;\n sweepTo?: ForwardTo;\n simulationPolicy?: SimulationPolicy;\n simulateUserProgram?: boolean;\n checkOnChainAllowances?: boolean;\n}): ComposeRun => ({\n inputs: run.inputs,\n signer: run.signer,\n ...pickDefined({\n // An empty precondition list is the same as none, so drop it too.\n preconditions: run.preconditions?.length ? run.preconditions : undefined,\n assumptions: run.assumptions,\n referrer: run.referrer,\n integratorFeeBps: run.integratorFeeBps,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n simulateUserProgram: run.simulateUserProgram,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0FA,MAAa,gBACX,MACA,SAAkC,CAAC,OACZ;CACvB;CACA,GAAG;AACL;;;;;;;;;AAUA,MAAM,eACJ,QAEA,OAAO,YACL,OAAO,QAAQ,GAAG,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CAC/D;;;;;;;AAQF,MAAa,YAAY,SAYN;CACjB,QAAQ,IAAI;CACZ,QAAQ,IAAI;CACZ,GAAG,YAAY;EAEb,eAAe,IAAI,eAAe,SAAS,IAAI,gBAAgB,KAAA;EAC/D,aAAa,IAAI;EACjB,UAAU,IAAI;EACd,kBAAkB,IAAI;EACtB,mBAAmB,IAAI;EACvB,SAAS,IAAI;EACb,kBAAkB,IAAI;EACtB,qBAAqB,IAAI;EACzB,wBAAwB,IAAI;CAC9B,CAAC;AACH"}
1
+ {"version":3,"file":"inputs.cjs","names":[],"sources":["../../src/run/inputs.ts"],"sourcesContent":["import type {\n ComposeRun,\n ForwardTo,\n InputSpec,\n MaterialiserInput,\n Precondition,\n SimulationPolicy,\n} from '@lifi/compose-spec';\n\nimport type { Address, InputSchema, InputSpecOf } from '../types.js';\n\n/**\n * Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.\n *\n * @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.\n */\nexport interface ComposeRunInput<T extends InputSchema = InputSchema> {\n /**\n * Concrete values for each declared flow input. Resource inputs accept a\n * materialiser or a literal integer amount; scalar inputs accept the matching type.\n */\n readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]> };\n /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */\n readonly preconditions?: readonly Precondition[];\n /** The `0x`-prefixed address of the transaction signer. */\n readonly signer: Address;\n /**\n * Optional assumed token amounts for resource inputs, keyed by input name.\n * When a materialiser resolves amounts at execution time rather than upfront,\n * assumptions let the compiler plan routes using estimated values. The keys\n * must match the input names declared in the flow schema.\n */\n readonly assumptions?: { readonly [K in keyof T]?: bigint };\n /** Optional integrator referrer identifier. */\n readonly referrer?: string;\n /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */\n readonly maxPriceImpactBps?: number;\n /**\n * Destination for sweeping all proxy-held terminal resources after execution.\n * Pass a literal `0x`-prefixed address or `{ $ref: \"context.sender\" }` to\n * send remaining tokens to the signer.\n */\n readonly sweepTo?: ForwardTo;\n /**\n * Controls behavior when simulation detects a revert.\n * `'strict'` (default) returns an error; `'allow-revert'` returns a partial\n * result with the transaction and revert diagnostics.\n */\n readonly simulationPolicy?: SimulationPolicy;\n /**\n * When `true`, the server also simulates the final user-facing transaction\n * after the structured simulation succeeds; reverts honour\n * `simulationPolicy`. On success the result is echoed back on the response as\n * `userProgramSimulation`. Defaults to `false`.\n */\n readonly simulateUserProgram?: boolean;\n /**\n * When `true`, the server checks on-chain ERC-20 allowances and omits\n * approvals that are already sufficient. Defaults to `false`.\n */\n readonly checkOnChainAllowances?: boolean;\n}\n\n/**\n * Creates an untyped materialiser input spec. This is a low-level escape hatch\n * for materialiser kinds not yet covered by the generated helpers.\n *\n * Prefer the typed helpers in the `materialisers` namespace (e.g.\n * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide\n * compile-time config validation.\n *\n * @param kind - The materialiser type (e.g. `\"balanceOf\"`, `\"directDeposit\"`).\n * @param config - Optional materialiser-specific configuration.\n * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.\n *\n * @example\n * ```ts\n * const run = {\n * inputs: { token: materialiser('customKind', { myParam: '0x...' }) },\n * signer: '0x...',\n * };\n * ```\n */\nexport const materialiser = (\n kind: string,\n config: Record<string, unknown> = {},\n): MaterialiserInput => ({\n kind,\n ...config,\n});\n\n/**\n * Drops the keys whose value is `undefined`, so optional fields are omitted\n * from the wire payload rather than serialized as `null`.\n *\n * A local copy of `pickDefined` from `@lifi/utils`: this package is published\n * to npm and `@lifi/utils` is a private workspace package, so it cannot be a\n * runtime dependency here.\n */\nconst pickDefined = <S extends Record<string, unknown>>(\n obj: S,\n): Partial<{ [K in keyof S]: Exclude<S[K], undefined> }> =>\n Object.fromEntries(\n Object.entries(obj).filter(([, value]) => value !== undefined),\n ) as Partial<{ [K in keyof S]: Exclude<S[K], undefined> }>;\n\n/**\n * Assembles a {@link ComposeRun} object from individual parameters.\n * Used internally by the SDK; prefer {@link ComposeRunInput} for external use.\n *\n * @internal\n */\nexport const buildRun = (run: {\n inputs: Record<string, InputSpec>;\n preconditions?: readonly Precondition[];\n signer: string;\n assumptions?: Record<string, bigint>;\n referrer?: string;\n maxPriceImpactBps?: number;\n sweepTo?: ForwardTo;\n simulationPolicy?: SimulationPolicy;\n simulateUserProgram?: boolean;\n checkOnChainAllowances?: boolean;\n}): ComposeRun => ({\n inputs: run.inputs,\n signer: run.signer,\n ...pickDefined({\n // An empty precondition list is the same as none, so drop it too.\n preconditions: run.preconditions?.length ? run.preconditions : undefined,\n assumptions: run.assumptions,\n referrer: run.referrer,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n simulateUserProgram: run.simulateUserProgram,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmFA,MAAa,gBACX,MACA,SAAkC,CAAC,OACZ;CACvB;CACA,GAAG;AACL;;;;;;;;;AAUA,MAAM,eACJ,QAEA,OAAO,YACL,OAAO,QAAQ,GAAG,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CAC/D;;;;;;;AAQF,MAAa,YAAY,SAWN;CACjB,QAAQ,IAAI;CACZ,QAAQ,IAAI;CACZ,GAAG,YAAY;EAEb,eAAe,IAAI,eAAe,SAAS,IAAI,gBAAgB,KAAA;EAC/D,aAAa,IAAI;EACjB,UAAU,IAAI;EACd,mBAAmB,IAAI;EACvB,SAAS,IAAI;EACb,kBAAkB,IAAI;EACtB,qBAAqB,IAAI;EACzB,wBAAwB,IAAI;CAC9B,CAAC;AACH"}
@@ -25,13 +25,6 @@ export interface ComposeRunInput<T extends InputSchema = InputSchema> {
25
25
  readonly assumptions?: { readonly [K in keyof T]?: bigint; };
26
26
  /** Optional integrator referrer identifier. */
27
27
  readonly referrer?: string;
28
- /**
29
- * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).
30
- * A non-zero value requires the request to be authenticated with an
31
- * integration-scoped API key — the integration is derived from the key, not
32
- * this field. Defaults to `0` (no fee) when omitted.
33
- */
34
- readonly integratorFeeBps?: number;
35
28
  /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */
36
29
  readonly maxPriceImpactBps?: number;
37
30
  /**
@@ -92,7 +85,6 @@ export declare const buildRun: (run: {
92
85
  signer: string;
93
86
  assumptions?: Record<string, bigint>;
94
87
  referrer?: string;
95
- integratorFeeBps?: number;
96
88
  maxPriceImpactBps?: number;
97
89
  sweepTo?: ForwardTo;
98
90
  simulationPolicy?: SimulationPolicy;
@@ -25,13 +25,6 @@ export interface ComposeRunInput<T extends InputSchema = InputSchema> {
25
25
  readonly assumptions?: { readonly [K in keyof T]?: bigint; };
26
26
  /** Optional integrator referrer identifier. */
27
27
  readonly referrer?: string;
28
- /**
29
- * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).
30
- * A non-zero value requires the request to be authenticated with an
31
- * integration-scoped API key — the integration is derived from the key, not
32
- * this field. Defaults to `0` (no fee) when omitted.
33
- */
34
- readonly integratorFeeBps?: number;
35
28
  /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */
36
29
  readonly maxPriceImpactBps?: number;
37
30
  /**
@@ -92,7 +85,6 @@ export declare const buildRun: (run: {
92
85
  signer: string;
93
86
  assumptions?: Record<string, bigint>;
94
87
  referrer?: string;
95
- integratorFeeBps?: number;
96
88
  maxPriceImpactBps?: number;
97
89
  sweepTo?: ForwardTo;
98
90
  simulationPolicy?: SimulationPolicy;
@@ -45,7 +45,6 @@ const buildRun = (run) => ({
45
45
  preconditions: run.preconditions?.length ? run.preconditions : void 0,
46
46
  assumptions: run.assumptions,
47
47
  referrer: run.referrer,
48
- integratorFeeBps: run.integratorFeeBps,
49
48
  maxPriceImpactBps: run.maxPriceImpactBps,
50
49
  sweepTo: run.sweepTo,
51
50
  simulationPolicy: run.simulationPolicy,
@@ -1 +1 @@
1
- {"version":3,"file":"inputs.js","names":[],"sources":["../../src/run/inputs.ts"],"sourcesContent":["import type {\n ComposeRun,\n ForwardTo,\n InputSpec,\n MaterialiserInput,\n Precondition,\n SimulationPolicy,\n} from '@lifi/compose-spec';\n\nimport type { Address, InputSchema, InputSpecOf } from '../types.js';\n\n/**\n * Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.\n *\n * @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.\n */\nexport interface ComposeRunInput<T extends InputSchema = InputSchema> {\n /**\n * Concrete values for each declared flow input. Resource inputs accept a\n * materialiser or a literal integer amount; scalar inputs accept the matching type.\n */\n readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]> };\n /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */\n readonly preconditions?: readonly Precondition[];\n /** The `0x`-prefixed address of the transaction signer. */\n readonly signer: Address;\n /**\n * Optional assumed token amounts for resource inputs, keyed by input name.\n * When a materialiser resolves amounts at execution time rather than upfront,\n * assumptions let the compiler plan routes using estimated values. The keys\n * must match the input names declared in the flow schema.\n */\n readonly assumptions?: { readonly [K in keyof T]?: bigint };\n /** Optional integrator referrer identifier. */\n readonly referrer?: string;\n /**\n * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).\n * A non-zero value requires the request to be authenticated with an\n * integration-scoped API key — the integration is derived from the key, not\n * this field. Defaults to `0` (no fee) when omitted.\n */\n readonly integratorFeeBps?: number;\n /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */\n readonly maxPriceImpactBps?: number;\n /**\n * Destination for sweeping all proxy-held terminal resources after execution.\n * Pass a literal `0x`-prefixed address or `{ $ref: \"context.sender\" }` to\n * send remaining tokens to the signer.\n */\n readonly sweepTo?: ForwardTo;\n /**\n * Controls behavior when simulation detects a revert.\n * `'strict'` (default) returns an error; `'allow-revert'` returns a partial\n * result with the transaction and revert diagnostics.\n */\n readonly simulationPolicy?: SimulationPolicy;\n /**\n * When `true`, the server also simulates the final user-facing transaction\n * after the structured simulation succeeds; reverts honour\n * `simulationPolicy`. On success the result is echoed back on the response as\n * `userProgramSimulation`. Defaults to `false`.\n */\n readonly simulateUserProgram?: boolean;\n /**\n * When `true`, the server checks on-chain ERC-20 allowances and omits\n * approvals that are already sufficient. Defaults to `false`.\n */\n readonly checkOnChainAllowances?: boolean;\n}\n\n/**\n * Creates an untyped materialiser input spec. This is a low-level escape hatch\n * for materialiser kinds not yet covered by the generated helpers.\n *\n * Prefer the typed helpers in the `materialisers` namespace (e.g.\n * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide\n * compile-time config validation.\n *\n * @param kind - The materialiser type (e.g. `\"balanceOf\"`, `\"directDeposit\"`).\n * @param config - Optional materialiser-specific configuration.\n * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.\n *\n * @example\n * ```ts\n * const run = {\n * inputs: { token: materialiser('customKind', { myParam: '0x...' }) },\n * signer: '0x...',\n * };\n * ```\n */\nexport const materialiser = (\n kind: string,\n config: Record<string, unknown> = {},\n): MaterialiserInput => ({\n kind,\n ...config,\n});\n\n/**\n * Drops the keys whose value is `undefined`, so optional fields are omitted\n * from the wire payload rather than serialized as `null`.\n *\n * A local copy of `pickDefined` from `@lifi/utils`: this package is published\n * to npm and `@lifi/utils` is a private workspace package, so it cannot be a\n * runtime dependency here.\n */\nconst pickDefined = <S extends Record<string, unknown>>(\n obj: S,\n): Partial<{ [K in keyof S]: Exclude<S[K], undefined> }> =>\n Object.fromEntries(\n Object.entries(obj).filter(([, value]) => value !== undefined),\n ) as Partial<{ [K in keyof S]: Exclude<S[K], undefined> }>;\n\n/**\n * Assembles a {@link ComposeRun} object from individual parameters.\n * Used internally by the SDK; prefer {@link ComposeRunInput} for external use.\n *\n * @internal\n */\nexport const buildRun = (run: {\n inputs: Record<string, InputSpec>;\n preconditions?: readonly Precondition[];\n signer: string;\n assumptions?: Record<string, bigint>;\n referrer?: string;\n integratorFeeBps?: number;\n maxPriceImpactBps?: number;\n sweepTo?: ForwardTo;\n simulationPolicy?: SimulationPolicy;\n simulateUserProgram?: boolean;\n checkOnChainAllowances?: boolean;\n}): ComposeRun => ({\n inputs: run.inputs,\n signer: run.signer,\n ...pickDefined({\n // An empty precondition list is the same as none, so drop it too.\n preconditions: run.preconditions?.length ? run.preconditions : undefined,\n assumptions: run.assumptions,\n referrer: run.referrer,\n integratorFeeBps: run.integratorFeeBps,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n simulateUserProgram: run.simulateUserProgram,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0FA,MAAa,gBACX,MACA,SAAkC,CAAC,OACZ;CACvB;CACA,GAAG;AACL;;;;;;;;;AAUA,MAAM,eACJ,QAEA,OAAO,YACL,OAAO,QAAQ,GAAG,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CAC/D;;;;;;;AAQF,MAAa,YAAY,SAYN;CACjB,QAAQ,IAAI;CACZ,QAAQ,IAAI;CACZ,GAAG,YAAY;EAEb,eAAe,IAAI,eAAe,SAAS,IAAI,gBAAgB,KAAA;EAC/D,aAAa,IAAI;EACjB,UAAU,IAAI;EACd,kBAAkB,IAAI;EACtB,mBAAmB,IAAI;EACvB,SAAS,IAAI;EACb,kBAAkB,IAAI;EACtB,qBAAqB,IAAI;EACzB,wBAAwB,IAAI;CAC9B,CAAC;AACH"}
1
+ {"version":3,"file":"inputs.js","names":[],"sources":["../../src/run/inputs.ts"],"sourcesContent":["import type {\n ComposeRun,\n ForwardTo,\n InputSpec,\n MaterialiserInput,\n Precondition,\n SimulationPolicy,\n} from '@lifi/compose-spec';\n\nimport type { Address, InputSchema, InputSpecOf } from '../types.js';\n\n/**\n * Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.\n *\n * @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.\n */\nexport interface ComposeRunInput<T extends InputSchema = InputSchema> {\n /**\n * Concrete values for each declared flow input. Resource inputs accept a\n * materialiser or a literal integer amount; scalar inputs accept the matching type.\n */\n readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]> };\n /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */\n readonly preconditions?: readonly Precondition[];\n /** The `0x`-prefixed address of the transaction signer. */\n readonly signer: Address;\n /**\n * Optional assumed token amounts for resource inputs, keyed by input name.\n * When a materialiser resolves amounts at execution time rather than upfront,\n * assumptions let the compiler plan routes using estimated values. The keys\n * must match the input names declared in the flow schema.\n */\n readonly assumptions?: { readonly [K in keyof T]?: bigint };\n /** Optional integrator referrer identifier. */\n readonly referrer?: string;\n /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */\n readonly maxPriceImpactBps?: number;\n /**\n * Destination for sweeping all proxy-held terminal resources after execution.\n * Pass a literal `0x`-prefixed address or `{ $ref: \"context.sender\" }` to\n * send remaining tokens to the signer.\n */\n readonly sweepTo?: ForwardTo;\n /**\n * Controls behavior when simulation detects a revert.\n * `'strict'` (default) returns an error; `'allow-revert'` returns a partial\n * result with the transaction and revert diagnostics.\n */\n readonly simulationPolicy?: SimulationPolicy;\n /**\n * When `true`, the server also simulates the final user-facing transaction\n * after the structured simulation succeeds; reverts honour\n * `simulationPolicy`. On success the result is echoed back on the response as\n * `userProgramSimulation`. Defaults to `false`.\n */\n readonly simulateUserProgram?: boolean;\n /**\n * When `true`, the server checks on-chain ERC-20 allowances and omits\n * approvals that are already sufficient. Defaults to `false`.\n */\n readonly checkOnChainAllowances?: boolean;\n}\n\n/**\n * Creates an untyped materialiser input spec. This is a low-level escape hatch\n * for materialiser kinds not yet covered by the generated helpers.\n *\n * Prefer the typed helpers in the `materialisers` namespace (e.g.\n * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide\n * compile-time config validation.\n *\n * @param kind - The materialiser type (e.g. `\"balanceOf\"`, `\"directDeposit\"`).\n * @param config - Optional materialiser-specific configuration.\n * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.\n *\n * @example\n * ```ts\n * const run = {\n * inputs: { token: materialiser('customKind', { myParam: '0x...' }) },\n * signer: '0x...',\n * };\n * ```\n */\nexport const materialiser = (\n kind: string,\n config: Record<string, unknown> = {},\n): MaterialiserInput => ({\n kind,\n ...config,\n});\n\n/**\n * Drops the keys whose value is `undefined`, so optional fields are omitted\n * from the wire payload rather than serialized as `null`.\n *\n * A local copy of `pickDefined` from `@lifi/utils`: this package is published\n * to npm and `@lifi/utils` is a private workspace package, so it cannot be a\n * runtime dependency here.\n */\nconst pickDefined = <S extends Record<string, unknown>>(\n obj: S,\n): Partial<{ [K in keyof S]: Exclude<S[K], undefined> }> =>\n Object.fromEntries(\n Object.entries(obj).filter(([, value]) => value !== undefined),\n ) as Partial<{ [K in keyof S]: Exclude<S[K], undefined> }>;\n\n/**\n * Assembles a {@link ComposeRun} object from individual parameters.\n * Used internally by the SDK; prefer {@link ComposeRunInput} for external use.\n *\n * @internal\n */\nexport const buildRun = (run: {\n inputs: Record<string, InputSpec>;\n preconditions?: readonly Precondition[];\n signer: string;\n assumptions?: Record<string, bigint>;\n referrer?: string;\n maxPriceImpactBps?: number;\n sweepTo?: ForwardTo;\n simulationPolicy?: SimulationPolicy;\n simulateUserProgram?: boolean;\n checkOnChainAllowances?: boolean;\n}): ComposeRun => ({\n inputs: run.inputs,\n signer: run.signer,\n ...pickDefined({\n // An empty precondition list is the same as none, so drop it too.\n preconditions: run.preconditions?.length ? run.preconditions : undefined,\n assumptions: run.assumptions,\n referrer: run.referrer,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n simulateUserProgram: run.simulateUserProgram,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmFA,MAAa,gBACX,MACA,SAAkC,CAAC,OACZ;CACvB;CACA,GAAG;AACL;;;;;;;;;AAUA,MAAM,eACJ,QAEA,OAAO,YACL,OAAO,QAAQ,GAAG,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CAC/D;;;;;;;AAQF,MAAa,YAAY,SAWN;CACjB,QAAQ,IAAI;CACZ,QAAQ,IAAI;CACZ,GAAG,YAAY;EAEb,eAAe,IAAI,eAAe,SAAS,IAAI,gBAAgB,KAAA;EAC/D,aAAa,IAAI;EACjB,UAAU,IAAI;EACd,mBAAmB,IAAI;EACvB,SAAS,IAAI;EACb,kBAAkB,IAAI;EACtB,qBAAqB,IAAI;EACzB,wBAAwB,IAAI;CAC9B,CAAC;AACH"}
package/dist/sdk.cjs CHANGED
@@ -25,7 +25,6 @@ const createComposeSdk = (options) => {
25
25
  signer: run.signer,
26
26
  assumptions: run.assumptions,
27
27
  referrer: run.referrer,
28
- integratorFeeBps: run.integratorFeeBps,
29
28
  maxPriceImpactBps: run.maxPriceImpactBps,
30
29
  sweepTo: run.sweepTo,
31
30
  simulationPolicy: run.simulationPolicy,
package/dist/sdk.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.cjs","names":["createComposeClient","buildRun","createFlowBuilderCore","bindGeneratedOps"],"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 type { ChainSummary } from './discovery.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 * Fetches the chains this Compose deployment supports, ascending by\n * `chainId`. Thin pass-through to {@link ComposeClient.getChains}; see it\n * for what \"supported\" means and for the caching caveat.\n *\n * Each entry pairs the `chainId` with a display `name`, so one call both\n * gates a chain selector and labels it. Key on `chainId`; `name` is a\n * deployment-maintained label that can change.\n *\n * Use it to fail fast before building a flow for a chain the server would\n * reject.\n *\n * @returns The supported chains, ascending by `chainId`.\n * @throws {@link ComposeError} on network or server errors.\n *\n * @example\n * ```ts\n * const chains = await sdk.getSupportedChains();\n * if (!chains.some((c) => c.chainId === 8453)) {\n * throw new Error('Base is not supported');\n * }\n * for (const { chainId, name } of chains) {\n * console.log(`${name} (${chainId})`);\n * }\n * ```\n */\n readonly getSupportedChains: () => Promise<readonly ChainSummary[]>;\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 into a submit-ready transaction. Thin\n * pass-through to {@link ComposeClient.route}; see it for the short chain of\n * catalog edges the server plans, when to prefer `flow(...).compile(...)`,\n * the `success` / `partial` discrimination, and error behaviour. Build the\n * `amount` with `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 simulateUserProgram: run.simulateUserProgram,\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 getSupportedChains: composeClient.getChains,\n request,\n route: composeClient.route,\n simulate: composeClient.simulate,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA6LA,MAAa,oBAAoB,YAA2C;CAC1E,MAAM,gBAAgBA,eAAAA,oBAAoB,OAAO;CAEjD,MAAM,WACJ,SACA,SAC2B;EAC3B,MAAM;EACN,KAAKC,mBAAAA,SAAS;GACZ,QAAQ,IAAI;GACZ,eAAe,IAAI;GACnB,QAAQ,IAAI;GACZ,aAAa,IAAI;GACjB,UAAU,IAAI;GACd,kBAAkB,IAAI;GACtB,mBAAmB,IAAI;GACvB,SAAS,IAAI;GACb,kBAAkB,IAAI;GACtB,qBAAqB,IAAI;GACzB,wBAAwB,IAAI;EAC9B,CAAC;CACH;CAEA,MAAM,QACJ,SACA,SACmB;EACnB,MAAM,OAAOC,kCAAAA,sBAAsB,SAAS,IAAI;EAChD,MAAM,UAAU,OAAO,OAAO,MAAMC,uCAAAA,iBAAiB,IAAI,CAAC;EAE1D,MAAM,UAAU,OACd,QACkC;GAClC,MAAM,UAAU,QAAQ,MAAM;GAC9B,MAAM,MAAM,QAAQ,SAAS,GAAG;GAChC,OAAO,cAAc,QAAQ,GAAG;EAClC;EAEA,OAAO,OAAO,OAAO,SAAS,EAAE,QAAQ,CAAC;CAC3C;CAEA,OAAO;EACL,QAAQ;EACR;EACA,oBAAoB,cAAc;EAClC;EACA,OAAO,cAAc;EACrB,UAAU,cAAc;CAC1B;AACF"}
1
+ {"version":3,"file":"sdk.cjs","names":["createComposeClient","buildRun","createFlowBuilderCore","bindGeneratedOps"],"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 type { ChainSummary } from './discovery.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 * Fetches the chains this Compose deployment supports, ascending by\n * `chainId`. Thin pass-through to {@link ComposeClient.getChains}; see it\n * for what \"supported\" means and for the caching caveat.\n *\n * Each entry pairs the `chainId` with a display `name`, so one call both\n * gates a chain selector and labels it. Key on `chainId`; `name` is a\n * deployment-maintained label that can change.\n *\n * Use it to fail fast before building a flow for a chain the server would\n * reject.\n *\n * @returns The supported chains, ascending by `chainId`.\n * @throws {@link ComposeError} on network or server errors.\n *\n * @example\n * ```ts\n * const chains = await sdk.getSupportedChains();\n * if (!chains.some((c) => c.chainId === 8453)) {\n * throw new Error('Base is not supported');\n * }\n * for (const { chainId, name } of chains) {\n * console.log(`${name} (${chainId})`);\n * }\n * ```\n */\n readonly getSupportedChains: () => Promise<readonly ChainSummary[]>;\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 into a submit-ready transaction. Thin\n * pass-through to {@link ComposeClient.route}; see it for the short chain of\n * catalog edges the server plans, when to prefer `flow(...).compile(...)`,\n * the `success` / `partial` discrimination, and error behaviour. Build the\n * `amount` with `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 maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n simulateUserProgram: run.simulateUserProgram,\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 getSupportedChains: composeClient.getChains,\n request,\n route: composeClient.route,\n simulate: composeClient.simulate,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA6LA,MAAa,oBAAoB,YAA2C;CAC1E,MAAM,gBAAgBA,eAAAA,oBAAoB,OAAO;CAEjD,MAAM,WACJ,SACA,SAC2B;EAC3B,MAAM;EACN,KAAKC,mBAAAA,SAAS;GACZ,QAAQ,IAAI;GACZ,eAAe,IAAI;GACnB,QAAQ,IAAI;GACZ,aAAa,IAAI;GACjB,UAAU,IAAI;GACd,mBAAmB,IAAI;GACvB,SAAS,IAAI;GACb,kBAAkB,IAAI;GACtB,qBAAqB,IAAI;GACzB,wBAAwB,IAAI;EAC9B,CAAC;CACH;CAEA,MAAM,QACJ,SACA,SACmB;EACnB,MAAM,OAAOC,kCAAAA,sBAAsB,SAAS,IAAI;EAChD,MAAM,UAAU,OAAO,OAAO,MAAMC,uCAAAA,iBAAiB,IAAI,CAAC;EAE1D,MAAM,UAAU,OACd,QACkC;GAClC,MAAM,UAAU,QAAQ,MAAM;GAC9B,MAAM,MAAM,QAAQ,SAAS,GAAG;GAChC,OAAO,cAAc,QAAQ,GAAG;EAClC;EAEA,OAAO,OAAO,OAAO,SAAS,EAAE,QAAQ,CAAC;CAC3C;CAEA,OAAO;EACL,QAAQ;EACR;EACA,oBAAoB,cAAc;EAClC;EACA,OAAO,cAAc;EACrB,UAAU,cAAc;CAC1B;AACF"}
package/dist/sdk.js CHANGED
@@ -24,7 +24,6 @@ const createComposeSdk = (options) => {
24
24
  signer: run.signer,
25
25
  assumptions: run.assumptions,
26
26
  referrer: run.referrer,
27
- integratorFeeBps: run.integratorFeeBps,
28
27
  maxPriceImpactBps: run.maxPriceImpactBps,
29
28
  sweepTo: run.sweepTo,
30
29
  simulationPolicy: run.simulationPolicy,
package/dist/sdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","names":[],"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 type { ChainSummary } from './discovery.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 * Fetches the chains this Compose deployment supports, ascending by\n * `chainId`. Thin pass-through to {@link ComposeClient.getChains}; see it\n * for what \"supported\" means and for the caching caveat.\n *\n * Each entry pairs the `chainId` with a display `name`, so one call both\n * gates a chain selector and labels it. Key on `chainId`; `name` is a\n * deployment-maintained label that can change.\n *\n * Use it to fail fast before building a flow for a chain the server would\n * reject.\n *\n * @returns The supported chains, ascending by `chainId`.\n * @throws {@link ComposeError} on network or server errors.\n *\n * @example\n * ```ts\n * const chains = await sdk.getSupportedChains();\n * if (!chains.some((c) => c.chainId === 8453)) {\n * throw new Error('Base is not supported');\n * }\n * for (const { chainId, name } of chains) {\n * console.log(`${name} (${chainId})`);\n * }\n * ```\n */\n readonly getSupportedChains: () => Promise<readonly ChainSummary[]>;\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 into a submit-ready transaction. Thin\n * pass-through to {@link ComposeClient.route}; see it for the short chain of\n * catalog edges the server plans, when to prefer `flow(...).compile(...)`,\n * the `success` / `partial` discrimination, and error behaviour. Build the\n * `amount` with `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 simulateUserProgram: run.simulateUserProgram,\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 getSupportedChains: composeClient.getChains,\n request,\n route: composeClient.route,\n simulate: composeClient.simulate,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA6LA,MAAa,oBAAoB,YAA2C;CAC1E,MAAM,gBAAgB,oBAAoB,OAAO;CAEjD,MAAM,WACJ,SACA,SAC2B;EAC3B,MAAM;EACN,KAAK,SAAS;GACZ,QAAQ,IAAI;GACZ,eAAe,IAAI;GACnB,QAAQ,IAAI;GACZ,aAAa,IAAI;GACjB,UAAU,IAAI;GACd,kBAAkB,IAAI;GACtB,mBAAmB,IAAI;GACvB,SAAS,IAAI;GACb,kBAAkB,IAAI;GACtB,qBAAqB,IAAI;GACzB,wBAAwB,IAAI;EAC9B,CAAC;CACH;CAEA,MAAM,QACJ,SACA,SACmB;EACnB,MAAM,OAAO,sBAAsB,SAAS,IAAI;EAChD,MAAM,UAAU,OAAO,OAAO,MAAM,iBAAiB,IAAI,CAAC;EAE1D,MAAM,UAAU,OACd,QACkC;GAClC,MAAM,UAAU,QAAQ,MAAM;GAC9B,MAAM,MAAM,QAAQ,SAAS,GAAG;GAChC,OAAO,cAAc,QAAQ,GAAG;EAClC;EAEA,OAAO,OAAO,OAAO,SAAS,EAAE,QAAQ,CAAC;CAC3C;CAEA,OAAO;EACL,QAAQ;EACR;EACA,oBAAoB,cAAc;EAClC;EACA,OAAO,cAAc;EACrB,UAAU,cAAc;CAC1B;AACF"}
1
+ {"version":3,"file":"sdk.js","names":[],"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 type { ChainSummary } from './discovery.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 * Fetches the chains this Compose deployment supports, ascending by\n * `chainId`. Thin pass-through to {@link ComposeClient.getChains}; see it\n * for what \"supported\" means and for the caching caveat.\n *\n * Each entry pairs the `chainId` with a display `name`, so one call both\n * gates a chain selector and labels it. Key on `chainId`; `name` is a\n * deployment-maintained label that can change.\n *\n * Use it to fail fast before building a flow for a chain the server would\n * reject.\n *\n * @returns The supported chains, ascending by `chainId`.\n * @throws {@link ComposeError} on network or server errors.\n *\n * @example\n * ```ts\n * const chains = await sdk.getSupportedChains();\n * if (!chains.some((c) => c.chainId === 8453)) {\n * throw new Error('Base is not supported');\n * }\n * for (const { chainId, name } of chains) {\n * console.log(`${name} (${chainId})`);\n * }\n * ```\n */\n readonly getSupportedChains: () => Promise<readonly ChainSummary[]>;\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 into a submit-ready transaction. Thin\n * pass-through to {@link ComposeClient.route}; see it for the short chain of\n * catalog edges the server plans, when to prefer `flow(...).compile(...)`,\n * the `success` / `partial` discrimination, and error behaviour. Build the\n * `amount` with `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 maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n simulateUserProgram: run.simulateUserProgram,\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 getSupportedChains: composeClient.getChains,\n request,\n route: composeClient.route,\n simulate: composeClient.simulate,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA6LA,MAAa,oBAAoB,YAA2C;CAC1E,MAAM,gBAAgB,oBAAoB,OAAO;CAEjD,MAAM,WACJ,SACA,SAC2B;EAC3B,MAAM;EACN,KAAK,SAAS;GACZ,QAAQ,IAAI;GACZ,eAAe,IAAI;GACnB,QAAQ,IAAI;GACZ,aAAa,IAAI;GACjB,UAAU,IAAI;GACd,mBAAmB,IAAI;GACvB,SAAS,IAAI;GACb,kBAAkB,IAAI;GACtB,qBAAqB,IAAI;GACzB,wBAAwB,IAAI;EAC9B,CAAC;CACH;CAEA,MAAM,QACJ,SACA,SACmB;EACnB,MAAM,OAAO,sBAAsB,SAAS,IAAI;EAChD,MAAM,UAAU,OAAO,OAAO,MAAM,iBAAiB,IAAI,CAAC;EAE1D,MAAM,UAAU,OACd,QACkC;GAClC,MAAM,UAAU,QAAQ,MAAM;GAC9B,MAAM,MAAM,QAAQ,SAAS,GAAG;GAChC,OAAO,cAAc,QAAQ,GAAG;EAClC;EAEA,OAAO,OAAO,OAAO,SAAS,EAAE,QAAQ,CAAC;CAC3C;CAEA,OAAO;EACL,QAAQ;EACR;EACA,oBAAoB,cAAc;EAClC;EACA,OAAO,cAAc;EACrB,UAAU,cAAc;CAC1B;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/composer-sdk",
3
- "version": "0.11.3",
3
+ "version": "0.12.0",
4
4
  "description": "Public Composer SDK for building and submitting flows",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -47,7 +47,7 @@
47
47
  "example:staged": "tsx src/examples/run.ts --staged"
48
48
  },
49
49
  "peerDependencies": {
50
- "@lifi/compose-spec": "0.11.3"
50
+ "@lifi/compose-spec": "0.12.0"
51
51
  },
52
52
  "dependencies": {
53
53
  "abitype": "^1.2.3",
@@ -53,12 +53,20 @@ export const ref = <T extends OutputKind>(path: string): TypedRef<T> =>
53
53
  * (`continuationFlow`). The leg produces its outcome into its own proxy
54
54
  * (`leg.context.executionAddress`) and names no recipient; the composer
55
55
  * appends a settlement epilogue at commit that forwards the outcome to the
56
- * provider's recipient and the residual to `refund`.
56
+ * provider's recipient and the residual to `refund`. A call argument inside
57
+ * the leg (the payee of an invoice the leg pays through `core.call`) is not
58
+ * that recipient and may be a literal.
59
+ *
60
+ * In a `core.call` / `core.staticCall` bind, `kind` must equal the parameter's
61
+ * Solidity type exactly, and `value` must encode as that type: a decimal or
62
+ * `0x` integer, `'true'` / `'false'`, a `0x` address (mixed case only with a
63
+ * valid checksum), or a `0x` hex byte string of the right length.
57
64
  *
58
65
  * @typeParam T - The Solidity type of the literal (e.g. `'address'`).
59
66
  * @param kind - The literal's Solidity type.
60
67
  * @param value - The literal value, as the wire format carries it: a string.
61
- * @returns A {@link TypedLiteral} accepted by `Bindable<T>` slots matching `T`.
68
+ * @returns A {@link TypedLiteral} accepted by `Bindable<T>` slots matching `T`
69
+ * and by `core.call` / `core.staticCall` parameters of type `T`.
62
70
  *
63
71
  * @example
64
72
  * ```ts
@@ -1,38 +1,59 @@
1
- import type { Ref } from '@lifi/compose-spec';
1
+ import type { Ref, SolType } from '@lifi/compose-spec';
2
2
  import { type ParseAbiItem, parseAbiItem } from 'abitype';
3
3
 
4
- import type { AbiTypeToOutputKind, TypedGuard } from '../types.js';
4
+ import type {
5
+ AbiTypeToOutputKind,
6
+ TypedGuard,
7
+ TypedLiteral,
8
+ } from '../types.js';
5
9
 
6
10
  import type { CallArgs } from './FlowBuilderCore.js';
7
11
  import type { AnyRefBindable, OutputHandle, RefBindable } from './handles.js';
8
12
  import { handleToRef } from './handles.js';
9
13
 
14
+ /**
15
+ * Any value a signature-derived bind slot accepts, with no per-slot type
16
+ * constraint: a ref-resolving bindable or a typed literal.
17
+ */
18
+ type AnySignatureBindable = AnyRefBindable | TypedLiteral;
19
+
20
+ // The literal arm of a signature-derived slot. A positional arg is encoded by
21
+ // its parameter's ABI type, not by the literal's `kind`, so the kind must equal
22
+ // that type exactly: the `bytes32` widening `Bindable<T>` applies would admit an
23
+ // `address` literal the encoder then rejects. A parameter whose ABI type is no
24
+ // `SolType` (a tuple, an array, `uint24`) has no literal kind to name, so its
25
+ // slot stays ref-only.
26
+ type SignatureLiteral<TAbiType extends string> = TAbiType extends SolType
27
+ ? TypedLiteral<TAbiType>
28
+ : never;
29
+
10
30
  /**
11
31
  * Type-level extraction of named bind keys from a function signature string.
12
32
  * When `TSig` is a string literal matching a Solidity function signature,
13
- * resolves to a record whose keys are the parameter names and values are
14
- * `RefBindable<kind>` where the kind is derived from each parameter's Solidity
15
- * type via `AbiTypeToOutputKind`. For recognised `SolType` parameters
16
- * (e.g. `uint256`, `address`, `uint128`) the bind slot is precisely typed;
17
- * for other Solidity types (e.g. tuples) the slot accepts any scalar handle.
18
- * Falls back to `Record<string, AnyRefBindable>` for non-literal strings.
33
+ * resolves to a record whose keys are the parameter names and whose values are
34
+ * `RefBindable<kind>`, where the kind is derived from each parameter's Solidity
35
+ * type via `AbiTypeToOutputKind`, or a `TypedLiteral` (`raw.literal`) of that
36
+ * exact Solidity type. For recognised `SolType` parameters (e.g. `uint256`,
37
+ * `address`, `bytes`) the slot is precisely typed; other Solidity types (e.g.
38
+ * tuples) accept any scalar handle and no literal.
39
+ * Falls back to `Record<string, AnySignatureBindable>` for non-literal strings.
19
40
  *
20
- * These slots are lowered into `config.args`, which is positional calldata
21
- * rather than a node `bind` record, so a literal is not accepted here: only
22
- * values that resolve to a `$ref`.
41
+ * These slots are lowered into `config.args`, positional calldata: a ref
42
+ * becomes `{ $ref }` and a literal becomes its `value` string, which the
43
+ * backend encodes against the parameter's type.
23
44
  */
24
45
  export type SignatureBind<TSig extends string> = string extends TSig
25
- ? Record<string, AnyRefBindable>
46
+ ? Record<string, AnySignatureBindable>
26
47
  : ParseAbiItem<TSig> extends {
27
48
  type: 'function';
28
49
  inputs: infer I extends readonly { name: string; type: string }[];
29
50
  }
30
51
  ? {
31
- readonly [P in I[number] as P['name']]: RefBindable<
32
- AbiTypeToOutputKind<P['type']>
33
- >;
52
+ readonly [P in I[number] as P['name']]:
53
+ | RefBindable<AbiTypeToOutputKind<P['type']>>
54
+ | SignatureLiteral<P['type']>;
34
55
  }
35
- : Record<string, AnyRefBindable>;
56
+ : Record<string, AnySignatureBindable>;
36
57
 
37
58
  // ---------------------------------------------------------------------------
38
59
  // Return-type inference from function signatures
@@ -139,9 +160,18 @@ export const toBindRef = (bindable: AnyRefBindable): Ref => {
139
160
  return bindable;
140
161
  };
141
162
 
163
+ /**
164
+ * Converts one signature-derived bind to its positional `config.args` entry: a
165
+ * ref-resolving bindable becomes `{ $ref }`; a literal becomes its `value`
166
+ * verbatim, which the backend encodes against the parameter's ABI type (a
167
+ * decimal or hex integer, a hex address or byte string, `'true'`/`'false'`).
168
+ */
169
+ const toPositionalArg = (bindable: AnySignatureBindable): Ref | string =>
170
+ 'kind' in bindable ? bindable.value : toBindRef(bindable);
171
+
142
172
  export interface BuildCallWireFormatInput {
143
173
  readonly resource?: AnyRefBindable;
144
- readonly bind: Record<string, AnyRefBindable>;
174
+ readonly bind: Record<string, AnySignatureBindable>;
145
175
  readonly config: Record<string, unknown>;
146
176
  readonly guards?: readonly TypedGuard[];
147
177
  }
@@ -155,13 +185,13 @@ export interface CallWireResult {
155
185
 
156
186
  /**
157
187
  * Parses a function signature from `config`, validates bind keys against it,
158
- * and converts named binds to positional `$ref` args.
188
+ * and converts named binds to positional args.
159
189
  */
160
190
  const resolvePositionalArgs = (
161
191
  label: string,
162
- bind: Record<string, AnyRefBindable>,
192
+ bind: Record<string, AnySignatureBindable>,
163
193
  config: Record<string, unknown>,
164
- ): Ref[] => {
194
+ ): (Ref | string)[] => {
165
195
  const functionSignature = config.functionSignature;
166
196
  if (typeof functionSignature !== 'string') {
167
197
  throw new Error(
@@ -196,7 +226,7 @@ const resolvePositionalArgs = (
196
226
  `${label}: bind value for parameter "${name}" is undefined`,
197
227
  );
198
228
  }
199
- return toBindRef(bindable);
229
+ return toPositionalArg(bindable);
200
230
  });
201
231
  };
202
232
 
@@ -205,7 +235,7 @@ const resolvePositionalArgs = (
205
235
  * format that the backend expects:
206
236
  * - With resource: `core.call` with `bind: { input: <resourceRef> }`
207
237
  * - Without resource: `core.invoke` with `bind: {}`
208
- * - `config: { ...userConfig, args: [positional refs...] }`
238
+ * - `config: { ...userConfig, args: [positional refs and literal values...] }`
209
239
  */
210
240
  export const buildCallWireFormat = (
211
241
  args: BuildCallWireFormatInput,
@@ -226,7 +256,7 @@ export const buildCallWireFormat = (
226
256
  };
227
257
 
228
258
  export interface BuildStaticCallWireFormatInput {
229
- readonly bind: Record<string, AnyRefBindable>;
259
+ readonly bind: Record<string, AnySignatureBindable>;
230
260
  readonly config: Record<string, unknown>;
231
261
  readonly guards?: readonly TypedGuard[];
232
262
  }
@@ -34,8 +34,7 @@ export interface ContinuationBridgeSettleInput {
34
34
  * escrow on Base instead of landing at an address
35
35
  * - `continuation.settle` bound to `bridge.amountOut` (delivered funding): the
36
36
  * bridge delivers straight into the escrow, so the user signs one
37
- * transaction on Arbitrum, and the settle must omit `funding` and
38
- * `perpetual`
37
+ * transaction on Arbitrum, and the settle must omit `funding`
39
38
  * - `validity.expiresAtMs` at least `max(3 × the bridge ETA, 30 minutes)` away
40
39
  * - A leg on the escrow chain (Base) that does the work the user could not do
41
40
  * from Arbitrum: `lifi.zap` supplies the landed USDC to Aave. The aBasUSDC
@@ -50,7 +50,7 @@ export interface ContinuationSettleInput {
50
50
  * settlement account, not the user). Never set the leg's own epilogue. At
51
51
  * commit the composer appends the settlement epilogue, which forwards each
52
52
  * outcome to the provider's recipient and the residual to `refund`.
53
- * - Omit `funding` and `perpetual` when the settle input is a bridge's
53
+ * - Omit `funding` when the settle input is a bridge's
54
54
  * `amountOut` (see `continuationBridgeSettle.ts`).
55
55
  * - `minAmount` is optional: a guard or an op floor on the outcome token
56
56
  * proves it, and an unconsumed funding input proves the full funding floor.
@@ -1230,7 +1230,7 @@ export interface ParaswapBuyConfig {
1230
1230
  */
1231
1231
  partnerAddress?: string;
1232
1232
  /**
1233
- * Integrator fee in basis points; non-negative integer string capped at 9000.
1233
+ * Paraswap partner fee in basis points; non-negative integer string capped at 9000.
1234
1234
  */
1235
1235
  partnerFeeBps?: string;
1236
1236
  }
@@ -1319,13 +1319,13 @@ export interface ContinuationSettleConfig {
1319
1319
  validity: {
1320
1320
  expiresAtMs: Between86400000000000008640000000000000;
1321
1321
  };
1322
- perpetual?: boolean;
1323
1322
  provider?: string;
1324
1323
  funding?: 'inline' | 'external';
1325
1324
  /**
1326
1325
  * EVM address: 0x followed by 40 hex characters
1327
1326
  */
1328
1327
  refund?: Address;
1328
+ exact?: boolean;
1329
1329
  }
1330
1330
 
1331
1331
  export interface UniswapV2AddLiquidityConfig {
@@ -1498,6 +1498,7 @@ export type DirectDepositMaterialiserConfig =
1498
1498
  | {
1499
1499
  allowNonExact: true;
1500
1500
  simAmount?: string;
1501
+ minAmount?: IntegerStringInput;
1501
1502
  };
1502
1503
 
1503
1504
  export interface CallMaterialiserConfig {
@@ -436,7 +436,7 @@ export interface CoreTransferArgs {
436
436
  readonly amount: Bindable<'resource'>;
437
437
  readonly recipient: Bindable<'address'>;
438
438
  };
439
- readonly config: CoreTransferConfig;
439
+ readonly config?: CoreTransferConfig;
440
440
  readonly guards?: readonly TypedGuard<'transferred'>[];
441
441
  }
442
442
 
package/src/index.ts CHANGED
@@ -49,7 +49,6 @@ export type {
49
49
  ComposeCompilePartialData,
50
50
  ComposeAction,
51
51
  ComposeFill,
52
- ComposeFee,
53
52
  ComposeUserProgramSimulation,
54
53
  ComposeWarning,
55
54
  ComposeCompileRequest,
@@ -104,6 +103,7 @@ export type {
104
103
  ContinuationOutcome,
105
104
  SettlementWire,
106
105
  SettlementEscrowWire,
106
+ SettlementBindingWire,
107
107
  } from '@lifi/compose-spec';
108
108
  export {
109
109
  SIMULATE_MAX_TRACKED_BALANCES,
package/src/run/inputs.ts CHANGED
@@ -33,13 +33,6 @@ export interface ComposeRunInput<T extends InputSchema = InputSchema> {
33
33
  readonly assumptions?: { readonly [K in keyof T]?: bigint };
34
34
  /** Optional integrator referrer identifier. */
35
35
  readonly referrer?: string;
36
- /**
37
- * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).
38
- * A non-zero value requires the request to be authenticated with an
39
- * integration-scoped API key — the integration is derived from the key, not
40
- * this field. Defaults to `0` (no fee) when omitted.
41
- */
42
- readonly integratorFeeBps?: number;
43
36
  /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */
44
37
  readonly maxPriceImpactBps?: number;
45
38
  /**
@@ -123,7 +116,6 @@ export const buildRun = (run: {
123
116
  signer: string;
124
117
  assumptions?: Record<string, bigint>;
125
118
  referrer?: string;
126
- integratorFeeBps?: number;
127
119
  maxPriceImpactBps?: number;
128
120
  sweepTo?: ForwardTo;
129
121
  simulationPolicy?: SimulationPolicy;
@@ -137,7 +129,6 @@ export const buildRun = (run: {
137
129
  preconditions: run.preconditions?.length ? run.preconditions : undefined,
138
130
  assumptions: run.assumptions,
139
131
  referrer: run.referrer,
140
- integratorFeeBps: run.integratorFeeBps,
141
132
  maxPriceImpactBps: run.maxPriceImpactBps,
142
133
  sweepTo: run.sweepTo,
143
134
  simulationPolicy: run.simulationPolicy,
package/src/sdk.ts CHANGED
@@ -201,7 +201,6 @@ export const createComposeSdk = (options: ComposeSdkOptions): ComposeSdk => {
201
201
  signer: run.signer,
202
202
  assumptions: run.assumptions as Record<string, bigint> | undefined,
203
203
  referrer: run.referrer,
204
- integratorFeeBps: run.integratorFeeBps,
205
204
  maxPriceImpactBps: run.maxPriceImpactBps,
206
205
  sweepTo: run.sweepTo,
207
206
  simulationPolicy: run.simulationPolicy,
@@ -1,59 +0,0 @@
1
- import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
2
-
3
- import { createComposeSdk, materialisers, resources } from '../index.js';
4
-
5
- import { API_KEY, BASE_URL, OWNER } from './config.js';
6
-
7
- const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
8
- const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
9
-
10
- /**
11
- * Swap WETH to USDC via LI.FI while collecting an integrator fee.
12
- *
13
- * Demonstrates:
14
- * - Setting `integratorFeeBps` on the compile request (50 bps = 0.5%)
15
- * - The fee is taken on the input token; the backend injects the fee transfer
16
- *
17
- * A non-zero `integratorFeeBps` requires the SDK to be configured with an
18
- * integration-scoped API key (`apiKey`); the integration is derived from the
19
- * key, not the request body.
20
- */
21
- export const buildSwapWithFeeExample = (): {
22
- flow: Flow;
23
- request: ComposeCompileRequest;
24
- } => {
25
- const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
26
-
27
- // Declare the flow with a single WETH input on Ethereum mainnet.
28
- const builder = sdk.flow(1, {
29
- name: 'swap-with-fee',
30
- inputs: {
31
- amountIn: resources.erc20(WETH, 1),
32
- },
33
- });
34
-
35
- // Swap WETH → USDC via LI.FI.
36
- builder.lifi.swap('swap', {
37
- bind: { amountIn: builder.inputs.amountIn },
38
- config: {
39
- resourceOut: resources.erc20(USDC, 1),
40
- slippage: 0.03,
41
- },
42
- });
43
-
44
- const flow = builder.build();
45
-
46
- // Build the compile request with a 50 bps (0.5%) integrator fee.
47
- const request = sdk.request(flow, {
48
- signer: OWNER,
49
- inputs: {
50
- amountIn: materialisers.directDeposit({
51
- amount: '1000000000000000000',
52
- }),
53
- },
54
- integratorFeeBps: 50,
55
- sweepTo: builder.context.sender,
56
- });
57
-
58
- return { flow, request };
59
- };