@lifi/compose-spec 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -94,6 +94,8 @@ __export(index_exports, {
94
94
  canonicalNativeAddress: () => canonicalNativeAddress,
95
95
  copy: () => copy,
96
96
  erc20: () => erc20,
97
+ erc20Allowance: () => erc20Allowance,
98
+ erc20Balance: () => erc20Balance,
97
99
  erc20Resource: () => erc20Resource,
98
100
  erc20Token: () => erc20Token,
99
101
  flowInputMode: () => flowInputMode,
@@ -109,12 +111,15 @@ __export(index_exports, {
109
111
  isContextKey: () => isContextKey,
110
112
  isEQCheck: () => isEQCheck,
111
113
  isERC20Resource: () => isERC20Resource,
114
+ isErc20AllowancePrecondition: () => isErc20AllowancePrecondition,
115
+ isFutureResourceOutput: () => isFutureResourceOutput,
112
116
  isGTECheck: () => isGTECheck,
113
117
  isHandlePort: () => isHandlePort,
114
118
  isLTECheck: () => isLTECheck,
115
119
  isMaterialiserInput: () => isMaterialiserInput,
116
120
  isMsgValueNative: () => isMsgValueNative,
117
121
  isNativeAddressForChain: () => isNativeAddressForChain,
122
+ isNativeBalancePrecondition: () => isNativeBalancePrecondition,
118
123
  isNativeResource: () => isNativeResource,
119
124
  isRef: () => isRef,
120
125
  isResourceInput: () => isResourceInput,
@@ -123,6 +128,7 @@ __export(index_exports, {
123
128
  isStaticSolType: () => isStaticSolType,
124
129
  linear: () => linear,
125
130
  native: () => native,
131
+ nativeBalance: () => nativeBalance,
126
132
  nativeResource: () => nativeResource,
127
133
  normalizeNativeTokenAddress: () => normalizeNativeTokenAddress,
128
134
  normalizeResource: () => normalizeResource,
@@ -478,6 +484,7 @@ var flowInputResource = (input) => isResourceInput(input) ? input.resource : voi
478
484
  var isResourcePort = (port) => port.kind === "resource";
479
485
  var isHandlePort = (port) => port.kind === "handle";
480
486
  var isResourceOutputPort = (port) => port.kind === "resource_output";
487
+ var isFutureResourceOutput = (port) => isResourceOutputPort(port) && port.availability === "future";
481
488
  var isMaterialiserInput = (s) => typeof s === "object" && s !== null && "kind" in s;
482
489
 
483
490
  // src/resource.ts
@@ -542,11 +549,27 @@ var outputRef = (node, port) => ({
542
549
  $ref: `${node}.${port}`
543
550
  });
544
551
  var optionalProp = (key, value) => value !== void 0 && value !== null ? { [key]: value } : {};
545
- var linear = (name, type) => ({ name, type, mode: "linear", availability: "now" });
546
- var copy = (name, type) => ({ name, type, mode: "copy", availability: "now" });
552
+ var linear = (name, type) => ({
553
+ name,
554
+ type,
555
+ mode: "linear",
556
+ availability: "now"
557
+ });
558
+ var copy = (name, type) => ({
559
+ name,
560
+ type,
561
+ mode: "copy",
562
+ availability: "now"
563
+ });
547
564
  var handle = (name, type) => ({ name, type });
548
- var native = (name, chainId) => ({ name, resource: nativeResource(chainId) });
549
- var erc20 = (name, token, chainId) => ({ name, resource: erc20Resource(token, chainId) });
565
+ var native = (name, chainId) => ({
566
+ name,
567
+ resource: nativeResource(chainId)
568
+ });
569
+ var erc20 = (name, token, chainId) => ({
570
+ name,
571
+ resource: erc20Resource(token, chainId)
572
+ });
550
573
  var resource = (name, accepts, options) => ({
551
574
  kind: "resource",
552
575
  name,
@@ -554,17 +577,24 @@ var resource = (name, accepts, options) => ({
554
577
  mode: "linear",
555
578
  ...optionalProp("optional", options?.optional)
556
579
  });
557
- var readResource = (name, accepts) => ({ kind: "resource", name, accepts, mode: "copy" });
580
+ var readResource = (name, accepts) => ({
581
+ kind: "resource",
582
+ name,
583
+ accepts,
584
+ mode: "copy"
585
+ });
558
586
  var opHandle = (name, type, options) => ({
559
587
  kind: "handle",
560
588
  name,
561
589
  type,
562
590
  mode: "copy",
563
591
  ...optionalProp("expose", options?.expose),
564
- ...optionalProp("units", options?.units)
592
+ ...optionalProp("units", options?.units),
593
+ ...optionalProp("optional", options?.optional)
565
594
  });
566
595
  var resourceOutput = (name, options) => {
567
- const opts = typeof options === "string" ? { availability: options } : options;
596
+ const raw = options;
597
+ const opts = typeof raw === "string" ? { availability: raw } : raw;
568
598
  return {
569
599
  kind: "resource_output",
570
600
  name,
@@ -609,6 +639,13 @@ var refKey = (ref) => foldRef(parseRef(ref), {
609
639
  output: (node, port) => `output:${node}:${port}`
610
640
  });
611
641
 
642
+ // src/preconditions.ts
643
+ var erc20Balance = (config) => ({ type: "Erc20Balance", ...config });
644
+ var nativeBalance = (config) => ({ type: "NativeBalance", ...config });
645
+ var erc20Allowance = (config) => ({ type: "Erc20Allowance", ...config });
646
+ var isErc20AllowancePrecondition = (p) => p.type === "Erc20Allowance";
647
+ var isNativeBalancePrecondition = (p) => p.type === "NativeBalance";
648
+
612
649
  // src/simulate.ts
613
650
  var SIMULATE_MAX_TRACKED_BALANCES = 40;
614
651
  var SIMULATE_MAX_REQUIREMENTS = 40;
@@ -674,7 +711,8 @@ var HandlePortZod = import_zod.default.object({
674
711
  type: SolTypeZod,
675
712
  mode: import_zod.default.enum(["linear", "copy"]),
676
713
  expose: import_zod.default.boolean().optional(),
677
- units: HandleUnitsZod.optional()
714
+ units: HandleUnitsZod.optional(),
715
+ optional: import_zod.default.boolean().optional()
678
716
  });
679
717
  var InputPortZod = import_zod.default.discriminatedUnion("kind", [
680
718
  ResourcePortZod,
@@ -922,6 +960,8 @@ var ContinuationPlanZod = import_zod.default.object({
922
960
  canonicalNativeAddress,
923
961
  copy,
924
962
  erc20,
963
+ erc20Allowance,
964
+ erc20Balance,
925
965
  erc20Resource,
926
966
  erc20Token,
927
967
  flowInputMode,
@@ -937,12 +977,15 @@ var ContinuationPlanZod = import_zod.default.object({
937
977
  isContextKey,
938
978
  isEQCheck,
939
979
  isERC20Resource,
980
+ isErc20AllowancePrecondition,
981
+ isFutureResourceOutput,
940
982
  isGTECheck,
941
983
  isHandlePort,
942
984
  isLTECheck,
943
985
  isMaterialiserInput,
944
986
  isMsgValueNative,
945
987
  isNativeAddressForChain,
988
+ isNativeBalancePrecondition,
946
989
  isNativeResource,
947
990
  isRef,
948
991
  isResourceInput,
@@ -951,6 +994,7 @@ var ContinuationPlanZod = import_zod.default.object({
951
994
  isStaticSolType,
952
995
  linear,
953
996
  native,
997
+ nativeBalance,
954
998
  nativeResource,
955
999
  normalizeNativeTokenAddress,
956
1000
  normalizeResource,
package/dist/index.d.cts CHANGED
@@ -789,7 +789,7 @@ type Resource = {
789
789
  };
790
790
  type SimulatedAmounts = {
791
791
  readonly amountOut: bigint;
792
- readonly amountOutMin: bigint;
792
+ readonly amountOutMin?: bigint;
793
793
  };
794
794
  type ProducedResource = Resource & {
795
795
  readonly availability: Availability;
@@ -879,6 +879,7 @@ declare const HandlePortZod: z.ZodObject<{
879
879
  bps: "bps";
880
880
  "token-decimals": "token-decimals";
881
881
  }>>;
882
+ optional: z.ZodOptional<z.ZodBoolean>;
882
883
  }, z.core.$strip>;
883
884
  declare const InputPortZod: z.ZodDiscriminatedUnion<[z.ZodObject<{
884
885
  kind: z.ZodLiteral<"resource">;
@@ -924,6 +925,7 @@ declare const InputPortZod: z.ZodDiscriminatedUnion<[z.ZodObject<{
924
925
  bps: "bps";
925
926
  "token-decimals": "token-decimals";
926
927
  }>>;
928
+ optional: z.ZodOptional<z.ZodBoolean>;
927
929
  }, z.core.$strip>], "kind">;
928
930
  declare const ResourceOutputPortZod: z.ZodObject<{
929
931
  kind: z.ZodLiteral<"resource_output">;
@@ -985,6 +987,7 @@ declare const OutputPortZod: z.ZodDiscriminatedUnion<[z.ZodObject<{
985
987
  bps: "bps";
986
988
  "token-decimals": "token-decimals";
987
989
  }>>;
990
+ optional: z.ZodOptional<z.ZodBoolean>;
988
991
  }, z.core.$strip>], "kind">;
989
992
  declare const ManifestOperationZod: z.ZodObject<{
990
993
  id: z.ZodString;
@@ -1033,6 +1036,7 @@ declare const ManifestOperationZod: z.ZodObject<{
1033
1036
  bps: "bps";
1034
1037
  "token-decimals": "token-decimals";
1035
1038
  }>>;
1039
+ optional: z.ZodOptional<z.ZodBoolean>;
1036
1040
  }, z.core.$strip>], "kind">>;
1037
1041
  outputs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1038
1042
  kind: z.ZodLiteral<"resource_output">;
@@ -1079,6 +1083,7 @@ declare const ManifestOperationZod: z.ZodObject<{
1079
1083
  bps: "bps";
1080
1084
  "token-decimals": "token-decimals";
1081
1085
  }>>;
1086
+ optional: z.ZodOptional<z.ZodBoolean>;
1082
1087
  }, z.core.$strip>], "kind">>;
1083
1088
  configSchema: z.ZodOptional<z.ZodUnknown>;
1084
1089
  }, z.core.$strip>;
@@ -1268,6 +1273,7 @@ declare const ComposeManifestZod: z.ZodObject<{
1268
1273
  bps: "bps";
1269
1274
  "token-decimals": "token-decimals";
1270
1275
  }>>;
1276
+ optional: z.ZodOptional<z.ZodBoolean>;
1271
1277
  }, z.core.$strip>], "kind">>;
1272
1278
  outputs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1273
1279
  kind: z.ZodLiteral<"resource_output">;
@@ -1314,6 +1320,7 @@ declare const ComposeManifestZod: z.ZodObject<{
1314
1320
  bps: "bps";
1315
1321
  "token-decimals": "token-decimals";
1316
1322
  }>>;
1323
+ optional: z.ZodOptional<z.ZodBoolean>;
1317
1324
  }, z.core.$strip>], "kind">>;
1318
1325
  configSchema: z.ZodOptional<z.ZodUnknown>;
1319
1326
  }, z.core.$strip>>;
@@ -1893,7 +1900,8 @@ declare const flowInputResource: (input: FlowInput) => Resource | undefined;
1893
1900
  declare const isResourcePort: (port: OpInputPort) => port is ResourcePort;
1894
1901
  declare const isHandlePort: (port: OpInputPort | OpOutputPort) => port is HandlePort;
1895
1902
  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';
1903
+ declare const isFutureResourceOutput: (port: OpInputPort | OpOutputPort) => boolean;
1904
+ 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
1905
  type GenericComposeErrorKind = Exclude<ComposeErrorKind, 'preparation_error' | 'simulation_revert'>;
1898
1906
  interface FailedPreparedOp {
1899
1907
  readonly callId: string;
@@ -1950,9 +1958,10 @@ interface FlashloanMaterialiserInput {
1950
1958
  readonly amount: string;
1951
1959
  }
1952
1960
 
1953
- interface OpHandleOptions {
1961
+ interface OpHandleOptions<Opt extends boolean = boolean> {
1954
1962
  readonly expose?: boolean;
1955
1963
  readonly units?: HandleUnits;
1964
+ readonly optional?: Opt;
1956
1965
  }
1957
1966
  declare const inputRef: (port: string) => Ref;
1958
1967
  declare const outputRef: (node: string, port: string) => Ref;
@@ -1977,26 +1986,32 @@ declare const erc20: <N extends string>(name: N, token: string, chainId: number)
1977
1986
  readonly name: N;
1978
1987
  };
1979
1988
  declare const resource: <N extends string, Opt extends boolean = false>(name: N, accepts: "erc20" | "native" | "any", options?: {
1980
- optional?: Opt;
1989
+ readonly optional?: Opt;
1981
1990
  }) => ResourcePort & {
1982
1991
  readonly name: N;
1983
- readonly optional: Opt;
1992
+ readonly optional: NoInfer<Opt>;
1984
1993
  };
1985
1994
  declare const readResource: <N extends string>(name: N, accepts: "erc20" | "native" | "any") => ResourcePort & {
1986
1995
  readonly name: N;
1987
1996
  readonly mode: "copy";
1988
1997
  };
1989
- declare const opHandle: <N extends string, T extends SolType>(name: N, type: T, options?: OpHandleOptions) => HandlePort & {
1998
+ declare const opHandle: <N extends string, T extends SolType, Opt extends boolean = false>(name: N, type: T, options?: OpHandleOptions<Opt>) => HandlePort & {
1990
1999
  readonly name: N;
1991
2000
  readonly type: T;
2001
+ readonly optional: NoInfer<Opt>;
2002
+ };
2003
+ type ResourceOutputOptions = Availability | {
2004
+ readonly availability?: Availability;
2005
+ readonly providesMinimum?: boolean;
2006
+ readonly omitIfZero?: boolean;
2007
+ readonly deliveryAddressInput?: string;
1992
2008
  };
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 & {
2009
+ type OutputAvailability<O> = [O] extends ['future'] ? 'future' : [O] extends ['now'] ? 'now' : [O] extends [string] ? Availability : O extends {
2010
+ readonly availability: infer A;
2011
+ } ? [A] extends ['future'] ? 'future' : [A] extends ['now'] ? 'now' : Availability : 'now';
2012
+ declare const resourceOutput: <N extends string, const O extends ResourceOutputOptions = "now">(name: N, options?: O) => ResourceOutputPort & {
1999
2013
  readonly name: N;
2014
+ readonly availability: OutputAvailability<O>;
2000
2015
  };
2001
2016
 
2002
2017
  type ParsedRef = {
@@ -2133,6 +2148,162 @@ declare const normalizeResource: (r: Resource) => Resource;
2133
2148
  */
2134
2149
  declare const normalizeNativeTokenAddress: (token: string, chainId: number) => string;
2135
2150
 
2151
+ /**
2152
+ * Canonical request types for the `POST /compose/route` convenience endpoint.
2153
+ * Amounts accept `bigint | string` for authoring convenience; the JSON wire
2154
+ * format is always a decimal string, which the SDK serialises for you.
2155
+ *
2156
+ * `/compose/route` trades authoring power for brevity. Instead of a full flow
2157
+ * document it takes a single from/to token pair; the server builds a
2158
+ * `lifi.zap` flow with a `directDeposit` input on the caller's behalf and runs
2159
+ * it through the same compile pipeline as `POST /compose`. As of today the flow
2160
+ * it builds is a single zap step — one edge of the server's routing catalog —
2161
+ * and it is meant to author richer flows later, which this request shape is
2162
+ * deliberately agnostic about. Its response body is byte-identical to that of
2163
+ * `POST /compose` — the enveloped `ComposeCompileSuccessData` on HTTP 200 and
2164
+ * `ComposeCompilePartialData` on HTTP 206 — so this file declares only the
2165
+ * request shape and reuses `ComposeCompileResult` from `./compile.js` for the
2166
+ * result.
2167
+ *
2168
+ * These are the single source of truth for the request shape, hand-authored
2169
+ * here for the same reason as `./compile.ts` and `./simulate.ts` rather than
2170
+ * derived from the validating schema: that schema is the Zod one in
2171
+ * `@lifi/api-schemas` (`src/routes/composeRoute.ts`), a package that depends on
2172
+ * this one, so importing its inferred types here would invert the dependency —
2173
+ * and the public SDK ships this package as its only peer dependency, never the
2174
+ * server's schema package. The two definitions are held in lockstep by a
2175
+ * compile-time conformance assertion
2176
+ * (`api-schemas/src/routes/composeRoute.typecheck.ts`), which fails the build
2177
+ * if either side drifts.
2178
+ */
2179
+
2180
+ /**
2181
+ * Spend an exact amount of `fromToken`.
2182
+ *
2183
+ * `amount` is in the token's smallest unit. Accepts `bigint | string`; the wire
2184
+ * format is a non-negative decimal string.
2185
+ */
2186
+ interface RouteAmountExact {
2187
+ readonly type: 'EXACT';
2188
+ readonly amount: bigint | string;
2189
+ }
2190
+ /**
2191
+ * Spend the signer's entire `fromToken` balance, whatever it is at execution
2192
+ * time.
2193
+ *
2194
+ * The on-chain amount is resolved by a deposit-all materialiser, so it is not
2195
+ * known when the route is compiled. `simAmount` is the stand-in the server
2196
+ * quotes and simulates against — make it a realistic estimate of the balance,
2197
+ * because it determines the quote and the derived preconditions, not the amount
2198
+ * actually moved. Accepts `bigint | string`; the wire format is a non-negative
2199
+ * decimal string.
2200
+ *
2201
+ * Not supported when `fromToken` is the chain's native sentinel: a gas coin
2202
+ * arrives via `msg.value`, so there is no on-chain balance to sweep, and the
2203
+ * server rejects the combination with a `validation_error`. Use
2204
+ * {@link RouteAmountExact} for native inputs.
2205
+ */
2206
+ interface RouteAmountAll {
2207
+ readonly type: 'ALL';
2208
+ readonly simAmount: bigint | string;
2209
+ }
2210
+ /**
2211
+ * How much of `fromToken` a route spends. Two variants, discriminated by
2212
+ * `type`.
2213
+ */
2214
+ type RouteAmount = RouteAmountExact | RouteAmountAll;
2215
+ /** Request body for `POST /compose/route`. */
2216
+ interface ComposeRouteRequest {
2217
+ /** EVM chain id. Both tokens must live on this chain — routes are same-chain. */
2218
+ readonly chainId: number;
2219
+ /**
2220
+ * Token to spend. Use the chain's native sentinel address for the gas coin
2221
+ * (the zero address on EVM-native chains).
2222
+ */
2223
+ readonly fromToken: string;
2224
+ /** Token to receive. */
2225
+ readonly toToken: string;
2226
+ /** How much of `fromToken` to spend — an exact amount or the whole balance. */
2227
+ readonly amount: RouteAmount;
2228
+ /** Address that funds the route and, by default, owns its output. */
2229
+ readonly signer: string;
2230
+ /**
2231
+ * Slippage tolerance in basis points, applied as a guard on the route's
2232
+ * output. Range 0–10000. Defaults to `100` (1%) server-side when omitted.
2233
+ */
2234
+ readonly slippageBps?: number;
2235
+ /**
2236
+ * Reject the route when its quoted price impact exceeds this many basis
2237
+ * points. Range 0–10000. Omitted ⇒ no price-impact guard is installed.
2238
+ */
2239
+ readonly maxPriceImpactBps?: number;
2240
+ /**
2241
+ * Integrator fee in basis points, taken from the input amount. Range 0–9000.
2242
+ * Defaults to `0` server-side when omitted. A non-zero value requires an
2243
+ * integration-scoped API key; the server rejects it otherwise.
2244
+ */
2245
+ readonly integratorFeeBps?: number;
2246
+ /** Opaque referrer tag forwarded to the underlying quote provider. */
2247
+ readonly referrer?: string;
2248
+ /**
2249
+ * Owner of the route's output; defaults to `signer`. Routes whose protocol
2250
+ * mints to a named receiver (surfaced as `recipient: 'required'` by
2251
+ * `GET /compose/zap-packs`) bind this address at mint time rather than
2252
+ * transferring afterwards. Accepts an address or `{ $ref: 'context.sender' }`;
2253
+ * `{ $ref: 'context.executionAddress' }` is rejected.
2254
+ */
2255
+ readonly sweepTo?: SweepTo;
2256
+ /**
2257
+ * `'strict'` (the default) fails the request when simulation detects a
2258
+ * revert; `'allow-revert'` returns a partial result with revert diagnostics
2259
+ * instead.
2260
+ */
2261
+ readonly simulationPolicy?: SimulationPolicy;
2262
+ /**
2263
+ * Also simulate the final user-facing transaction after the structured
2264
+ * simulation succeeds. Reverts honour `simulationPolicy`. Defaults to `false`.
2265
+ */
2266
+ readonly simulateUserProgram?: boolean;
2267
+ /**
2268
+ * Filter the returned `approvals` against current on-chain allowances,
2269
+ * omitting approvals that are already sufficient. Defaults to `false`.
2270
+ */
2271
+ readonly checkOnChainAllowances?: boolean;
2272
+ }
2273
+
2274
+ /**
2275
+ * The three concrete precondition shapes the stack exchanges today. One
2276
+ * definition serves every producer and consumer: op/materialiser declarations,
2277
+ * `rewritePreconditions`, the simulator's funding requirements (`simulate.ts`
2278
+ * aliases these as `*Requirement`), and the zap-backend approval derivation.
2279
+ *
2280
+ * Amounts accept `bigint | string`: the SDK serialises `bigint` to a decimal
2281
+ * string; the string side covers values already stringified.
2282
+ */
2283
+ type Erc20BalancePrecondition = {
2284
+ readonly type: 'Erc20Balance';
2285
+ readonly wallet: string;
2286
+ readonly token: string;
2287
+ readonly balance: bigint | string;
2288
+ };
2289
+ type NativeBalancePrecondition = {
2290
+ readonly type: 'NativeBalance';
2291
+ readonly wallet: string;
2292
+ readonly balance: bigint | string;
2293
+ };
2294
+ type Erc20AllowancePrecondition = {
2295
+ readonly type: 'Erc20Allowance';
2296
+ readonly owner: string;
2297
+ readonly spender: string;
2298
+ readonly token: string;
2299
+ readonly allowance: bigint | string;
2300
+ };
2301
+ declare const erc20Balance: (config: Omit<Erc20BalancePrecondition, "type">) => Erc20BalancePrecondition;
2302
+ declare const nativeBalance: (config: Omit<NativeBalancePrecondition, "type">) => NativeBalancePrecondition;
2303
+ declare const erc20Allowance: (config: Omit<Erc20AllowancePrecondition, "type">) => Erc20AllowancePrecondition;
2304
+ declare const isErc20AllowancePrecondition: (p: Precondition) => p is Erc20AllowancePrecondition;
2305
+ declare const isNativeBalancePrecondition: (p: Precondition) => p is NativeBalancePrecondition;
2306
+
2136
2307
  /**
2137
2308
  * Canonical wire-format types for the standalone `POST /simulate` endpoint.
2138
2309
  *
@@ -2150,6 +2321,7 @@ declare const normalizeNativeTokenAddress: (token: string, chainId: number) => s
2150
2321
  *
2151
2322
  * Mirrors the hand-authored style of `src/compile.ts`.
2152
2323
  */
2324
+
2153
2325
  /**
2154
2326
  * Maximum number of watched `(token, owner)` pairs accepted by `POST /simulate`.
2155
2327
  *
@@ -2178,31 +2350,12 @@ interface TrackedBalance {
2178
2350
  /** Account whose balance of `token` is watched. */
2179
2351
  readonly owner: string;
2180
2352
  }
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
- }
2353
+ /** Funding instruction: seed an ERC-20 balance on a wallet before simulation. */
2354
+ type Erc20BalanceRequirement = Erc20BalancePrecondition;
2192
2355
  /** 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
- }
2356
+ type NativeBalanceRequirement = NativeBalancePrecondition;
2198
2357
  /** 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
- }
2358
+ type Erc20AllowanceRequirement = Erc20AllowancePrecondition;
2206
2359
  /**
2207
2360
  * The funding-instruction union applied before a simulation. Three variants,
2208
2361
  * discriminated by `type`.
@@ -2318,4 +2471,4 @@ declare const foldMaterialiserMetadata: <R>(meta: MaterialiserMetadata, cases: {
2318
2471
  readonly runtime: () => R;
2319
2472
  }) => R;
2320
2473
 
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 };
2474
+ 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 ComposeRouteRequest, 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 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, 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, inputRef, 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, outputRef, parseRef, providerKindByName, providerKindNames, readResource, refKey, resource, resourceKey, resourceOutput, resourceToken, resourcesEqual };