@lifi/compose-spec 0.12.0 → 0.14.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.cjs CHANGED
@@ -61,16 +61,26 @@ const ARC_NATIVE_ERC20 = {
61
61
  decimals: 6
62
62
  };
63
63
  const ARC_NATIVE_SCALE = 10n ** BigInt(18 - ARC_NATIVE_ERC20.decimals);
64
- const REGISTRY = /* @__PURE__ */ new Map([[TEMPO_CHAIN_ID, {
65
- kind: "as-erc20",
66
- chainId: TEMPO_CHAIN_ID,
67
- nativeErc20: TEMPO_NATIVE_ERC20
68
- }], [ARC_CHAIN_ID, {
69
- kind: "native-mirrored-erc20",
70
- chainId: ARC_CHAIN_ID,
71
- nativeErc20: ARC_NATIVE_ERC20,
72
- nativeScale: ARC_NATIVE_SCALE
73
- }]]);
64
+ const ARC_TESTNET_CHAIN_ID = 5042002;
65
+ const REGISTRY = /* @__PURE__ */ new Map([
66
+ [TEMPO_CHAIN_ID, {
67
+ kind: "as-erc20",
68
+ chainId: TEMPO_CHAIN_ID,
69
+ nativeErc20: TEMPO_NATIVE_ERC20
70
+ }],
71
+ [ARC_CHAIN_ID, {
72
+ kind: "native-mirrored-erc20",
73
+ chainId: ARC_CHAIN_ID,
74
+ nativeErc20: ARC_NATIVE_ERC20,
75
+ nativeScale: ARC_NATIVE_SCALE
76
+ }],
77
+ [ARC_TESTNET_CHAIN_ID, {
78
+ kind: "native-mirrored-erc20",
79
+ chainId: ARC_TESTNET_CHAIN_ID,
80
+ nativeErc20: ARC_NATIVE_ERC20,
81
+ nativeScale: ARC_NATIVE_SCALE
82
+ }]
83
+ ]);
74
84
  const getChainCapabilities = (chainId) => REGISTRY.get(chainId) ?? {
75
85
  kind: "evm-native",
76
86
  chainId
@@ -323,7 +333,7 @@ const normalizingOutcome = (raw) => effect.Schema.transform(raw, effect.Schema.t
323
333
  const ContinuationOutcomeSchema = normalizingOutcome(effect.Schema.Struct(outcomeFields(effect.Schema.optional(IntegerString))));
324
334
  const CommittedOutcomeSchema = normalizingOutcome(effect.Schema.Struct(outcomeFields(IntegerString)));
325
335
  const ContinuationIntentSchema = effect.Schema.Struct({
326
- outcomes: effect.Schema.NonEmptyArray(ContinuationOutcomeSchema),
336
+ outcomes: effect.Schema.Array(ContinuationOutcomeSchema),
327
337
  continuationFlow: effect.Schema.optional(FlowSchema),
328
338
  validity: effect.Schema.Struct({ expiresAtMs: EpochMsSchema }),
329
339
  provider: effect.Schema.optional(effect.Schema.String),
@@ -962,6 +972,10 @@ const SettlementZod = zod.default.object({
962
972
  escrow: SettlementEscrowZod.optional(),
963
973
  binding: SettlementBindingZod.optional()
964
974
  });
975
+ const ShortfallZod = zod.default.object({
976
+ required: zod.default.string(),
977
+ available: zod.default.string()
978
+ });
965
979
  //#endregion
966
980
  exports.ARC_CHAIN_ID = ARC_CHAIN_ID;
967
981
  exports.ARC_NATIVE_ERC20 = ARC_NATIVE_ERC20;
@@ -1020,6 +1034,7 @@ exports.SIMULATE_MAX_REQUIREMENTS = SIMULATE_MAX_REQUIREMENTS;
1020
1034
  exports.SIMULATE_MAX_TRACKED_BALANCES = SIMULATE_MAX_TRACKED_BALANCES;
1021
1035
  exports.STATIC_SOL_TYPES = STATIC_SOL_TYPES;
1022
1036
  exports.SettlementZod = SettlementZod;
1037
+ exports.ShortfallZod = ShortfallZod;
1023
1038
  exports.SolTypeSchema = SolTypeSchema;
1024
1039
  exports.StaticSolTypeZod = StaticSolTypeZod;
1025
1040
  exports.TEMPO_CHAIN_ID = TEMPO_CHAIN_ID;
package/dist/index.d.cts CHANGED
@@ -29,19 +29,19 @@ export declare const ResourceSchema: Schema.transform<Schema.Union<[Schema.Struc
29
29
  token: Schema.refine<string, typeof Schema.String>;
30
30
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
31
31
  }>]>, Schema.SchemaClass<{
32
- readonly chainId: number;
33
32
  readonly kind: "native";
34
- } | {
35
- readonly token: string;
36
33
  readonly chainId: number;
34
+ } | {
37
35
  readonly kind: "erc20";
38
- }, {
39
36
  readonly chainId: number;
40
- readonly kind: "native";
41
- } | {
42
37
  readonly token: string;
38
+ }, {
39
+ readonly kind: "native";
43
40
  readonly chainId: number;
41
+ } | {
44
42
  readonly kind: "erc20";
43
+ readonly chainId: number;
44
+ readonly token: string;
45
45
  }, never>>;
46
46
  export declare const ResourceInputSchema: Schema.Struct<{
47
47
  name: typeof Schema.String;
@@ -53,19 +53,19 @@ export declare const ResourceInputSchema: Schema.Struct<{
53
53
  token: Schema.refine<string, typeof Schema.String>;
54
54
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
55
55
  }>]>, Schema.SchemaClass<{
56
- readonly chainId: number;
57
56
  readonly kind: "native";
58
- } | {
59
- readonly token: string;
60
57
  readonly chainId: number;
58
+ } | {
61
59
  readonly kind: "erc20";
62
- }, {
63
60
  readonly chainId: number;
64
- readonly kind: "native";
65
- } | {
66
61
  readonly token: string;
62
+ }, {
63
+ readonly kind: "native";
67
64
  readonly chainId: number;
65
+ } | {
68
66
  readonly kind: "erc20";
67
+ readonly chainId: number;
68
+ readonly token: string;
69
69
  }, never>>;
70
70
  }>;
71
71
  export declare const HandleInputSchema: Schema.Struct<{
@@ -82,19 +82,19 @@ export declare const FlowInputSchema: Schema.Union<[Schema.Struct<{
82
82
  token: Schema.refine<string, typeof Schema.String>;
83
83
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
84
84
  }>]>, Schema.SchemaClass<{
85
- readonly chainId: number;
86
85
  readonly kind: "native";
87
- } | {
88
- readonly token: string;
89
86
  readonly chainId: number;
87
+ } | {
90
88
  readonly kind: "erc20";
91
- }, {
92
89
  readonly chainId: number;
93
- readonly kind: "native";
94
- } | {
95
90
  readonly token: string;
91
+ }, {
92
+ readonly kind: "native";
96
93
  readonly chainId: number;
94
+ } | {
97
95
  readonly kind: "erc20";
96
+ readonly chainId: number;
97
+ readonly token: string;
98
98
  }, never>>;
99
99
  }>, Schema.Struct<{
100
100
  name: typeof Schema.String;
@@ -157,19 +157,19 @@ export declare const EpilogueForwardSchema: Schema.Struct<{
157
157
  token: Schema.refine<string, typeof Schema.String>;
158
158
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
159
159
  }>]>, Schema.SchemaClass<{
160
- readonly chainId: number;
161
160
  readonly kind: "native";
162
- } | {
163
- readonly token: string;
164
161
  readonly chainId: number;
162
+ } | {
165
163
  readonly kind: "erc20";
166
- }, {
167
164
  readonly chainId: number;
168
- readonly kind: "native";
169
- } | {
170
165
  readonly token: string;
166
+ }, {
167
+ readonly kind: "native";
171
168
  readonly chainId: number;
169
+ } | {
172
170
  readonly kind: "erc20";
171
+ readonly chainId: number;
172
+ readonly token: string;
173
173
  }, never>>;
174
174
  to: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
175
175
  $ref: Schema.filter<typeof Schema.String>;
@@ -185,19 +185,19 @@ export declare const EpilogueSchema: Schema.filter<Schema.Struct<{
185
185
  token: Schema.refine<string, typeof Schema.String>;
186
186
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
187
187
  }>]>, Schema.SchemaClass<{
188
- readonly chainId: number;
189
188
  readonly kind: "native";
190
- } | {
191
- readonly token: string;
192
189
  readonly chainId: number;
190
+ } | {
193
191
  readonly kind: "erc20";
194
- }, {
195
192
  readonly chainId: number;
196
- readonly kind: "native";
197
- } | {
198
193
  readonly token: string;
194
+ }, {
195
+ readonly kind: "native";
199
196
  readonly chainId: number;
197
+ } | {
200
198
  readonly kind: "erc20";
199
+ readonly chainId: number;
200
+ readonly token: string;
201
201
  }, never>>;
202
202
  to: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
203
203
  $ref: Schema.filter<typeof Schema.String>;
@@ -221,19 +221,19 @@ export declare const FlowSchema: Schema.Struct<{
221
221
  token: Schema.refine<string, typeof Schema.String>;
222
222
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
223
223
  }>]>, Schema.SchemaClass<{
224
- readonly chainId: number;
225
224
  readonly kind: "native";
226
- } | {
227
- readonly token: string;
228
225
  readonly chainId: number;
226
+ } | {
229
227
  readonly kind: "erc20";
230
- }, {
231
228
  readonly chainId: number;
232
- readonly kind: "native";
233
- } | {
234
229
  readonly token: string;
230
+ }, {
231
+ readonly kind: "native";
235
232
  readonly chainId: number;
233
+ } | {
236
234
  readonly kind: "erc20";
235
+ readonly chainId: number;
236
+ readonly token: string;
237
237
  }, never>>;
