@lifi/compose-spec 0.4.0 → 0.5.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.
package/dist/index.d.cts CHANGED
@@ -138,10 +138,6 @@ declare const CallSchema: Schema.Struct<{
138
138
  readonly value: typeof Schema.Unknown;
139
139
  }]>>>;
140
140
  }>;
141
- declare const ContinuationSchema: Schema.Struct<{
142
- awaits: typeof Schema.String;
143
- flowId: typeof Schema.String;
144
- }>;
145
141
  declare const FlowSchema: Schema.Struct<{
146
142
  version: Schema.Literal<[1]>;
147
143
  id: typeof Schema.String;
@@ -195,10 +191,6 @@ declare const FlowSchema: Schema.Struct<{
195
191
  readonly value: typeof Schema.Unknown;
196
192
  }]>>>;
197
193
  }>>;
198
- continuations: Schema.optional<Schema.Array$<Schema.Struct<{
199
- awaits: typeof Schema.String;
200
- flowId: typeof Schema.String;
201
- }>>>;
202
194
  }>;
203
195
  type SolType = typeof SolTypeSchema.Type;
204
196
  type ResourceInput = typeof ResourceInputSchema.Type;
@@ -209,7 +201,6 @@ type LiteralBinding = typeof LiteralBindingSchema.Type;
209
201
  type BindValue = typeof BindValueSchema.Type;
210
202
  type AppliedGuard = typeof AppliedGuardSchema.Type;
211
203
  type Call = typeof CallSchema.Type;
212
- type Continuation = typeof ContinuationSchema.Type;
213
204
  type Flow = typeof FlowSchema.Type;
214
205
 
215
206
  declare const CONTINUATION_COMMITMENT_OP_ID = "continuation.commitment";
@@ -299,23 +290,22 @@ declare const ContinuationIntentSchema: Schema.Struct<{
299
290
  readonly value: typeof Schema.Unknown;
300
291
  }]>>>;
301
292
  }>>;
302
- continuations: Schema.optional<Schema.Array$<Schema.Struct<{
303
- awaits: typeof Schema.String;
304
- flowId: typeof Schema.String;
305
- }>>>;
306
293
  }>>;
307
294
  validity: Schema.Struct<{
308
295
  expiresAtMs: typeof Schema.Number;
309
296
  }>;
310
297
  perpetual: Schema.optional<typeof Schema.Boolean>;
311
298
  provider: Schema.optional<typeof Schema.String>;
299
+ funding: Schema.optional<Schema.Literal<["inline", "external"]>>;
312
300
  }>;
313
301
  declare const Phase1ArtifactSchema: Schema.Union<[Schema.Struct<{
314
302
  kind: Schema.Literal<["transaction"]>;
303
+ funding: Schema.Literal<["inline", "external"]>;
315
304
  transactionRequest: Schema.optional<Schema.Struct<{
316
305
  to: typeof Schema.String;
317
306
  data: typeof Schema.String;
318
307
  value: typeof Schema.String;
308
+ chainId: typeof Schema.Number;
319
309
  }>>;
320
310
  }>, Schema.Struct<{
321
311
  kind: Schema.Literal<["signables"]>;
@@ -500,10 +490,6 @@ declare const ContinuationPlanSchema: Schema.Struct<{
500
490
  readonly value: typeof Schema.Unknown;
501
491
  }]>>>;
502
492
  }>>;
503
- continuations: Schema.optional<Schema.Array$<Schema.Struct<{
504
- awaits: typeof Schema.String;
505
- flowId: typeof Schema.String;
506
- }>>>;
507
493
  }>;
508
494
  check: Schema.transform<Schema.Union<[Schema.Struct<{
509
495
  kind: Schema.Literal<["erc20BalanceGte"]>;
@@ -789,12 +775,13 @@ type Resource = {
789
775
  };
790
776
  type SimulatedAmounts = {
791
777
  readonly amountOut: bigint;
792
- readonly amountOutMin: bigint;
778
+ readonly amountOutMin?: bigint;
793
779
  };
794
780
  type ProducedResource = Resource & {
795
781
  readonly availability: Availability;
796
782
  readonly simulated?: SimulatedAmounts;
797
783
  readonly owner: string;
784
+ readonly etaSeconds?: number;
798
785
  };
799
786
  declare const erc20Resource: (token: string, chainId: number) => Resource;
800
787
  declare const nativeResource: (chainId: number) => Resource;
@@ -879,6 +866,7 @@ declare const HandlePortZod: z.ZodObject<{
879
866
  bps: "bps";
880
867
  "token-decimals": "token-decimals";
881
868
  }>>;
869
+ optional: z.ZodOptional<z.ZodBoolean>;
882
870
  }, z.core.$strip>;
883
871
  declare const InputPortZod: z.ZodDiscriminatedUnion<[z.ZodObject<{
884
872
  kind: z.ZodLiteral<"resource">;
@@ -924,6 +912,7 @@ declare const InputPortZod: z.ZodDiscriminatedUnion<[z.ZodObject<{
924
912
  bps: "bps";
925
913
  "token-decimals": "token-decimals";
926
914
  }>>;
915
+ optional: z.ZodOptional<z.ZodBoolean>;
927
916
  }, z.core.$strip>], "kind">;
928
917
  declare const ResourceOutputPortZod: z.ZodObject<{
929
918
  kind: z.ZodLiteral<"resource_output">;
@@ -985,6 +974,7 @@ declare const OutputPortZod: z.ZodDiscriminatedUnion<[z.ZodObject<{
985
974
  bps: "bps";
986
975
  "token-decimals": "token-decimals";
987
976
  }>>;
977
+ optional: z.ZodOptional<z.ZodBoolean>;
988
978
  }, z.core.$strip>], "kind">;
989
979
  declare const ManifestOperationZod: z.ZodObject<{
990
980
  id: z.ZodString;
@@ -1033,6 +1023,7 @@ declare const ManifestOperationZod: z.ZodObject<{
1033
1023
  bps: "bps";
1034
1024
  "token-decimals": "token-decimals";
1035
1025
  }>>;
1026
+ optional: z.ZodOptional<z.ZodBoolean>;
1036
1027
  }, z.core.$strip>], "kind">>;
1037
1028
  outputs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1038
1029
  kind: z.ZodLiteral<"resource_output">;
@@ -1079,6 +1070,7 @@ declare const ManifestOperationZod: z.ZodObject<{
1079
1070
  bps: "bps";
1080
1071
  "token-decimals": "token-decimals";
1081
1072
  }>>;
1073
+ optional: z.ZodOptional<z.ZodBoolean>;
1082
1074
  }, z.core.$strip>], "kind">>;