238
238
  }>, Schema.Struct<{
239
239
  name: typeof Schema.String;
@@ -274,19 +274,19 @@ export declare const FlowSchema: Schema.Struct<{
274
274
  token: Schema.refine<string, typeof Schema.String>;
275
275
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
276
276
  }>]>, Schema.SchemaClass<{
277
- readonly chainId: number;
278
277
  readonly kind: "native";
279
- } | {
280
- readonly token: string;
281
278
  readonly chainId: number;
279
+ } | {
282
280
  readonly kind: "erc20";
283
- }, {
284
281
  readonly chainId: number;
285
- readonly kind: "native";
286
- } | {
287
282
  readonly token: string;
283
+ }, {
284
+ readonly kind: "native";
288
285
  readonly chainId: number;
286
+ } | {
289
287
  readonly kind: "erc20";
288
+ readonly chainId: number;
289
+ readonly token: string;
290
290
  }, never>>;
291
291
  to: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
292
292
  $ref: Schema.filter<typeof Schema.String>;
@@ -315,68 +315,68 @@ type Flow = typeof FlowSchema.Type;
315
315
  //#region src/continuation.d.ts
316
316
  export declare const CONTINUATION_COMMITMENT_OP_ID = "continuation.commitment";
317
317
  export declare const ContinuationOutcomeSchema: Schema.transform<Schema.Schema<{
318
+ readonly chainId: number;
318
319
  readonly token: string;
319
320
  readonly minAmount?: string | undefined;
320
321
  readonly destination: string;
321
- readonly chainId: number;
322
322
  }, {
323
+ readonly chainId: number;
323
324
  readonly token: string;
324
325
  readonly destination: string;
325
- readonly chainId: number;
326
326
  readonly minAmount?: string | undefined;
327
327
  }, never>, Schema.SchemaClass<{
328
+ readonly chainId: number;
328
329
  readonly token: string;
329
330
  readonly minAmount?: string | undefined;
330
331
  readonly destination: string;
331
- readonly chainId: number;
332
332
  }, {
333
+ readonly chainId: number;
333
334
  readonly token: string;
334
335
  readonly minAmount?: string | undefined;
335
336
  readonly destination: string;
336
- readonly chainId: number;
337
337
  }, never>>;
338
338
  export declare const CommittedOutcomeSchema: Schema.transform<Schema.Schema<{
339
+ readonly chainId: number;
339
340
  readonly token: string;
340
341
  readonly minAmount: string;
341
342
  readonly destination: string;
342
- readonly chainId: number;
343
343
  }, {
344
+ readonly chainId: number;
344
345
  readonly token: string;
345
346
  readonly minAmount: string;
346
347
  readonly destination: string;
347
- readonly chainId: number;
348
348
  }, never>, Schema.SchemaClass<{
349
+ readonly chainId: number;
349
350
  readonly token: string;
350
351
  readonly minAmount: string;
351
352
  readonly destination: string;
352
- readonly chainId: number;
353
353
  }, {
354
+ readonly chainId: number;
354
355
  readonly token: string;
355
356
  readonly minAmount: string;
356
357
  readonly destination: string;
357
- readonly chainId: number;
358
358
  }, never>>;
359
359
  export declare const ContinuationIntentSchema: Schema.Struct<{
360
- outcomes: Schema.NonEmptyArray<Schema.transform<Schema.Schema<{
360
+ outcomes: Schema.Array$<Schema.transform<Schema.Schema<{
361
+ readonly chainId: number;
361
362
  readonly token: string;
362
363
  readonly minAmount?: string | undefined;
363
364
  readonly destination: string;
364
- readonly chainId: number;
365
365
  }, {
366
+ readonly chainId: number;
366
367
  readonly token: string;
367
368
  readonly destination: string;
368
- readonly chainId: number;
369
369
  readonly minAmount?: string | undefined;
370
370
  }, never>, Schema.SchemaClass<{
371
+ readonly chainId: number;
371
372
  readonly token: string;
372
373
  readonly minAmount?: string | undefined;
373
374
  readonly destination: string;
374
- readonly chainId: number;
375
375
  }, {
376
+ readonly chainId: number;
376
377
  readonly token: string;
377
378
  readonly minAmount?: string | undefined;
378
379
  readonly destination: string;
379
- readonly chainId: number;
380
380
  }, never>>>;
381
381
  continuationFlow: Schema.optional<Schema.Struct<{
382
382
  version: Schema.Literal<[1]>;
@@ -392,19 +392,19 @@ export declare const ContinuationIntentSchema: Schema.Struct<{
392
392
  token: Schema.refine<string, typeof Schema.String>;
393
393
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
394
394
  }>]>, Schema.SchemaClass<{
395
- readonly chainId: number;
396
395
  readonly kind: "native";
397
- } | {
398
- readonly token: string;
399
396
  readonly chainId: number;
397
+ } | {
400
398
  readonly kind: "erc20";
401
- }, {
402
399
  readonly chainId: number;
403
- readonly kind: "native";
404
- } | {
405
400
  readonly token: string;
401
+ }, {
402
+ readonly kind: "native";
406
403
  readonly chainId: number;
404
+ } | {
407
405
  readonly kind: "erc20";
406
+ readonly chainId: number;
407
+ readonly token: string;
408
408
  }, never>>;
409
409
  }>, Schema.Struct<{
410
410
  name: typeof Schema.String;
@@ -445,19 +445,19 @@ export declare const ContinuationIntentSchema: Schema.Struct<{
445
445
  token: Schema.refine<string, typeof Schema.String>;
446
446
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
447
447
  }>]>, Schema.SchemaClass<{
448
- readonly chainId: number;
449
448
  readonly kind: "native";
450
- } | {
451
- readonly token: string;
452
449
  readonly chainId: number;
450
+ } | {
453
451
  readonly kind: "erc20";
454
- }, {
455
452
  readonly chainId: number;
456
- readonly kind: "native";
457
- } | {
458
453
  readonly token: string;
454
+ }, {
455
+ readonly kind: "native";
459
456
  readonly chainId: number;
457
+ } | {
460
458
  readonly kind: "erc20";
459
+ readonly chainId: number;
460
+ readonly token: string;
461
461
  }, never>>;
462
462
  to: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
463
463
  $ref: Schema.filter<typeof Schema.String>;
@@ -564,8 +564,8 @@ type Phase1Artifact = typeof Phase1ArtifactSchema.Type;
564
564
  type AssertionSpec = typeof AssertionSpecSchema.Type;
565
565
  type CallCheckSpec = typeof CallCheckSpecSchema.Type;
566
566
  export declare const settledOutcome: <I extends {
567
- readonly outcomes: readonly [unknown, ...unknown[]];
568
- }>(intent: I) => I["outcomes"][0];
567
+ readonly outcomes: readonly unknown[];
568
+ }>(intent: I) => I["outcomes"][number] | undefined;
569
569
  //#endregion
570
570
  //#region src/descriptor.d.ts
571
571
  export declare const Bytes32HexSchema: Schema.filter<typeof Schema.String>;
@@ -589,38 +589,38 @@ export declare const AssertedPredicateSchema: Schema.transformOrFail<Schema.Unio
589
589
  comparator: Schema.Literal<["gte", "eq", "lte"]>;
590
590
  threshold: Schema.filter<typeof Schema.String>;
591
591
  }>]>, Schema.SchemaClass<{
592
- readonly minAmount: string;
593
- readonly chainId: number;
594
592
  readonly kind: "nativeBalanceGte";
593
+ readonly chainId: number;
594
+ readonly minAmount: string;
595
595
  readonly owner: string;
596
596
  } | {
597
+ readonly kind: "erc20BalanceGte";
598
+ readonly chainId: number;
597
599
  readonly token: string;
598
600
  readonly minAmount: string;
599
- readonly chainId: number;
600
- readonly kind: "erc20BalanceGte";
601
601
  readonly owner: string;
602
602
  } | {
603
- readonly chainId: number;
604
603
  readonly kind: "call";
604
+ readonly chainId: number;
605
605
  readonly to: string;
606
606
  readonly signature: string;
607
607
  readonly args: readonly string[];
608
608
  readonly comparator: "gte" | "eq" | "lte";
609
609
  readonly threshold: string;
610
610
  }, {
611
- readonly minAmount: string;
612
- readonly chainId: number;
613
611
  readonly kind: "nativeBalanceGte";
612
+ readonly chainId: number;
613
+ readonly minAmount: string;
614
614
  readonly owner: string;
615
615
  } | {
616
+ readonly kind: "erc20BalanceGte";
617
+ readonly chainId: number;
616
618
  readonly token: string;
617
619
  readonly minAmount: string;
618
- readonly chainId: number;
619
- readonly kind: "erc20BalanceGte";
620
620
  readonly owner: string;
621
621
  } | {
622
- readonly chainId: number;
623
622
  readonly kind: "call";
623
+ readonly chainId: number;
624
624
  readonly to: string;
625
625
  readonly signature: string;
626
626
  readonly args: readonly string[];
@@ -650,38 +650,38 @@ export declare const VerificationDescriptorSchema: Schema.Struct<{
650
650
  comparator: Schema.Literal<["gte", "eq", "lte"]>;
651
651
  threshold: Schema.filter<typeof Schema.String>;
652
652
  }>]>, Schema.SchemaClass<{
653
- readonly minAmount: string;
654
- readonly chainId: number;
655
653
  readonly kind: "nativeBalanceGte";
654
+ readonly chainId: number;
655
+ readonly minAmount: string;
656
656
  readonly owner: string;
657
657
  } | {
658
+ readonly kind: "erc20BalanceGte";
659
+ readonly chainId: number;
658
660
  readonly token: string;
659
661
  readonly minAmount: string;
660
- readonly chainId: number;
661
- readonly kind: "erc20BalanceGte";
662
662
  readonly owner: string;
663
663
  } | {
664
- readonly chainId: number;
665
664
  readonly kind: "call";
665
+ readonly chainId: number;
666
666
  readonly to: string;
667
667
  readonly signature: string;
668
668
  readonly args: readonly string[];
669
669
  readonly comparator: "gte" | "eq" | "lte";
670
670
  readonly threshold: string;
671
671
  }, {
672
- readonly minAmount: string;
673
- readonly chainId: number;
674
672
  readonly kind: "nativeBalanceGte";
673
+ readonly chainId: number;
674
+ readonly minAmount: string;
675
675
  readonly owner: string;
676
676
  } | {
677
+ readonly kind: "erc20BalanceGte";
678
+ readonly chainId: number;
677
679
  readonly token: string;
678
680
  readonly minAmount: string;
679
- readonly chainId: number;
680
- readonly kind: "erc20BalanceGte";
681
681
  readonly owner: string;
682
682
  } | {
683
- readonly chainId: number;
684
683
  readonly kind: "call";
684
+ readonly chainId: number;
685
685
  readonly to: string;
686
686
  readonly signature: string;
687
687
  readonly args: readonly string[];
@@ -1461,6 +1461,10 @@ export declare const SettlementZod: z.ZodObject<{
1461
1461
  }, z.core.$strip>>>;
1462
1462
  }, z.core.$strip>>;
1463
1463
  }, z.core.$strip>;
1464
+ export declare const ShortfallZod: z.ZodObject<{
1465
+ required: z.ZodString;
1466
+ available: z.ZodString;
1467
+ }, z.core.$strip>;
1464
1468
  type ResourcePort = z.infer<typeof ResourcePortZod>;
1465
1469
  type HandlePort = z.infer<typeof HandlePortZod>;
1466
1470
  type HandleUnits = z.infer<typeof HandleUnitsZod>;
@@ -1479,6 +1483,7 @@ type ComposeManifest = z.infer<typeof ComposeManifestZod>;
1479
1483
  type SettlementEscrowWire = z.infer<typeof SettlementEscrowZod>;
1480
1484
  type SettlementBindingWire = z.infer<typeof SettlementBindingZod>;
1481
1485
  type SettlementWire = z.infer<typeof SettlementZod>;
1486
+ type Shortfall = z.infer<typeof ShortfallZod>;
1482
1487
  //#endregion
1483
1488
  //#region src/compile.d.ts
1484
1489
  type SimulationPolicy = 'strict' | 'allow-revert';
@@ -1653,12 +1658,14 @@ interface FailedPreparedOp {
1653
1658
  readonly path?: string;
1654
1659
  readonly port?: string;
1655
1660
  readonly fix?: string;
1661
+ readonly shortfall?: Shortfall;
1656
1662
  }
1657
1663
  interface ComposeErrorBase {
1658
1664
  readonly message: string;
1659
1665
  readonly path?: string;
1660
1666
  readonly port?: string;
1661
1667
  readonly fix?: string;
1668
+ readonly shortfall?: Shortfall;
1662
1669
  }
1663
1670
  interface PreparationComposeError extends ComposeErrorBase {
1664
1671
  readonly kind: 'preparation_error';
@@ -2234,10 +2241,36 @@ type NativeBalanceRequirement = NativeBalancePrecondition;
2234
2241
  /** Funding instruction: seed an ERC-20 allowance before simulation. */
2235
2242
  type Erc20AllowanceRequirement = Erc20AllowancePrecondition;
2236
2243
  /**
2237
- * The funding-instruction union applied before a simulation. Three variants,
2244
+ * Funding instruction: seed a Uniswap Permit2 `AllowanceTransfer` allowance
2245
+ * before simulation, so a `Permit2.transferFrom(owner, _, amount, token)` sent
2246
+ * by `spender` passes Permit2's own check.
2247
+ *
2248
+ * slot-finder writes two overrides: Permit2's `allowance[owner][token][spender]`
2249
+ * (no expiry, the owner's live nonce kept) and the ERC-20 allowance
2250
+ * `owner` → Permit2 that the pull spends. It does not fund the owner's token
2251
+ * balance: add an `Erc20Balance` for that. Only the canonical Permit2 address
2252
+ * `0x000000000022D473030F116dDEE9F6B43aC78BA3` is supported; on a chain
2253
+ * without code there the simulation answers HTTP 422.
2254
+ *
2255
+ * Unlike the other variants this is not a compile precondition: no op declares
2256
+ * a Permit2 allowance, so only a `POST /simulate` caller sends one.
2257
+ */
2258
+ type Permit2AllowanceRequirement = {
2259
+ readonly type: 'Permit2Allowance';
2260
+ /** Address whose tokens Permit2 pulls. */
2261
+ readonly owner: string;
2262
+ /** ERC-20 token Permit2 pulls. */
2263
+ readonly token: string;
2264
+ /** Address that calls `Permit2.transferFrom`. */
2265
+ readonly spender: string;
2266
+ /** Permit2 allowance amount, in the token's base units. */
2267
+ readonly amount: bigint | string;
2268
+ };
2269
+ /**
2270
+ * The funding-instruction union applied before a simulation. Four variants,
2238
2271
  * discriminated by `type`.
2239
2272
  */
2240
- type SlotFinderRequirement = Erc20BalanceRequirement | NativeBalanceRequirement | Erc20AllowanceRequirement;
2273
+ type SlotFinderRequirement = Erc20BalanceRequirement | NativeBalanceRequirement | Erc20AllowanceRequirement | Permit2AllowanceRequirement;
2241
2274
  /** Request body for `POST /simulate`. */
2242
2275
  interface SimulateRequest {
2243
2276
  /** EVM chain id. */
@@ -2415,4 +2448,4 @@ export declare const foldMaterialiserMetadata: <R>(meta: MaterialiserMetadata, c
2415
2448
  readonly runtime: (min: bigint | undefined) => R;
2416
2449
  }) => R;
2417
2450
  //#endregion
2418
- export type { Amount, AppliedGuard, ApprovalEntry, AssertedPredicate, AssertionOwner, AssertionSpec, AssertionSpecWire, Availability, BindValue, Call, CallCheckSpec, ChainCapabilities, CommittedOutcome, ComposeAction, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeError, ComposeErrorKind, ComposeFill, ComposeManifest, ComposeRouteErrorKind, ComposeRouteRequest, ComposeRun, ComposeTransactionRequest, ComposeUserProgramSimulation, ComposeVersion, ComposeWarning, ConsumedOutput, ContextKey, ContinuationIntent, ContinuationOutcome, Delivery, DeliveryComposeError, DeliveryErrorDetails, DeliveryErrorReason, ERC20Resource, Epilogue, EpilogueForward, Erc20AllowancePrecondition, Erc20AllowanceRequirement, Erc20BalancePrecondition, Erc20BalanceRequirement, Estimate, EstimateBasis, ExecutedEpilogue, ExecutedForward, FailedPreparedOp, FlashloanMaterialiserInput, Flow, FlowInput, ForwardTo, GenericComposeError, GenericComposeErrorKind, GuardCompatibility, GuardSelector, HandleInput, HandlePort, HandleUnits, InputSpec, Lineage, LiteralBinding, ManifestGuard, ManifestMaterialiser, ManifestOperation, ManifestPrecondition, ManifestRouting, MaterialiserConfigOf, MaterialiserInput, MaterialiserInputBase, MaterialiserInputOf, MaterialiserMetadata, MaterialiserResolution, Minimum, MinimumBasis, NativeBalancePrecondition, NativeBalanceRequirement, NativeCheckPolicy, NativeErc20, NativeResource, OpInputPort, OpOutputPort, Output, OutputAmount, OutputFamilyPort, Outputs, ParsedRef, Phase1Artifact, Port, Precondition, PreconditionBase, PreconditionConfigOf, PreconditionOf, PreparationComposeError, PriceImpact, ProviderKindName, Ref, RefBuilder, RefPath, RefScope, Resource, ResourceInput, ResourceOutputPort, ResourcePort, RouteAmount, RouteAmountAll, RouteAmountExact, SettlementBindingWire, SettlementEscrowWire, SettlementWire, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SimulationRevertComposeError, SlotFinderRequirement, SolType, SpendEntry, StaticSolType, TerminalOutput, TrackedBalance, VerificationDescriptor, VerificationDescriptorWire, VersionCompatibility };
2451
+ export type { Amount, AppliedGuard, ApprovalEntry, AssertedPredicate, AssertionOwner, AssertionSpec, AssertionSpecWire, Availability, BindValue, Call, CallCheckSpec, ChainCapabilities, CommittedOutcome, ComposeAction, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeError, ComposeErrorKind, ComposeFill, ComposeManifest, ComposeRouteErrorKind, ComposeRouteRequest, ComposeRun, ComposeTransactionRequest, ComposeUserProgramSimulation, ComposeVersion, ComposeWarning, ConsumedOutput, ContextKey, ContinuationIntent, ContinuationOutcome, Delivery, DeliveryComposeError, DeliveryErrorDetails, DeliveryErrorReason, ERC20Resource, Epilogue, EpilogueForward, Erc20AllowancePrecondition, Erc20AllowanceRequirement, Erc20BalancePrecondition, Erc20BalanceRequirement, Estimate, EstimateBasis, ExecutedEpilogue, ExecutedForward, FailedPreparedOp, FlashloanMaterialiserInput, Flow, FlowInput, ForwardTo, GenericComposeError, GenericComposeErrorKind, GuardCompatibility, GuardSelector, HandleInput, HandlePort, HandleUnits, InputSpec, Lineage, LiteralBinding, ManifestGuard, ManifestMaterialiser, ManifestOperation, ManifestPrecondition, ManifestRouting, MaterialiserConfigOf, MaterialiserInput, MaterialiserInputBase, MaterialiserInputOf, MaterialiserMetadata, MaterialiserResolution, Minimum, MinimumBasis, NativeBalancePrecondition, NativeBalanceRequirement, NativeCheckPolicy, NativeErc20, NativeResource, OpInputPort, OpOutputPort, Output, OutputAmount, OutputFamilyPort, Outputs, ParsedRef, Permit2AllowanceRequirement, Phase1Artifact, Port, Precondition, PreconditionBase, PreconditionConfigOf, PreconditionOf, PreparationComposeError, PriceImpact, ProviderKindName, Ref, RefBuilder, RefPath, RefScope, Resource, ResourceInput, ResourceOutputPort, ResourcePort, RouteAmount, RouteAmountAll, RouteAmountExact, SettlementBindingWire, SettlementEscrowWire, SettlementWire, Shortfall, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SimulationRevertComposeError, SlotFinderRequirement, SolType, SpendEntry, StaticSolType, TerminalOutput, TrackedBalance, VerificationDescriptor, VerificationDescriptorWire, VersionCompatibility };
package/dist/index.d.ts CHANGED
@@ -29,19 +29,19 @@ export declare const ResourceSchema: Schema.transform<Schema.Union<[Schema.Struc
29
29
  token: Schema.refine<string, typeof Schema.String>;
30
30
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
31
31
  }>]>, Schema.SchemaClass<{
32
- readonly chainId: number;
33
32
  readonly kind: "native";
34
- } | {
35
- readonly token: string;
36
33
  readonly chainId: number;
34
+ } | {
37
35
  readonly kind: "erc20";
38
- }, {
39
36
  readonly chainId: number;
40
- readonly kind: "native";
41
- } | {
42
37
  readonly token: string;
38
+ }, {
39
+ readonly kind: "native";
43
40
  readonly chainId: number;
41
+ } | {
44
42
  readonly kind: "erc20";
43
+ readonly chainId: number;
44
+ readonly token: string;
45
45
  }, never>>;