1083
1075
  configSchema: z.ZodOptional<z.ZodUnknown>;
1084
1076
  }, z.core.$strip>;
@@ -1268,6 +1260,7 @@ declare const ComposeManifestZod: z.ZodObject<{
1268
1260
  bps: "bps";
1269
1261
  "token-decimals": "token-decimals";
1270
1262
  }>>;
1263
+ optional: z.ZodOptional<z.ZodBoolean>;
1271
1264
  }, z.core.$strip>], "kind">>;
1272
1265
  outputs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1273
1266
  kind: z.ZodLiteral<"resource_output">;
@@ -1314,6 +1307,7 @@ declare const ComposeManifestZod: z.ZodObject<{
1314
1307
  bps: "bps";
1315
1308
  "token-decimals": "token-decimals";
1316
1309
  }>>;
1310
+ optional: z.ZodOptional<z.ZodBoolean>;
1317
1311
  }, z.core.$strip>], "kind">>;
1318
1312
  configSchema: z.ZodOptional<z.ZodUnknown>;
1319
1313
  }, z.core.$strip>>;
@@ -1379,11 +1373,10 @@ declare const ComposeManifestZod: z.ZodObject<{
1379
1373
  }, z.core.$strip>;
1380
1374
  declare const Phase1ArtifactZod: z.ZodDiscriminatedUnion<[z.ZodObject<{
1381
1375
  kind: z.ZodLiteral<"transaction">;
1382
- transactionRequest: z.ZodOptional<z.ZodObject<{
1383
- to: z.ZodString;
1384
- data: z.ZodString;
1385
- value: z.ZodString;
1386
- }, z.core.$strip>>;
1376
+ funding: z.ZodEnum<{
1377
+ inline: "inline";
1378
+ external: "external";
1379
+ }>;
1387
1380
  }, z.core.$strip>, z.ZodObject<{
1388
1381
  kind: z.ZodLiteral<"signables">;
1389
1382
  typedData: z.ZodArray<z.ZodUnknown>;
@@ -1797,6 +1790,12 @@ interface ComposeRun {
1797
1790
  readonly maxPriceImpactBps?: number;
1798
1791
  readonly sweepTo?: SweepTo;
1799
1792
  readonly simulationPolicy?: SimulationPolicy;
1793
+ /**
1794
+ * Also simulate the final user-facing transaction. Defaults to `false`;
1795
+ * reverts honour `simulationPolicy` and a success is echoed back as
1796
+ * `userProgramSimulation`.
1797
+ */
1798
+ readonly simulateUserProgram?: boolean;
1800
1799
  readonly checkOnChainAllowances?: boolean;
1801
1800
  }
1802
1801
  interface ComposeCompileRequest {
@@ -1833,34 +1832,56 @@ interface SimulationRevert {
1833
1832
  }
1834
1833
  interface ComposeTransactionRequest {
1835
1834
  readonly to: string;
1835
+ readonly chainId: number;
1836
1836
  readonly data: string;
1837
1837
  readonly value: string;
1838
1838
  readonly gasLimit?: string;
1839
1839
  }
1840
- interface ComposeContinuation {
1841
- readonly awaits: string;
1842
- readonly flowId: string;
1840
+ interface ComposeAction {
1841
+ readonly kind: 'transaction';
1842
+ readonly purpose: 'approval' | 'execute' | 'fundEscrow';
1843
+ readonly submitter: 'signer' | 'anyone';
1844
+ readonly transactionRequest: ComposeTransactionRequest;
1845
+ readonly nodeId?: string;
1843
1846
  }
1844
1847
  interface ComposeContinuationData {
1845
- readonly continuations?: readonly ComposeContinuation[];
1846
1848
  readonly phase1ByNode?: Record<string, Phase1ArtifactWire>;
1847
1849
  readonly continuationPlans?: Record<string, ContinuationPlanWire>;
1848
1850
  }
1849
1851
  interface SpendEntry {
1852
+ readonly input: string;
1850
1853
  readonly token: string;
1854
+ readonly chainId: number;
1851
1855
  readonly amount: string;
1856
+ readonly nodeId?: string;
1857
+ }
1858
+ interface ComposeFee {
1859
+ readonly input: string;
1860
+ readonly token: string;
1861
+ readonly recipient: 'lifi' | 'integrator';
1862
+ readonly recipientAddress: string;
1863
+ readonly bps: number;
1864
+ readonly amount?: string;
1865
+ }
1866
+ interface ComposeUserProgramSimulation {
1867
+ readonly status: 'ok';
1868
+ readonly returnData: string;
1869
+ }
1870
+ interface ComposeFill {
1871
+ readonly spends: readonly SpendEntry[];
1872
+ readonly validUntilMs?: number;
1852
1873
  }
1853
1874
  interface ComposeCompileSuccessData extends ComposeContinuationData {
1854
1875
  readonly producedResources: Record<string, ProducedResource>;
1855
- readonly transactionRequest: ComposeTransactionRequest;
1876
+ readonly transactionRequest?: ComposeTransactionRequest;
1877
+ readonly actions?: readonly ComposeAction[];
1856
1878
  readonly userProxy: string;
1857
1879
  readonly priceImpact?: PriceImpact;
1858
1880
  readonly approvals?: readonly ApprovalEntry[];
1859
- readonly spends?: readonly SpendEntry[];
1860
- readonly quote?: {
1861
- readonly validUntilMs: number;
1862
- };
1863
- readonly verificationDescriptor?: VerificationDescriptor;
1881
+ readonly fees?: readonly ComposeFee[];
1882
+ readonly userProgramSimulation?: ComposeUserProgramSimulation;
1883
+ readonly fill?: ComposeFill;
1884
+ readonly verificationByNode?: Record<string, VerificationDescriptor>;
1864
1885
  }
1865
1886
  interface ComposeCompilePartialData extends ComposeContinuationData {
1866
1887
  readonly producedResources: Record<string, ProducedResource>;
@@ -1868,6 +1889,9 @@ interface ComposeCompilePartialData extends ComposeContinuationData {
1868
1889
  readonly userProxy: string;
1869
1890
  readonly simulationRevert: SimulationRevert;
1870
1891
  readonly approvals?: readonly ApprovalEntry[];
1892
+ readonly actions?: readonly ComposeAction[];
1893
+ readonly fees?: readonly ComposeFee[];
1894
+ readonly userProgramSimulation?: ComposeUserProgramSimulation;
1871
1895
  }
1872
1896
  type ComposeCompileResult = (ComposeCompileSuccessData & {
1873
1897
  readonly status: 'success';
@@ -1893,7 +1917,8 @@ declare const flowInputResource: (input: FlowInput) => Resource | undefined;
1893
1917
  declare const isResourcePort: (port: OpInputPort) => port is ResourcePort;
1894
1918
  declare const isHandlePort: (port: OpInputPort | OpOutputPort) => port is HandlePort;
1895
1919
  declare const isResourceOutputPort: (port: OpInputPort | OpOutputPort) => port is ResourceOutputPort;
1896
- type ComposeErrorKind = 'decode_error' | 'validation_error' | 'linearity_error' | 'resolve_error' | 'preparation_error' | 'provider_error' | 'no_route_error' | 'resolution_error' | 'lowering_error' | 'empty_program' | 'simulation_error' | 'simulation_setup_error' | 'simulation_rpc_error' | 'simulation_revert' | 'subgraph_simulation_revert' | 'guard_error' | 'continuation_error' | 'compilation_error' | 'verification_error' | 'price_impact_exceeded' | 'fee_resolution_error' | 'fee_resolution_unavailable' | 'flashloan_unauthorized';
1920
+ declare const isFutureResourceOutput: (port: OpInputPort | OpOutputPort) => boolean;
1921
+ type ComposeErrorKind = 'decode_error' | 'validation_error' | 'linearity_error' | 'resolve_error' | 'preparation_error' | 'provider_error' | 'no_route_error' | 'resolution_error' | 'resolution_rejected' | 'lowering_error' | 'empty_program' | 'simulation_error' | 'simulation_setup_error' | 'simulation_insufficient_funds' | 'simulation_gas_limit' | 'simulation_rpc_error' | 'simulation_revert' | 'subgraph_simulation_revert' | 'guard_error' | 'continuation_error' | 'compilation_error' | 'verification_error' | 'price_impact_exceeded' | 'fee_resolution_error' | 'fee_resolution_unavailable' | 'flashloan_unauthorized' | 'deadline_exceeded';
1897
1922
  type GenericComposeErrorKind = Exclude<ComposeErrorKind, 'preparation_error' | 'simulation_revert'>;
1898
1923
  interface FailedPreparedOp {
1899
1924
  readonly callId: string;
@@ -1950,12 +1975,11 @@ interface FlashloanMaterialiserInput {
1950
1975
  readonly amount: string;
1951
1976
  }
1952
1977
 
1953
- interface OpHandleOptions {
1978
+ interface OpHandleOptions<Opt extends boolean = boolean> {
1954
1979
  readonly expose?: boolean;
1955
1980
  readonly units?: HandleUnits;
1981
+ readonly optional?: Opt;
1956
1982
  }
1957
- declare const inputRef: (port: string) => Ref;
1958
- declare const outputRef: (node: string, port: string) => Ref;
1959
1983
  declare const linear: <N extends string, T extends SolType>(name: N, type: T) => Port & {
1960
1984
  readonly name: N;
1961
1985
  readonly type: T;
@@ -1977,26 +2001,32 @@ declare const erc20: <N extends string>(name: N, token: string, chainId: number)
1977
2001
  readonly name: N;
1978
2002
  };
1979
2003
  declare const resource: <N extends string, Opt extends boolean = false>(name: N, accepts: "erc20" | "native" | "any", options?: {
1980
- optional?: Opt;
2004
+ readonly optional?: Opt;
1981
2005
  }) => ResourcePort & {
1982
2006
  readonly name: N;
1983
- readonly optional: Opt;
2007
+ readonly optional: NoInfer<Opt>;
1984
2008
  };
1985
2009
  declare const readResource: <N extends string>(name: N, accepts: "erc20" | "native" | "any") => ResourcePort & {
1986
2010
  readonly name: N;
1987
2011
  readonly mode: "copy";
1988
2012
  };
1989
- declare const opHandle: <N extends string, T extends SolType>(name: N, type: T, options?: OpHandleOptions) => HandlePort & {
2013
+ declare const opHandle: <N extends string, T extends SolType, Opt extends boolean = false>(name: N, type: T, options?: OpHandleOptions<Opt>) => HandlePort & {
1990
2014
  readonly name: N;
1991
2015
  readonly type: T;
2016
+ readonly optional: NoInfer<Opt>;
2017
+ };
2018
+ type ResourceOutputOptions = Availability | {
2019
+ readonly availability?: Availability;
2020
+ readonly providesMinimum?: boolean;
2021
+ readonly omitIfZero?: boolean;
2022
+ readonly deliveryAddressInput?: string;
1992
2023
  };
1993
- declare const resourceOutput: <N extends string>(name: N, options?: Availability | {
1994
- availability?: Availability;
1995
- providesMinimum?: boolean;
1996
- omitIfZero?: boolean;
1997
- deliveryAddressInput?: string;
1998
- }) => ResourceOutputPort & {
2024
+ type OutputAvailability<O> = [O] extends ['future'] ? 'future' : [O] extends ['now'] ? 'now' : [O] extends [string] ? Availability : O extends {
2025
+ readonly availability: infer A;
2026
+ } ? [A] extends ['future'] ? 'future' : [A] extends ['now'] ? 'now' : Availability : 'now';
2027
+ declare const resourceOutput: <N extends string, const O extends ResourceOutputOptions = "now">(name: N, options?: O) => ResourceOutputPort & {
1999
2028
  readonly name: N;
2029
+ readonly availability: OutputAvailability<O>;
2000
2030
  };
2001
2031
 
2002
2032
  type ParsedRef = {
@@ -2022,6 +2052,22 @@ declare const isContextKey: (key: string) => key is ContextKey;
2022
2052
  declare const RESERVED_REF_SCOPES: ReadonlySet<string>;
2023
2053
  declare const isRef: (v: unknown) => v is Ref;
2024
2054
  declare const parseRef: (ref: Ref) => ParsedRef;
2055
+ /** A ref path: a dotpath such as `input.amount` or `nodeId.port`. */
2056
+ type RefPath = `${string}.${string}`;
2057
+ /**
2058
+ * Builds a bind ref. `ref.input(port)` for a flow input, `ref.context.*` for a
2059
+ * context ref, and a dotpath for a node output (`ref('deposit.shares')`).
2060
+ * Prefer the named forms: `parseRef` reads an unrecognised prefix as a node id,
2061
+ * so a misspelled `input.`/`context.` silently becomes an output ref.
2062
+ */
2063
+ interface RefBuilder {
2064
+ (path: RefPath): Ref;
2065
+ input(port: string): Ref;
2066
+ readonly context: {
2067
+ readonly [K in ContextKey]: Ref;
2068
+ };
2069
+ }
2070
+ declare const ref: RefBuilder;
2025
2071
  declare const foldRef: <R>(ref: ParsedRef, cases: {
2026
2072
  readonly input: (port: string) => R;
2027
2073
  readonly context: (key: ContextKey) => R;
@@ -2133,6 +2179,174 @@ declare const normalizeResource: (r: Resource) => Resource;
2133
2179
  */
2134
2180
  declare const normalizeNativeTokenAddress: (token: string, chainId: number) => string;
2135
2181
 
2182
+ /**
2183
+ * Canonical request types for the `POST /compose/route` convenience endpoint.
2184
+ * Amounts accept `bigint | string` for authoring convenience; the JSON wire
2185
+ * format is always a decimal string, which the SDK serialises for you.
2186
+ *
2187
+ * `/compose/route` trades authoring power for brevity. Instead of a full flow
2188
+ * document it takes a single from/to token pair; the server builds a one-node
2189
+ * zap flow with a `directDeposit` input on the caller's behalf and runs it
2190
+ * through the same compile pipeline as `POST /compose`. It routes through
2191
+ * `lifi.zap` unless the pair is reachable only asynchronously and the request
2192
+ * set `allowAsyncRoutes`, in which case it uses `lifi.zapAsync`. As of today
2193
+ * the flow it builds is a single zap step — one edge of the server's routing
2194
+ * catalog — and it is meant to author richer flows later, which this request
2195
+ * shape is deliberately agnostic about. Its response body is byte-identical to
2196
+ * that of `POST /compose` — the enveloped `ComposeCompileSuccessData` on HTTP
2197
+ * 200 and `ComposeCompilePartialData` on HTTP 206 — so this file declares only
2198
+ * the request shape and reuses `ComposeCompileResult` from `./compile.js` for
2199
+ * the result.
2200
+ *
2201
+ * These are the single source of truth for the request shape, hand-authored
2202
+ * here for the same reason as `./compile.ts` and `./simulate.ts` rather than
2203
+ * derived from the validating schema: that schema is the Zod one in
2204
+ * `@lifi/api-schemas` (`src/routes/composeRoute.ts`), a package that depends on
2205
+ * this one, so importing its inferred types here would invert the dependency —
2206
+ * and the public SDK ships this package as its only peer dependency, never the
2207
+ * server's schema package. The two definitions are held in lockstep by a
2208
+ * compile-time conformance assertion
2209
+ * (`api-schemas/src/routes/composeRoute.typecheck.ts`), which fails the build
2210
+ * if either side drifts.
2211
+ */
2212
+
2213
+ /**
2214
+ * Spend an exact amount of `fromToken`.
2215
+ *
2216
+ * `amount` is in the token's smallest unit. Accepts `bigint | string`; the wire
2217
+ * format is a non-negative decimal string.
2218
+ */
2219
+ interface RouteAmountExact {
2220
+ readonly type: 'EXACT';
2221
+ readonly amount: bigint | string;
2222
+ }
2223
+ /**
2224
+ * Spend the signer's entire `fromToken` balance, whatever it is at execution
2225
+ * time.
2226
+ *
2227
+ * The on-chain amount is resolved by a deposit-all materialiser, so it is not
2228
+ * known when the route is compiled. `simAmount` is the stand-in the server
2229
+ * quotes and simulates against — make it a realistic estimate of the balance,
2230
+ * because it determines the quote and the derived preconditions, not the amount
2231
+ * actually moved. Accepts `bigint | string`; the wire format is a non-negative
2232
+ * decimal string.
2233
+ *
2234
+ * Not supported when `fromToken` is the chain's native sentinel: a gas coin
2235
+ * arrives via `msg.value`, so there is no on-chain balance to sweep, and the
2236
+ * server rejects the combination with a `validation_error`. Use
2237
+ * {@link RouteAmountExact} for native inputs.
2238
+ */
2239
+ interface RouteAmountAll {
2240
+ readonly type: 'ALL';
2241
+ readonly simAmount: bigint | string;
2242
+ }
2243
+ /**
2244
+ * How much of `fromToken` a route spends. Two variants, discriminated by
2245
+ * `type`.
2246
+ */
2247
+ type RouteAmount = RouteAmountExact | RouteAmountAll;
2248
+ /** Request body for `POST /compose/route`. */
2249
+ interface ComposeRouteRequest {
2250
+ /** EVM chain id. Both tokens must live on this chain — routes are same-chain. */
2251
+ readonly chainId: number;
2252
+ /**
2253
+ * Token to spend. Use the chain's native sentinel address for the gas coin
2254
+ * (the zero address on EVM-native chains).
2255
+ */
2256
+ readonly fromToken: string;
2257
+ /** Token to receive. */
2258
+ readonly toToken: string;
2259
+ /** How much of `fromToken` to spend — an exact amount or the whole balance. */
2260
+ readonly amount: RouteAmount;
2261
+ /** Address that funds the route and, by default, owns its output. */
2262
+ readonly signer: string;
2263
+ /**
2264
+ * Slippage tolerance in basis points, applied as a guard on the route's
2265
+ * output. Range 0–10000. Defaults to `100` (1%) server-side when omitted.
2266
+ */
2267
+ readonly slippageBps?: number;
2268
+ /**
2269
+ * Reject the route when its quoted price impact exceeds this many basis
2270
+ * points. Range 0–10000. Omitted ⇒ no price-impact guard is installed.
2271
+ */
2272
+ readonly maxPriceImpactBps?: number;
2273
+ /**
2274
+ * Integrator fee in basis points, taken from the input amount. Range 0–9000.
2275
+ * Defaults to `0` server-side when omitted. A non-zero value requires an
2276
+ * integration-scoped API key; the server rejects it otherwise.
2277
+ */
2278
+ readonly integratorFeeBps?: number;
2279
+ /** Opaque referrer tag forwarded to the underlying quote provider. */
2280
+ readonly referrer?: string;
2281
+ /**
2282
+ * Owner of the route's output; defaults to `signer`. Routes whose protocol
2283
+ * mints to a named receiver (surfaced as `recipient: 'required'` by
2284
+ * `GET /compose/zap-packs`) bind this address at mint time rather than
2285
+ * transferring afterwards. Accepts an address or `{ $ref: 'context.sender' }`;
2286
+ * `{ $ref: 'context.executionAddress' }` is rejected.
2287
+ */
2288
+ readonly sweepTo?: SweepTo;
2289
+ /**
2290
+ * `'strict'` (the default) fails the request when simulation detects a
2291
+ * revert; `'allow-revert'` returns a partial result with revert diagnostics
2292
+ * instead.
2293
+ */
2294
+ readonly simulationPolicy?: SimulationPolicy;
2295
+ /**
2296
+ * Also simulate the final user-facing transaction after the structured
2297
+ * simulation succeeds. Reverts honour `simulationPolicy`. Defaults to `false`.
2298
+ */
2299
+ readonly simulateUserProgram?: boolean;
2300
+ /**
2301
+ * Filter the returned `approvals` against current on-chain allowances,
2302
+ * omitting approvals that are already sufficient. Defaults to `false`.
2303
+ */
2304
+ readonly checkOnChainAllowances?: boolean;
2305
+ /**
2306
+ * Accept a route whose output is delivered only after the initiating
2307
+ * transaction settles (`availability: 'future'` on the produced resource).
2308
+ * Such a route obliges you to track settlement rather than treat the
2309
+ * transaction as completing the job, and carries no slippage floor, so it is
2310
+ * opt-in. Defaults to `false` server-side, which leaves a pair reachable
2311
+ * only asynchronously rejected with `no_route_error` and guarantees every
2312
+ * produced resource is `availability: 'now'`.
2313
+ */
2314
+ readonly allowAsyncRoutes?: boolean;
2315
+ }
2316
+
2317
+ /**
2318
+ * The three concrete precondition shapes the stack exchanges today. One
2319
+ * definition serves every producer and consumer: op/materialiser declarations,
2320
+ * `rewritePreconditions`, the simulator's funding requirements (`simulate.ts`
2321
+ * aliases these as `*Requirement`), and the zap-backend approval derivation.
2322
+ *
2323
+ * Amounts accept `bigint | string`: the SDK serialises `bigint` to a decimal
2324
+ * string; the string side covers values already stringified.
2325
+ */
2326
+ type Erc20BalancePrecondition = {
2327
+ readonly type: 'Erc20Balance';
2328
+ readonly wallet: string;
2329
+ readonly token: string;
2330
+ readonly balance: bigint | string;
2331
+ };
2332
+ type NativeBalancePrecondition = {
2333
+ readonly type: 'NativeBalance';
2334
+ readonly wallet: string;
2335
+ readonly balance: bigint | string;
2336
+ };
2337
+ type Erc20AllowancePrecondition = {
2338
+ readonly type: 'Erc20Allowance';
2339
+ readonly owner: string;
2340
+ readonly spender: string;
2341
+ readonly token: string;
2342
+ readonly allowance: bigint | string;
2343
+ };
2344
+ declare const erc20Balance: (config: Omit<Erc20BalancePrecondition, "type">) => Erc20BalancePrecondition;
2345
+ declare const nativeBalance: (config: Omit<NativeBalancePrecondition, "type">) => NativeBalancePrecondition;
2346
+ declare const erc20Allowance: (config: Omit<Erc20AllowancePrecondition, "type">) => Erc20AllowancePrecondition;
2347
+ declare const isErc20AllowancePrecondition: (p: Precondition) => p is Erc20AllowancePrecondition;
2348
+ declare const isNativeBalancePrecondition: (p: Precondition) => p is NativeBalancePrecondition;
2349
+
2136
2350
  /**
2137
2351
  * Canonical wire-format types for the standalone `POST /simulate` endpoint.
2138
2352
  *
@@ -2150,6 +2364,7 @@ declare const normalizeNativeTokenAddress: (token: string, chainId: number) => s
2150
2364
  *
2151
2365
  * Mirrors the hand-authored style of `src/compile.ts`.
2152
2366
  */
2367
+
2153
2368
  /**
2154
2369
  * Maximum number of watched `(token, owner)` pairs accepted by `POST /simulate`.
2155
2370
  *
@@ -2178,31 +2393,12 @@ interface TrackedBalance {
2178
2393
  /** Account whose balance of `token` is watched. */
2179
2394
  readonly owner: string;
2180
2395
  }
2181
- /**
2182
- * Funding instruction: seed an ERC-20 balance on a wallet before simulation.
2183
- * Amounts accept `bigint | string` — the SDK serialises `bigint` to a decimal
2184
- * string; the string side covers values already stringified.
2185
- */
2186
- interface Erc20BalanceRequirement {
2187
- readonly type: 'Erc20Balance';
2188
- readonly wallet: string;
2189
- readonly token: string;
2190
- readonly balance: bigint | string;
2191
- }
2396
+ /** Funding instruction: seed an ERC-20 balance on a wallet before simulation. */
2397
+ type Erc20BalanceRequirement = Erc20BalancePrecondition;
2192
2398
  /** Funding instruction: seed a native balance on a wallet before simulation. */
2193
- interface NativeBalanceRequirement {
2194
- readonly type: 'NativeBalance';
2195
- readonly wallet: string;
2196
- readonly balance: bigint | string;
2197
- }
2399
+ type NativeBalanceRequirement = NativeBalancePrecondition;
2198
2400
  /** Funding instruction: seed an ERC-20 allowance before simulation. */
2199
- interface Erc20AllowanceRequirement {
2200
- readonly type: 'Erc20Allowance';
2201
- readonly owner: string;
2202
- readonly spender: string;
2203
- readonly token: string;
2204
- readonly allowance: bigint | string;
2205
- }
2401
+ type Erc20AllowanceRequirement = Erc20AllowancePrecondition;
2206
2402
  /**
2207
2403
  * The funding-instruction union applied before a simulation. Three variants,
2208
2404
  * discriminated by `type`.
@@ -2318,4 +2514,4 @@ declare const foldMaterialiserMetadata: <R>(meta: MaterialiserMetadata, cases: {
2318
2514
  readonly runtime: () => R;
2319
2515
  }) => R;
2320
2516
 
2321
- export { type AppliedGuard, AppliedGuardSchema, type ApprovalEntry, AssertedErc20BalanceGteSpecSchema, AssertedNativeBalanceGteSpecSchema, type AssertedPredicate, AssertedPredicateSchema, type AssertedPredicateWire, AssertedPredicateZod, type AssertionOwner, AssertionOwnerSchema, type AssertionSpec, AssertionSpecSchema, type AssertionSpecWire, AssertionSpecZod, type Availability, type BindValue, BindValueSchema, Bytes32HexSchema, CONTINUATION_COMMITMENT_OP_ID, type Call, CallCheckSpecSchema, CallSchema, type ChainCapabilities, type Check, type CheckComparator, CheckSchema, CheckZod, type ComposeCompilePartialData, type ComposeCompileRequest, type ComposeCompileResult, type ComposeCompileSuccessData, type ComposeContinuation, type ComposeError, type ComposeErrorKind, type ComposeManifest, ComposeManifestZod, type ComposeRun, type ComposeTransactionRequest, type ContextKey, type Continuation, type ContinuationIntent, ContinuationIntentSchema, type ContinuationOutcome, ContinuationOutcomeSchema, type ContinuationPlan, ContinuationPlanSchema, type ContinuationPlanWire, ContinuationPlanZod, ContinuationSchema, EVM_NATIVE_SENTINEL, type Erc20AllowanceRequirement, Erc20BalanceDeltaGteSpecSchema, Erc20BalanceGteSpecSchema, type Erc20BalanceRequirement, type FailedPreparedOp, type FlashloanMaterialiserInput, type Flow, type FlowInput, FlowInputSchema, FlowSchema, type GenericComposeError, type GenericComposeErrorKind, type GuardCompatibility, GuardCompatibilityZod, type GuardSelector, GuardSelectorZod, HANDLE_UNITS, type HandleInput, HandleInputSchema, type HandlePort, HandlePortZod, type HandleUnits, HandleUnitsZod, HexStringSchema, InputPortZod, type InputSpec, type LiteralBinding, LiteralBindingSchema, type ManifestGuard, ManifestGuardZod, type ManifestMaterialiser, ManifestMaterialiserZod, type ManifestOperation, ManifestOperationZod, type ManifestPrecondition, ManifestPreconditionZod, type MaterialiserConfigOf, type MaterialiserInput, type MaterialiserInputBase, type MaterialiserInputOf, type MaterialiserMetadata, type MaterialiserResolution, NativeBalanceDeltaGteSpecSchema, NativeBalanceGteSpecSchema, type NativeBalanceRequirement, type NativeErc20, type OpInputPort, type OpOutputPort, type OutputAmount, OutputPortZod, PROVIDER_KIND, type ParsedRef, type Phase1Artifact, Phase1ArtifactSchema, type Phase1ArtifactWire, Phase1ArtifactZod, type Port, type Precondition, type PreconditionBase, type PreconditionConfigOf, type PreconditionOf, type PreparationComposeError, type PriceImpact, type ProducedResource, type ProviderKindName, RESERVED_REF_SCOPES, type Ref, RefSchema, type RefScope, type Resource, type ResourceInput, ResourceInputSchema, type ResourceOutputPort, ResourceOutputPortZod, type ResourcePort, ResourcePortZod, ResourceSchema, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, STATIC_SOL_TYPES, type SimulateBalanceEntry, type SimulateOkResult, type SimulateRequest, type SimulateResult, type SimulateRevertDecodeResult, type SimulateRevertResult, type SimulateSetupErrorResult, type SimulatedAmounts, type SimulationPolicy, type SimulationRevert, type SimulationRevertComposeError, type SlotFinderRequirement, type SolType, SolTypeSchema, type SpendEntry, type StaticSolType, StaticSolTypeZod, type SweepTo, TEMPO_CHAIN_ID, TEMPO_NATIVE_ERC20, type TrackedBalance, type VerificationDescriptor, VerificationDescriptorSchema, type VerificationDescriptorWire, VerificationDescriptorZod, canonicalAssertedPredicate, canonicalNativeAddress, copy, erc20, erc20Resource, erc20Token, flowInputMode, flowInputResource, flowInputType, foldMaterialiserMetadata, foldRef, foldResource, getChainCapabilities, handle, inputRef, isAsErc20Chain, isContextKey, isEQCheck, isERC20Resource, isGTECheck, isHandlePort, isLTECheck, isMaterialiserInput, isMsgValueNative, isNativeAddressForChain, isNativeResource, isRef, isResourceInput, isResourceOutputPort, isResourcePort, isStaticSolType, linear, native, nativeResource, normalizeNativeTokenAddress, normalizeResource, opHandle, outputRef, parseRef, providerKindByName, providerKindNames, readResource, refKey, resource, resourceKey, resourceOutput, resourceToken, resourcesEqual };
2517
+ export { type AppliedGuard, AppliedGuardSchema, type ApprovalEntry, AssertedErc20BalanceGteSpecSchema, AssertedNativeBalanceGteSpecSchema, type AssertedPredicate, AssertedPredicateSchema, type AssertedPredicateWire, AssertedPredicateZod, type AssertionOwner, AssertionOwnerSchema, type AssertionSpec, AssertionSpecSchema, type AssertionSpecWire, AssertionSpecZod, type Availability, type BindValue, BindValueSchema, Bytes32HexSchema, CONTINUATION_COMMITMENT_OP_ID, type Call, CallCheckSpecSchema, CallSchema, type ChainCapabilities, type Check, type CheckComparator, CheckSchema, CheckZod, type ComposeAction, type ComposeCompilePartialData, type ComposeCompileRequest, type ComposeCompileResult, type ComposeCompileSuccessData, type ComposeError, type ComposeErrorKind, type ComposeFee, type ComposeFill, type ComposeManifest, ComposeManifestZod, type ComposeRouteRequest, type ComposeRun, type ComposeTransactionRequest, type ComposeUserProgramSimulation, type ContextKey, type ContinuationIntent, ContinuationIntentSchema, type ContinuationOutcome, ContinuationOutcomeSchema, type ContinuationPlan, ContinuationPlanSchema, type ContinuationPlanWire, ContinuationPlanZod, EVM_NATIVE_SENTINEL, type Erc20AllowancePrecondition, type Erc20AllowanceRequirement, Erc20BalanceDeltaGteSpecSchema, Erc20BalanceGteSpecSchema, type Erc20BalancePrecondition, type Erc20BalanceRequirement, type FailedPreparedOp, type FlashloanMaterialiserInput, type Flow, type FlowInput, FlowInputSchema, FlowSchema, type GenericComposeError, type GenericComposeErrorKind, type GuardCompatibility, GuardCompatibilityZod, type GuardSelector, GuardSelectorZod, HANDLE_UNITS, type HandleInput, HandleInputSchema, type HandlePort, HandlePortZod, type HandleUnits, HandleUnitsZod, HexStringSchema, InputPortZod, type InputSpec, type LiteralBinding, LiteralBindingSchema, type ManifestGuard, ManifestGuardZod, type ManifestMaterialiser, ManifestMaterialiserZod, type ManifestOperation, ManifestOperationZod, type ManifestPrecondition, ManifestPreconditionZod, type MaterialiserConfigOf, type MaterialiserInput, type MaterialiserInputBase, type MaterialiserInputOf, type MaterialiserMetadata, type MaterialiserResolution, NativeBalanceDeltaGteSpecSchema, NativeBalanceGteSpecSchema, type NativeBalancePrecondition, type NativeBalanceRequirement, type NativeErc20, type OpInputPort, type OpOutputPort, type OutputAmount, OutputPortZod, PROVIDER_KIND, type ParsedRef, type Phase1Artifact, Phase1ArtifactSchema, type Phase1ArtifactWire, Phase1ArtifactZod, type Port, type Precondition, type PreconditionBase, type PreconditionConfigOf, type PreconditionOf, type PreparationComposeError, type PriceImpact, type ProducedResource, type ProviderKindName, RESERVED_REF_SCOPES, type Ref, type RefBuilder, type RefPath, RefSchema, type RefScope, type Resource, type ResourceInput, ResourceInputSchema, type ResourceOutputPort, ResourceOutputPortZod, type ResourcePort, ResourcePortZod, ResourceSchema, type RouteAmount, type RouteAmountAll, type RouteAmountExact, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, STATIC_SOL_TYPES, type SimulateBalanceEntry, type SimulateOkResult, type SimulateRequest, type SimulateResult, type SimulateRevertDecodeResult, type SimulateRevertResult, type SimulateSetupErrorResult, type SimulatedAmounts, type SimulationPolicy, type SimulationRevert, type SimulationRevertComposeError, type SlotFinderRequirement, type SolType, SolTypeSchema, type SpendEntry, type StaticSolType, StaticSolTypeZod, type SweepTo, TEMPO_CHAIN_ID, TEMPO_NATIVE_ERC20, type TrackedBalance, type VerificationDescriptor, VerificationDescriptorSchema, type VerificationDescriptorWire, VerificationDescriptorZod, canonicalAssertedPredicate, canonicalNativeAddress, copy, erc20, erc20Allowance, erc20Balance, erc20Resource, erc20Token, flowInputMode, flowInputResource, flowInputType, foldMaterialiserMetadata, foldRef, foldResource, getChainCapabilities, handle, isAsErc20Chain, isContextKey, isEQCheck, isERC20Resource, isErc20AllowancePrecondition, isFutureResourceOutput, isGTECheck, isHandlePort, isLTECheck, isMaterialiserInput, isMsgValueNative, isNativeAddressForChain, isNativeBalancePrecondition, isNativeResource, isRef, isResourceInput, isResourceOutputPort, isResourcePort, isStaticSolType, linear, native, nativeBalance, nativeResource, normalizeNativeTokenAddress, normalizeResource, opHandle, parseRef, providerKindByName, providerKindNames, readResource, ref, refKey, resource, resourceKey, resourceOutput, resourceToken, resourcesEqual };