46
46
  export declare const ResourceInputSchema: Schema.Struct<{
47
47
  name: typeof Schema.String;
@@ -53,19 +53,19 @@ export declare const ResourceInputSchema: Schema.Struct<{
53
53
  token: Schema.refine<string, typeof Schema.String>;
54
54
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
55
55
  }>]>, Schema.SchemaClass<{
56
- readonly chainId: number;
57
56
  readonly kind: "native";
58
- } | {
59
- readonly token: string;
60
57
  readonly chainId: number;
58
+ } | {
61
59
  readonly kind: "erc20";
62
- }, {
63
60
  readonly chainId: number;
64
- readonly kind: "native";
65
- } | {
66
61
  readonly token: string;
62
+ }, {
63
+ readonly kind: "native";
67
64
  readonly chainId: number;
65
+ } | {
68
66
  readonly kind: "erc20";
67
+ readonly chainId: number;
68
+ readonly token: string;
69
69
  }, never>>;
70
70
  }>;
71
71
  export declare const HandleInputSchema: Schema.Struct<{
@@ -82,19 +82,19 @@ export declare const FlowInputSchema: Schema.Union<[Schema.Struct<{
82
82
  token: Schema.refine<string, typeof Schema.String>;
83
83
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
84
84
  }>]>, Schema.SchemaClass<{
85
- readonly chainId: number;
86
85
  readonly kind: "native";
87
- } | {
88
- readonly token: string;
89
86
  readonly chainId: number;
87
+ } | {
90
88
  readonly kind: "erc20";
91
- }, {
92
89
  readonly chainId: number;
93
- readonly kind: "native";
94
- } | {
95
90
  readonly token: string;
91
+ }, {
92
+ readonly kind: "native";
96
93
  readonly chainId: number;
94
+ } | {
97
95
  readonly kind: "erc20";
96
+ readonly chainId: number;
97
+ readonly token: string;
98
98
  }, never>>;
99
99
  }>, Schema.Struct<{
100
100
  name: typeof Schema.String;
@@ -157,19 +157,19 @@ export declare const EpilogueForwardSchema: Schema.Struct<{
157
157
  token: Schema.refine<string, typeof Schema.String>;
158
158
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
159
159
  }>]>, Schema.SchemaClass<{
160
- readonly chainId: number;
161
160
  readonly kind: "native";
162
- } | {
163
- readonly token: string;
164
161
  readonly chainId: number;
162
+ } | {
165
163
  readonly kind: "erc20";
166
- }, {
167
164
  readonly chainId: number;
168
- readonly kind: "native";
169
- } | {
170
165
  readonly token: string;
166
+ }, {
167
+ readonly kind: "native";
171
168
  readonly chainId: number;
169
+ } | {
172
170
  readonly kind: "erc20";
171
+ readonly chainId: number;
172
+ readonly token: string;
173
173
  }, never>>;
174
174
  to: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
175
175
  $ref: Schema.filter<typeof Schema.String>;
@@ -185,19 +185,19 @@ export declare const EpilogueSchema: Schema.filter<Schema.Struct<{
185
185
  token: Schema.refine<string, typeof Schema.String>;
186
186
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
187
187
  }>]>, Schema.SchemaClass<{
188
- readonly chainId: number;
189
188
  readonly kind: "native";
190
- } | {
191
- readonly token: string;
192
189
  readonly chainId: number;
190
+ } | {
193
191
  readonly kind: "erc20";
194
- }, {
195
192
  readonly chainId: number;
196
- readonly kind: "native";
197
- } | {
198
193
  readonly token: string;
194
+ }, {
195
+ readonly kind: "native";
199
196
  readonly chainId: number;
197
+ } | {
200
198
  readonly kind: "erc20";
199
+ readonly chainId: number;
200
+ readonly token: string;
201
201
  }, never>>;
202
202
  to: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
203
203
  $ref: Schema.filter<typeof Schema.String>;
@@ -221,19 +221,19 @@ export declare const FlowSchema: Schema.Struct<{
221
221
  token: Schema.refine<string, typeof Schema.String>;
222
222
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
223
223
  }>]>, Schema.SchemaClass<{
224
- readonly chainId: number;
225
224
  readonly kind: "native";
226
- } | {
227
- readonly token: string;
228
225
  readonly chainId: number;
226
+ } | {
229
227
  readonly kind: "erc20";
230
- }, {
231
228
  readonly chainId: number;
232
- readonly kind: "native";
233
- } | {
234
229
  readonly token: string;
230
+ }, {
231
+ readonly kind: "native";
235
232
  readonly chainId: number;
233
+ } | {
236
234
  readonly kind: "erc20";
235
+ readonly chainId: number;
236
+ readonly token: string;
237
237
  }, never>>;
238
238
  }>, Schema.Struct<{
239
239
  name: typeof Schema.String;
@@ -274,19 +274,19 @@ export declare const FlowSchema: Schema.Struct<{
274
274
  token: Schema.refine<string, typeof Schema.String>;
275
275
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
276
276
  }>]>, Schema.SchemaClass<{
277
- readonly chainId: number;
278
277
  readonly kind: "native";
279
- } | {
280
- readonly token: string;
281
278
  readonly chainId: number;
279
+ } | {
282
280
  readonly kind: "erc20";
283
- }, {
284
281
  readonly chainId: number;
285
- readonly kind: "native";
286
- } | {
287
282
  readonly token: string;
283
+ }, {
284
+ readonly kind: "native";
288
285
  readonly chainId: number;
286
+ } | {
289
287
  readonly kind: "erc20";
288
+ readonly chainId: number;
289
+ readonly token: string;
290
290
  }, never>>;
291
291
  to: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
292
292
  $ref: Schema.filter<typeof Schema.String>;
@@ -315,68 +315,68 @@ type Flow = typeof FlowSchema.Type;
315
315
  //#region src/continuation.d.ts
316
316
  export declare const CONTINUATION_COMMITMENT_OP_ID = "continuation.commitment";
317
317
  export declare const ContinuationOutcomeSchema: Schema.transform<Schema.Schema<{
318
+ readonly chainId: number;
318
319
  readonly token: string;
319
320
  readonly minAmount?: string | undefined;
320
321
  readonly destination: string;
321
- readonly chainId: number;
322
322
  }, {
323
+ readonly chainId: number;
323
324
  readonly token: string;
324
325
  readonly destination: string;
325
- readonly chainId: number;
326
326
  readonly minAmount?: string | undefined;
327
327
  }, never>, Schema.SchemaClass<{
328
+ readonly chainId: number;
328
329
  readonly token: string;
329
330
  readonly minAmount?: string | undefined;
330
331
  readonly destination: string;
331
- readonly chainId: number;
332
332
  }, {
333
+ readonly chainId: number;
333
334
  readonly token: string;
334
335
  readonly minAmount?: string | undefined;
335
336
  readonly destination: string;
336
- readonly chainId: number;
337
337
  }, never>>;
338
338
  export declare const CommittedOutcomeSchema: Schema.transform<Schema.Schema<{
339
+ readonly chainId: number;
339
340
  readonly token: string;
340
341
  readonly minAmount: string;
341
342
  readonly destination: string;
342
- readonly chainId: number;
343
343
  }, {
344
+ readonly chainId: number;
344
345
  readonly token: string;
345
346
  readonly minAmount: string;
346
347
  readonly destination: string;
347
- readonly chainId: number;
348
348
  }, never>, Schema.SchemaClass<{
349
+ readonly chainId: number;
349
350
  readonly token: string;
350
351
  readonly minAmount: string;
351
352
  readonly destination: string;
352
- readonly chainId: number;
353
353
  }, {
354
+ readonly chainId: number;
354
355
  readonly token: string;
355
356
  readonly minAmount: string;
356
357
  readonly destination: string;
357
- readonly chainId: number;
358
358
  }, never>>;
359
359
  export declare const ContinuationIntentSchema: Schema.Struct<{
360
- outcomes: Schema.NonEmptyArray<Schema.transform<Schema.Schema<{
360
+ outcomes: Schema.Array$<Schema.transform<Schema.Schema<{
361
+ readonly chainId: number;
361
362
  readonly token: string;
362
363
  readonly minAmount?: string | undefined;
363
364
  readonly destination: string;
364
- readonly chainId: number;
365
365
  }, {
366
+ readonly chainId: number;
366
367
  readonly token: string;
367
368
  readonly destination: string;
368
- readonly chainId: number;
369
369
  readonly minAmount?: string | undefined;
370
370
  }, never>, Schema.SchemaClass<{
371
+ readonly chainId: number;
371
372
  readonly token: string;
372
373
  readonly minAmount?: string | undefined;
373
374
  readonly destination: string;
374
- readonly chainId: number;
375
375
  }, {
376
+ readonly chainId: number;
376
377
  readonly token: string;
377
378
  readonly minAmount?: string | undefined;
378
379
  readonly destination: string;
379
- readonly chainId: number;
380
380
  }, never>>>;
381
381
  continuationFlow: Schema.optional<Schema.Struct<{
382
382
  version: Schema.Literal<[1]>;
@@ -392,19 +392,19 @@ export declare const ContinuationIntentSchema: Schema.Struct<{
392
392
  token: Schema.refine<string, typeof Schema.String>;
393
393
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
394
394
  }>]>, Schema.SchemaClass<{
395
- readonly chainId: number;
396
395
  readonly kind: "native";
397
- } | {
398
- readonly token: string;
399
396
  readonly chainId: number;
397
+ } | {
400
398
  readonly kind: "erc20";
401
- }, {
402
399
  readonly chainId: number;
403
- readonly kind: "native";
404
- } | {
405
400
  readonly token: string;
401
+ }, {
402
+ readonly kind: "native";
406
403
  readonly chainId: number;
404
+ } | {
407
405
  readonly kind: "erc20";
406
+ readonly chainId: number;
407
+ readonly token: string;
408
408
  }, never>>;
409
409
  }>, Schema.Struct<{
410
410
  name: typeof Schema.String;
@@ -445,19 +445,19 @@ export declare const ContinuationIntentSchema: Schema.Struct<{
445
445
  token: Schema.refine<string, typeof Schema.String>;
446
446
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
447
447
  }>]>, Schema.SchemaClass<{
448
- readonly chainId: number;
449
448
  readonly kind: "native";
450
- } | {
451
- readonly token: string;
452
449
  readonly chainId: number;
450
+ } | {
453
451
  readonly kind: "erc20";
454
- }, {
455
452
  readonly chainId: number;
456
- readonly kind: "native";
457
- } | {
458
453
  readonly token: string;
454
+ }, {
455
+ readonly kind: "native";
459
456
  readonly chainId: number;
457
+ } | {
460
458
  readonly kind: "erc20";
459
+ readonly chainId: number;
460
+ readonly token: string;
461
461
  }, never>>;
462
462
  to: Schema.Union<[Schema.refine<string, typeof Schema.String>, Schema.Struct<{
463
463
  $ref: Schema.filter<typeof Schema.String>;
@@ -564,8 +564,8 @@ type Phase1Artifact = typeof Phase1ArtifactSchema.Type;
564
564
  type AssertionSpec = typeof AssertionSpecSchema.Type;
565
565
  type CallCheckSpec = typeof CallCheckSpecSchema.Type;
566
566
  export declare const settledOutcome: <I extends {
567
- readonly outcomes: readonly [unknown, ...unknown[]];
568
- }>(intent: I) => I["outcomes"][0];
567
+ readonly outcomes: readonly unknown[];
568
+ }>(intent: I) => I["outcomes"][number] | undefined;
569
569
  //#endregion
570
570
  //#region src/descriptor.d.ts
571
571
  export declare const Bytes32HexSchema: Schema.filter<typeof Schema.String>;
@@ -589,38 +589,38 @@ export declare const AssertedPredicateSchema: Schema.transformOrFail<Schema.Unio
589
589
  comparator: Schema.Literal<["gte", "eq", "lte"]>;
590
590
  threshold: Schema.filter<typeof Schema.String>;
591
591
  }>]>, Schema.SchemaClass<{
592
- readonly minAmount: string;
593
- readonly chainId: number;
594
592
  readonly kind: "nativeBalanceGte";
593
+ readonly chainId: number;
594
+ readonly minAmount: string;
595
595
  readonly owner: string;
596
596
  } | {
597
+ readonly kind: "erc20BalanceGte";
598
+ readonly chainId: number;
597
599
  readonly token: string;
598
600
  readonly minAmount: string;
599
- readonly chainId: number;
600
- readonly kind: "erc20BalanceGte";
601
601
  readonly owner: string;
602
602
  } | {
603
- readonly chainId: number;
604
603
  readonly kind: "call";
604
+ readonly chainId: number;
605
605
  readonly to: string;
606
606
  readonly signature: string;
607
607
  readonly args: readonly string[];
608
608
  readonly comparator: "gte" | "eq" | "lte";
609
609
  readonly threshold: string;
610
610
  }, {
611
- readonly minAmount: string;
612
- readonly chainId: number;
613
611
  readonly kind: "nativeBalanceGte";
612
+ readonly chainId: number;
613
+ readonly minAmount: string;
614
614
  readonly owner: string;
615
615
  } | {
616
+ readonly kind: "erc20BalanceGte";
617
+ readonly chainId: number;
616
618
  readonly token: string;
617
619
  readonly minAmount: string;
618
- readonly chainId: number;
619
- readonly kind: "erc20BalanceGte";
620
620
  readonly owner: string;
621
621
  } | {
622
- readonly chainId: number;
623
622
  readonly kind: "call";
623
+ readonly chainId: number;
624
624
  readonly to: string;
625
625
  readonly signature: string;
626
626
  readonly args: readonly string[];
@@ -650,38 +650,38 @@ export declare const VerificationDescriptorSchema: Schema.Struct<{
650
650
  comparator: Schema.Literal<["gte", "eq", "lte"]>;
651
651
  threshold: Schema.filter<typeof Schema.String>;
652
652
  }>]>, Schema.SchemaClass<{
653
- readonly minAmount: string;
654
- readonly chainId: number;
655
653
  readonly kind: "nativeBalanceGte";
654
+ readonly chainId: number;
655
+ readonly minAmount: string;
656
656
  readonly owner: string;
657
657
  } | {
658
+ readonly kind: "erc20BalanceGte";
659
+ readonly chainId: number;
658
660
  readonly token: string;
659
661
  readonly minAmount: string;
660
- readonly chainId: number;
661
- readonly kind: "erc20BalanceGte";
662
662
  readonly owner: string;
663
663
  } | {
664
- readonly chainId: number;
665
664
  readonly kind: "call";
665
+ readonly chainId: number;
666
666
  readonly to: string;
667
667
  readonly signature: string;
668
668
  readonly args: readonly string[];
669
669
  readonly comparator: "gte" | "eq" | "lte";
670
670
  readonly threshold: string;
671
671
  }, {
672
- readonly minAmount: string;
673
- readonly chainId: number;
674
672
  readonly kind: "nativeBalanceGte";
673
+ readonly chainId: number;
674
+ readonly minAmount: string;
675
675
  readonly owner: string;
676
676
  } | {
677
+ readonly kind: "erc20BalanceGte";
678
+ readonly chainId: number;
677
679
  readonly token: string;
678
680
  readonly minAmount: string;
679
- readonly chainId: number;
680
- readonly kind: "erc20BalanceGte";
681
681
  readonly owner: string;
682
682
  } | {
683
- readonly chainId: number;
684
683
  readonly kind: "call";
684
+ readonly chainId: number;
685
685
  readonly to: string;
686
686
  readonly signature: string;
687
687
  readonly args: readonly string[];
@@ -1461,6 +1461,10 @@ export declare const SettlementZod: z.ZodObject<{
1461
1461
  }, z.core.$strip>>>;
1462
1462
  }, z.core.$strip>>;
1463
1463
  }, z.core.$strip>;
1464
+ export declare const ShortfallZod: z.ZodObject<{
1465
+ required: z.ZodString;
1466
+ available: z.ZodString;
1467
+ }, z.core.$strip>;
1464
1468
  type ResourcePort = z.infer<typeof ResourcePortZod>;
1465
1469
  type HandlePort = z.infer<typeof HandlePortZod>;
1466
1470
  type HandleUnits = z.infer<typeof HandleUnitsZod>;
@@ -1479,6 +1483,7 @@ type ComposeManifest = z.infer<typeof ComposeManifestZod>;
1479
1483
  type SettlementEscrowWire = z.infer<typeof SettlementEscrowZod>;
1480
1484
  type SettlementBindingWire = z.infer<typeof SettlementBindingZod>;
1481
1485
  type SettlementWire = z.infer<typeof SettlementZod>;
1486
+ type Shortfall = z.infer<typeof ShortfallZod>;
1482
1487
  //#endregion
1483
1488
  //#region src/compile.d.ts
1484
1489
  type SimulationPolicy = 'strict' | 'allow-revert';
@@ -1653,12 +1658,14 @@ interface FailedPreparedOp {
1653
1658
  readonly path?: string;
1654
1659
  readonly port?: string;
1655
1660
  readonly fix?: string;
1661
+ readonly shortfall?: Shortfall;
1656
1662
  }
1657
1663
  interface ComposeErrorBase {
1658
1664
  readonly message: string;
1659
1665
  readonly path?: string;
1660
1666
  readonly port?: string;
1661
1667
  readonly fix?: string;
1668
+ readonly shortfall?: Shortfall;
1662
1669
  }
1663
1670
  interface PreparationComposeError extends ComposeErrorBase {
1664
1671
  readonly kind: 'preparation_error';
@@ -2234,10 +2241,36 @@ type NativeBalanceRequirement = NativeBalancePrecondition;
2234
2241
  /** Funding instruction: seed an ERC-20 allowance before simulation. */
2235
2242
  type Erc20AllowanceRequirement = Erc20AllowancePrecondition;
2236
2243
  /**
2237
- * The funding-instruction union applied before a simulation. Three variants,
2244
+ * Funding instruction: seed a Uniswap Permit2 `AllowanceTransfer` allowance
2245
+ * before simulation, so a `Permit2.transferFrom(owner, _, amount, token)` sent
2246
+ * by `spender` passes Permit2's own check.
2247
+ *
2248
+ * slot-finder writes two overrides: Permit2's `allowance[owner][token][spender]`
2249
+ * (no expiry, the owner's live nonce kept) and the ERC-20 allowance
2250
+ * `owner` → Permit2 that the pull spends. It does not fund the owner's token
2251
+ * balance: add an `Erc20Balance` for that. Only the canonical Permit2 address
2252
+ * `0x000000000022D473030F116dDEE9F6B43aC78BA3` is supported; on a chain
2253
+ * without code there the simulation answers HTTP 422.
2254
+ *
2255
+ * Unlike the other variants this is not a compile precondition: no op declares
2256
+ * a Permit2 allowance, so only a `POST /simulate` caller sends one.
2257
+ */
2258
+ type Permit2AllowanceRequirement = {
2259
+ readonly type: 'Permit2Allowance';
2260
+ /** Address whose tokens Permit2 pulls. */
2261
+ readonly owner: string;
2262
+ /** ERC-20 token Permit2 pulls. */
2263
+ readonly token: string;
2264
+ /** Address that calls `Permit2.transferFrom`. */
2265
+ readonly spender: string;
2266
+ /** Permit2 allowance amount, in the token's base units. */
2267
+ readonly amount: bigint | string;
2268
+ };
2269
+ /**
2270
+ * The funding-instruction union applied before a simulation. Four variants,
2238
2271
  * discriminated by `type`.
2239
2272
  */
2240
- type SlotFinderRequirement = Erc20BalanceRequirement | NativeBalanceRequirement | Erc20AllowanceRequirement;
2273
+ type SlotFinderRequirement = Erc20BalanceRequirement | NativeBalanceRequirement | Erc20AllowanceRequirement | Permit2AllowanceRequirement;
2241
2274
  /** Request body for `POST /simulate`. */
2242
2275
  interface SimulateRequest {
2243
2276
  /** EVM chain id. */
@@ -2415,4 +2448,4 @@ export declare const foldMaterialiserMetadata: <R>(meta: MaterialiserMetadata, c
2415
2448
  readonly runtime: (min: bigint | undefined) => R;
2416
2449
  }) => R;
2417
2450
  //#endregion
2418
- export type { Amount, AppliedGuard, ApprovalEntry, AssertedPredicate, AssertionOwner, AssertionSpec, AssertionSpecWire, Availability, BindValue, Call, CallCheckSpec, ChainCapabilities, CommittedOutcome, ComposeAction, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeError, ComposeErrorKind, ComposeFill, ComposeManifest, ComposeRouteErrorKind, ComposeRouteRequest, ComposeRun, ComposeTransactionRequest, ComposeUserProgramSimulation, ComposeVersion, ComposeWarning, ConsumedOutput, ContextKey, ContinuationIntent, ContinuationOutcome, Delivery, DeliveryComposeError, DeliveryErrorDetails, DeliveryErrorReason, ERC20Resource, Epilogue, EpilogueForward, Erc20AllowancePrecondition, Erc20AllowanceRequirement, Erc20BalancePrecondition, Erc20BalanceRequirement, Estimate, EstimateBasis, ExecutedEpilogue, ExecutedForward, FailedPreparedOp, FlashloanMaterialiserInput, Flow, FlowInput, ForwardTo, GenericComposeError, GenericComposeErrorKind, GuardCompatibility, GuardSelector, HandleInput, HandlePort, HandleUnits, InputSpec, Lineage, LiteralBinding, ManifestGuard, ManifestMaterialiser, ManifestOperation, ManifestPrecondition, ManifestRouting, MaterialiserConfigOf, MaterialiserInput, MaterialiserInputBase, MaterialiserInputOf, MaterialiserMetadata, MaterialiserResolution, Minimum, MinimumBasis, NativeBalancePrecondition, NativeBalanceRequirement, NativeCheckPolicy, NativeErc20, NativeResource, OpInputPort, OpOutputPort, Output, OutputAmount, OutputFamilyPort, Outputs, ParsedRef, Phase1Artifact, Port, Precondition, PreconditionBase, PreconditionConfigOf, PreconditionOf, PreparationComposeError, PriceImpact, ProviderKindName, Ref, RefBuilder, RefPath, RefScope, Resource, ResourceInput, ResourceOutputPort, ResourcePort, RouteAmount, RouteAmountAll, RouteAmountExact, SettlementBindingWire, SettlementEscrowWire, SettlementWire, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SimulationRevertComposeError, SlotFinderRequirement, SolType, SpendEntry, StaticSolType, TerminalOutput, TrackedBalance, VerificationDescriptor, VerificationDescriptorWire, VersionCompatibility };
2451
+ export type { Amount, AppliedGuard, ApprovalEntry, AssertedPredicate, AssertionOwner, AssertionSpec, AssertionSpecWire, Availability, BindValue, Call, CallCheckSpec, ChainCapabilities, CommittedOutcome, ComposeAction, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeError, ComposeErrorKind, ComposeFill, ComposeManifest, ComposeRouteErrorKind, ComposeRouteRequest, ComposeRun, ComposeTransactionRequest, ComposeUserProgramSimulation, ComposeVersion, ComposeWarning, ConsumedOutput, ContextKey, ContinuationIntent, ContinuationOutcome, Delivery, DeliveryComposeError, DeliveryErrorDetails, DeliveryErrorReason, ERC20Resource, Epilogue, EpilogueForward, Erc20AllowancePrecondition, Erc20AllowanceRequirement, Erc20BalancePrecondition, Erc20BalanceRequirement, Estimate, EstimateBasis, ExecutedEpilogue, ExecutedForward, FailedPreparedOp, FlashloanMaterialiserInput, Flow, FlowInput, ForwardTo, GenericComposeError, GenericComposeErrorKind, GuardCompatibility, GuardSelector, HandleInput, HandlePort, HandleUnits, InputSpec, Lineage, LiteralBinding, ManifestGuard, ManifestMaterialiser, ManifestOperation, ManifestPrecondition, ManifestRouting, MaterialiserConfigOf, MaterialiserInput, MaterialiserInputBase, MaterialiserInputOf, MaterialiserMetadata, MaterialiserResolution, Minimum, MinimumBasis, NativeBalancePrecondition, NativeBalanceRequirement, NativeCheckPolicy, NativeErc20, NativeResource, OpInputPort, OpOutputPort, Output, OutputAmount, OutputFamilyPort, Outputs, ParsedRef, Permit2AllowanceRequirement, Phase1Artifact, Port, Precondition, PreconditionBase, PreconditionConfigOf, PreconditionOf, PreparationComposeError, PriceImpact, ProviderKindName, Ref, RefBuilder, RefPath, RefScope, Resource, ResourceInput, ResourceOutputPort, ResourcePort, RouteAmount, RouteAmountAll, RouteAmountExact, SettlementBindingWire, SettlementEscrowWire, SettlementWire, Shortfall, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SimulationRevertComposeError, SlotFinderRequirement, SolType, SpendEntry, StaticSolType, TerminalOutput, TrackedBalance, VerificationDescriptor, VerificationDescriptorWire, VersionCompatibility };
package/dist/index.js CHANGED
@@ -37,16 +37,26 @@ const ARC_NATIVE_ERC20 = {
37
37
  decimals: 6
38
38
  };
39
39
  const ARC_NATIVE_SCALE = 10n ** BigInt(18 - ARC_NATIVE_ERC20.decimals);
40
- const REGISTRY = /* @__PURE__ */ new Map([[TEMPO_CHAIN_ID, {
41
- kind: "as-erc20",
42
- chainId: TEMPO_CHAIN_ID,
43
- nativeErc20: TEMPO_NATIVE_ERC20
44
- }], [ARC_CHAIN_ID, {
45
- kind: "native-mirrored-erc20",
46
- chainId: ARC_CHAIN_ID,
47
- nativeErc20: ARC_NATIVE_ERC20,
48
- nativeScale: ARC_NATIVE_SCALE
49
- }]]);
40
+ const ARC_TESTNET_CHAIN_ID = 5042002;
41
+ const REGISTRY = /* @__PURE__ */ new Map([
42
+ [TEMPO_CHAIN_ID, {
43
+ kind: "as-erc20",
44
+ chainId: TEMPO_CHAIN_ID,
45
+ nativeErc20: TEMPO_NATIVE_ERC20
46
+ }],
47
+ [ARC_CHAIN_ID, {
48
+ kind: "native-mirrored-erc20",
49
+ chainId: ARC_CHAIN_ID,
50
+ nativeErc20: ARC_NATIVE_ERC20,
51
+ nativeScale: ARC_NATIVE_SCALE
52
+ }],
53
+ [ARC_TESTNET_CHAIN_ID, {
54
+ kind: "native-mirrored-erc20",
55
+ chainId: ARC_TESTNET_CHAIN_ID,
56
+ nativeErc20: ARC_NATIVE_ERC20,
57
+ nativeScale: ARC_NATIVE_SCALE
58
+ }]
59
+ ]);
50
60
  const getChainCapabilities = (chainId) => REGISTRY.get(chainId) ?? {
51
61
  kind: "evm-native",
52
62
  chainId
@@ -299,7 +309,7 @@ const normalizingOutcome = (raw) => Schema.transform(raw, Schema.typeSchema(raw)
299
309
  const ContinuationOutcomeSchema = normalizingOutcome(Schema.Struct(outcomeFields(Schema.optional(IntegerString))));
300
310
  const CommittedOutcomeSchema = normalizingOutcome(Schema.Struct(outcomeFields(IntegerString)));
301
311
  const ContinuationIntentSchema = Schema.Struct({
302
- outcomes: Schema.NonEmptyArray(ContinuationOutcomeSchema),
312
+ outcomes: Schema.Array(ContinuationOutcomeSchema),
303
313
  continuationFlow: Schema.optional(FlowSchema),
304
314
  validity: Schema.Struct({ expiresAtMs: EpochMsSchema }),
305
315
  provider: Schema.optional(Schema.String),
@@ -938,5 +948,9 @@ const SettlementZod = z.object({
938
948
  escrow: SettlementEscrowZod.optional(),
939
949
  binding: SettlementBindingZod.optional()
940
950
  });
951
+ const ShortfallZod = z.object({
952
+ required: z.string(),
953
+ available: z.string()
954
+ });
941
955
  //#endregion
942
- export { ARC_CHAIN_ID, ARC_NATIVE_ERC20, ARC_NATIVE_SCALE, AppliedGuardSchema, AssertedPredicateSchema, AssertionOwnerSchema, AssertionSpecSchema, AssertionSpecZod, BindValueSchema, Bytes32HexSchema, COMPOSER_SDK_VERSION_HEADER, COMPOSE_VERSION_HEADER, CONTINUATION_COMMITMENT_OP_ID, CallCheckSpecSchema, CallSchema, CommittedOutcomeSchema, ComposeManifestZod, ContinuationIntentSchema, ContinuationOutcomeSchema, EVMAddressString, EVM_NATIVE_SENTINEL, EpilogueForwardSchema, EpilogueSchema, Erc20BalanceGteSpecSchema, FlowInputSchema, FlowSchema, ForwardToSchema, GuardCompatibilityZod, GuardSelectorZod, HANDLE_UNITS, HandleInputSchema, HandlePortZod, HandleUnitsZod, HexStringSchema, InputPortZod, IntegerString, LineageSchema, LiteralBindingSchema, ManifestGuardZod, ManifestMaterialiserZod, ManifestOperationZod, ManifestPreconditionZod, ManifestRoutingZod, NativeBalanceGteSpecSchema, OutputPortZod, PROVIDER_KIND, Phase1ArtifactSchema, RESERVED_REF_SCOPES, RefSchema, ResourceInputSchema, ResourceOutputPortZod, ResourcePortZod, ResourceSchema, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, STATIC_SOL_TYPES, SettlementZod, SolTypeSchema, StaticSolTypeZod, TEMPO_CHAIN_ID, TEMPO_NATIVE_ERC20, UuidSchema, VerificationDescriptorSchema, VerificationDescriptorZod, canonicalAssertedPredicate, canonicalNativeAddress, checkCompatibility, copy, erc20, erc20Allowance, erc20Balance, erc20Resource, erc20Token, expandOutputPorts, familySize, flowInputMode, flowInputResource, flowInputType, foldChainCapabilities, foldMaterialiserMetadata, foldRef, foldResource, getChainCapabilities, handle, hasErc20CanonicalNative, instancePortName, isAsErc20Chain, isContextKey, isERC20Resource, isErc20AllowancePrecondition, isErc20BalancePrecondition, isFutureResourceOutput, isHandlePort, isMaterialiserInput, isMsgValueNative, isNativeAddressForChain, isNativeBalancePrecondition, isNativeResource, isOutputFamily, isRef, isResourceInput, isResourceOutputPort, isResourcePort, isStaticSolType, linear, native, nativeBalance, nativeCheckPolicy, nativeResource, normalizeNativeTokenAddress, normalizeResource, opHandle, parseRef, parseVersion, providerKindByName, providerKindNames, readResource, ref, refKey, resource, resourceKey, resourceOutput, resourceToken, resourcesEqual, settledOutcome };
956
+ export { ARC_CHAIN_ID, ARC_NATIVE_ERC20, ARC_NATIVE_SCALE, AppliedGuardSchema, AssertedPredicateSchema, AssertionOwnerSchema, AssertionSpecSchema, AssertionSpecZod, BindValueSchema, Bytes32HexSchema, COMPOSER_SDK_VERSION_HEADER, COMPOSE_VERSION_HEADER, CONTINUATION_COMMITMENT_OP_ID, CallCheckSpecSchema, CallSchema, CommittedOutcomeSchema, ComposeManifestZod, ContinuationIntentSchema, ContinuationOutcomeSchema, EVMAddressString, EVM_NATIVE_SENTINEL, EpilogueForwardSchema, EpilogueSchema, Erc20BalanceGteSpecSchema, FlowInputSchema, FlowSchema, ForwardToSchema, GuardCompatibilityZod, GuardSelectorZod, HANDLE_UNITS, HandleInputSchema, HandlePortZod, HandleUnitsZod, HexStringSchema, InputPortZod, IntegerString, LineageSchema, LiteralBindingSchema, ManifestGuardZod, ManifestMaterialiserZod, ManifestOperationZod, ManifestPreconditionZod, ManifestRoutingZod, NativeBalanceGteSpecSchema, OutputPortZod, PROVIDER_KIND, Phase1ArtifactSchema, RESERVED_REF_SCOPES, RefSchema, ResourceInputSchema, ResourceOutputPortZod, ResourcePortZod, ResourceSchema, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, STATIC_SOL_TYPES, SettlementZod, ShortfallZod, SolTypeSchema, StaticSolTypeZod, TEMPO_CHAIN_ID, TEMPO_NATIVE_ERC20, UuidSchema, VerificationDescriptorSchema, VerificationDescriptorZod, canonicalAssertedPredicate, canonicalNativeAddress, checkCompatibility, copy, erc20, erc20Allowance, erc20Balance, erc20Resource, erc20Token, expandOutputPorts, familySize, flowInputMode, flowInputResource, flowInputType, foldChainCapabilities, foldMaterialiserMetadata, foldRef, foldResource, getChainCapabilities, handle, hasErc20CanonicalNative, instancePortName, isAsErc20Chain, isContextKey, isERC20Resource, isErc20AllowancePrecondition, isErc20BalancePrecondition, isFutureResourceOutput, isHandlePort, isMaterialiserInput, isMsgValueNative, isNativeAddressForChain, isNativeBalancePrecondition, isNativeResource, isOutputFamily, isRef, isResourceInput, isResourceOutputPort, isResourcePort, isStaticSolType, linear, native, nativeBalance, nativeCheckPolicy, nativeResource, normalizeNativeTokenAddress, normalizeResource, opHandle, parseRef, parseVersion, providerKindByName, providerKindNames, readResource, ref, refKey, resource, resourceKey, resourceOutput, resourceToken, resourcesEqual, settledOutcome };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/compose-spec",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "Public wire-format types and schemas for Compose flows",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -99,6 +99,10 @@ export const ARC_NATIVE_ERC20: NativeErc20 = {
99
99
  // the scale silently wrong. Native wei is 18-decimal at the EVM level.
100
100
  export const ARC_NATIVE_SCALE = 10n ** BigInt(18 - ARC_NATIVE_ERC20.decimals);
101
101
 
102
+ // Arc Testnet runs the same USDC facade at the same address, so it reuses
103
+ // Arc's facts rather than carrying a second copy.
104
+ export const ARC_TESTNET_CHAIN_ID = 5042002;
105
+
102
106
  const REGISTRY: ReadonlyMap<number, ChainCapabilities> = new Map<
103
107
  number,
104
108
  ChainCapabilities
@@ -120,6 +124,15 @@ const REGISTRY: ReadonlyMap<number, ChainCapabilities> = new Map<
120
124
  nativeScale: ARC_NATIVE_SCALE,
121
125
  },
122
126
  ],
127
+ [
128
+ ARC_TESTNET_CHAIN_ID,
129
+ {
130
+ kind: 'native-mirrored-erc20',
131
+ chainId: ARC_TESTNET_CHAIN_ID,
132
+ nativeErc20: ARC_NATIVE_ERC20,
133
+ nativeScale: ARC_NATIVE_SCALE,
134
+ },
135
+ ],
123
136
  ]);
124
137
 
125
138
  /**
@@ -91,8 +91,11 @@ export const CommittedOutcomeSchema = normalizingOutcome(
91
91
  // pointer. `FlowSchema` lives in the same package, so importing it here keeps
92
92
  // `compose-spec` dependency-free.
93
93
  export const ContinuationIntentSchema = Schema.Struct({
94
- // `NonEmptyArray` enforces ≥1 outcome at the parse boundary, so downstream needs no guard.
95
- outcomes: Schema.NonEmptyArray(ContinuationOutcomeSchema),
94
+ // Zero outcomes are admitted only for an exact settle, whose bound leg is its
95
+ // only enforcement; compose-core's first two capability gates
96
+ // (`resolveContinuationProvider.ts:CAPABILITY_CHECKS`) enforce that pairing
97
+ // and the one-outcome maximum, since the schema cannot see `exact`.
98
+ outcomes: Schema.Array(ContinuationOutcomeSchema),
96
99
  continuationFlow: Schema.optional(FlowSchema),
97
100
  validity: Schema.Struct({ expiresAtMs: EpochMsSchema }),
98
101
  provider: Schema.optional(Schema.String),
@@ -338,12 +341,14 @@ export type CallCheckSpec = typeof CallCheckSpecSchema.Type;
338
341
  // The outcome a `continuation.settle` node's single `output` port stands for.
339
342
  // The wire format admits several outcomes, but the op produces one resource,
340
343
  // discloses one owner, and every shipped provider rejects a multi-outcome
341
- // intent, so the first outcome is the settled one everywhere. `NonEmptyArray`
342
- // makes `[0]` present by construction. Keep this the only place that picks
343
- // it: a multi-outcome design changes one accessor, not a scatter of `[0]`s.
344
- // Generic over the intent so a `CommittedIntent` yields a `CommittedOutcome`.
344
+ // intent, so the first outcome is the settled one everywhere. `undefined`
345
+ // means a zero-outcome exact settle: the bound leg consumes the funding and
346
+ // delivers nothing, so the `output` port carries no resource. Keep this the
347
+ // only place that picks `[0]`: a multi-outcome design changes one accessor,
348
+ // not a scatter of `[0]`s. Generic over the intent so a `CommittedIntent`
349
+ // yields a `CommittedOutcome`.
345
350
  export const settledOutcome = <
346
- I extends { readonly outcomes: readonly [unknown, ...unknown[]] },
351
+ I extends { readonly outcomes: readonly unknown[] },
347
352
  >(
348
353
  intent: I,
349
- ): I['outcomes'][0] => intent.outcomes[0];
354
+ ): I['outcomes'][number] | undefined => intent.outcomes[0];
package/src/flow.ts CHANGED
@@ -7,6 +7,7 @@ import type {
7
7
  OpOutputPort,
8
8
  ResourceOutputPort,
9
9
  ResourcePort,
10
+ Shortfall,
10
11
  } from './zodSchemas.js';
11
12
 
12
13
  export type {
@@ -114,6 +115,7 @@ export interface FailedPreparedOp {
114
115
  readonly path?: string;
115
116
  readonly port?: string;
116
117
  readonly fix?: string;
118
+ readonly shortfall?: Shortfall;
117
119
  }
118
120
 
119
121
  // `path` names the node the rejection is about, `port` the bound input port
@@ -121,12 +123,14 @@ export interface FailedPreparedOp {
121
123
  // that clears it. A `continuation.settle` authoring rejection carries `path`
122
124
  // and `fix`, plus `port` when it is about a bind; other `validation_error`s may
123
125
  // omit `fix`. A deployment or internal fault carries none of the three, because
124
- // no edit to the flow clears it.
126
+ // no edit to the flow clears it. `shortfall` is present when the cause is an
127
+ // amount that cannot cover what a step needs (see `ShortfallZod`).
125
128
  interface ComposeErrorBase {
126
129
  readonly message: string;
127
130
  readonly path?: string;
128
131
  readonly port?: string;
129
132
  readonly fix?: string;
133
+ readonly shortfall?: Shortfall;
130
134
  }
131
135
 
132
136
  export interface PreparationComposeError extends ComposeErrorBase {
package/src/index.ts CHANGED
@@ -256,6 +256,7 @@ export type {
256
256
  Erc20BalanceRequirement,
257
257
  NativeBalanceRequirement,
258
258
  Erc20AllowanceRequirement,
259
+ Permit2AllowanceRequirement,
259
260
  SlotFinderRequirement,
260
261
  SimulateRequest,
261
262
  SimulateBalanceEntry,
@@ -315,6 +316,7 @@ export {
315
316
  GuardSelectorZod,
316
317
  GuardCompatibilityZod,
317
318
  SettlementZod,
319
+ ShortfallZod,
318
320
  AssertionSpecZod,
319
321
  VerificationDescriptorZod,
320
322
  } from './zodSchemas.js';
@@ -324,6 +326,7 @@ export type {
324
326
  SettlementWire,
325
327
  SettlementEscrowWire,
326
328
  SettlementBindingWire,
329
+ Shortfall,
327
330
  AssertionSpecWire,
328
331
  VerificationDescriptorWire,
329
332
  } from './zodSchemas.js';
package/src/simulate.ts CHANGED
@@ -67,13 +67,41 @@ export type NativeBalanceRequirement = NativeBalancePrecondition;
67
67
  export type Erc20AllowanceRequirement = Erc20AllowancePrecondition;
68
68
 
69
69
  /**
70
- * The funding-instruction union applied before a simulation. Three variants,
70
+ * Funding instruction: seed a Uniswap Permit2 `AllowanceTransfer` allowance
71
+ * before simulation, so a `Permit2.transferFrom(owner, _, amount, token)` sent
72
+ * by `spender` passes Permit2's own check.
73
+ *
74
+ * slot-finder writes two overrides: Permit2's `allowance[owner][token][spender]`
75
+ * (no expiry, the owner's live nonce kept) and the ERC-20 allowance
76
+ * `owner` → Permit2 that the pull spends. It does not fund the owner's token
77
+ * balance: add an `Erc20Balance` for that. Only the canonical Permit2 address
78
+ * `0x000000000022D473030F116dDEE9F6B43aC78BA3` is supported; on a chain
79
+ * without code there the simulation answers HTTP 422.
80
+ *
81
+ * Unlike the other variants this is not a compile precondition: no op declares
82
+ * a Permit2 allowance, so only a `POST /simulate` caller sends one.
83
+ */
84
+ export type Permit2AllowanceRequirement = {
85
+ readonly type: 'Permit2Allowance';
86
+ /** Address whose tokens Permit2 pulls. */
87
+ readonly owner: string;
88
+ /** ERC-20 token Permit2 pulls. */
89
+ readonly token: string;
90
+ /** Address that calls `Permit2.transferFrom`. */
91
+ readonly spender: string;
92
+ /** Permit2 allowance amount, in the token's base units. */
93
+ readonly amount: bigint | string;
94
+ };
95
+
96
+ /**
97
+ * The funding-instruction union applied before a simulation. Four variants,
71
98
  * discriminated by `type`.
72
99
  */
73
100
  export type SlotFinderRequirement =
74
101
  | Erc20BalanceRequirement
75
102
  | NativeBalanceRequirement
76
- | Erc20AllowanceRequirement;
103
+ | Erc20AllowanceRequirement
104
+ | Permit2AllowanceRequirement;
77
105
 
78
106
  /** Request body for `POST /simulate`. */
79
107
  export interface SimulateRequest {
package/src/zodSchemas.ts CHANGED
@@ -308,6 +308,16 @@ export const SettlementZod = z.object({
308
308
  binding: SettlementBindingZod.optional(),
309
309
  });
310
310
 
311
+ // An amount that cannot cover what a step needs, carried by a compose error
312
+ // whose cause is that gap: `required` is the least amount that would clear
313
+ // the step, `available` the amount the flow had, both decimal strings in the
314
+ // token's units. The one schema for the field: api-schemas declares it on
315
+ // every error body that can carry it, the SDK parses it with it.
316
+ export const ShortfallZod = z.object({
317
+ required: z.string(),
318
+ available: z.string(),
319
+ });
320
+
311
321
  export type ResourcePort = z.infer<typeof ResourcePortZod>;
312
322
  export type HandlePort = z.infer<typeof HandlePortZod>;
313
323
  export type HandleUnits = z.infer<typeof HandleUnitsZod>;
@@ -326,3 +336,4 @@ export type ComposeManifest = z.infer<typeof ComposeManifestZod>;
326
336
  export type SettlementEscrowWire = z.infer<typeof SettlementEscrowZod>;
327
337
  export type SettlementBindingWire = z.infer<typeof SettlementBindingZod>;
328
338
  export type SettlementWire = z.infer<typeof SettlementZod>;
339
+ export type Shortfall = z.infer<typeof ShortfallZod>;