@lifi/composer-sdk 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +36 -4
  2. package/dist/authoring/raw.cjs +21 -8
  3. package/dist/authoring/raw.cjs.map +1 -1
  4. package/dist/authoring/raw.d.cts +21 -8
  5. package/dist/authoring/raw.d.ts +21 -8
  6. package/dist/authoring/raw.js +21 -8
  7. package/dist/authoring/raw.js.map +1 -1
  8. package/dist/authoring/signatureArgs.cjs +10 -3
  9. package/dist/authoring/signatureArgs.cjs.map +1 -1
  10. package/dist/authoring/signatureArgs.d.cts +23 -16
  11. package/dist/authoring/signatureArgs.d.ts +23 -16
  12. package/dist/authoring/signatureArgs.js +10 -3
  13. package/dist/authoring/signatureArgs.js.map +1 -1
  14. package/dist/client.cjs +11 -1
  15. package/dist/client.cjs.map +1 -1
  16. package/dist/client.js +11 -1
  17. package/dist/client.js.map +1 -1
  18. package/dist/errors.cjs +35 -13
  19. package/dist/errors.cjs.map +1 -1
  20. package/dist/errors.d.cts +19 -1
  21. package/dist/errors.d.ts +19 -1
  22. package/dist/errors.js +35 -14
  23. package/dist/errors.js.map +1 -1
  24. package/dist/generated/config.generated.d.cts +98 -2
  25. package/dist/generated/config.generated.d.ts +98 -2
  26. package/dist/generated/operations.generated.cjs +10 -0
  27. package/dist/generated/operations.generated.cjs.map +1 -1
  28. package/dist/generated/operations.generated.d.cts +57 -2
  29. package/dist/generated/operations.generated.d.ts +57 -2
  30. package/dist/generated/operations.generated.js +10 -0
  31. package/dist/generated/operations.generated.js.map +1 -1
  32. package/dist/index.cjs +1 -0
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +4 -4
  35. package/dist/index.d.ts +4 -4
  36. package/dist/index.js +2 -2
  37. package/dist/index.js.map +1 -1
  38. package/dist/outputs.cjs +3 -2
  39. package/dist/outputs.cjs.map +1 -1
  40. package/dist/outputs.d.cts +3 -2
  41. package/dist/outputs.d.ts +3 -2
  42. package/dist/outputs.js +3 -2
  43. package/dist/outputs.js.map +1 -1
  44. package/dist/responseSchemas.cjs.map +1 -1
  45. package/dist/responseSchemas.d.cts +2 -2
  46. package/dist/responseSchemas.d.ts +2 -2
  47. package/dist/responseSchemas.js.map +1 -1
  48. package/dist/run/inputs.cjs +0 -1
  49. package/dist/run/inputs.cjs.map +1 -1
  50. package/dist/run/inputs.d.cts +3 -11
  51. package/dist/run/inputs.d.ts +3 -11
  52. package/dist/run/inputs.js +0 -1
  53. package/dist/run/inputs.js.map +1 -1
  54. package/dist/sdk.cjs +0 -1
  55. package/dist/sdk.cjs.map +1 -1
  56. package/dist/sdk.js +0 -1
  57. package/dist/sdk.js.map +1 -1
  58. package/package.json +2 -2
  59. package/src/authoring/raw.ts +21 -8
  60. package/src/authoring/signatureArgs.ts +53 -23
  61. package/src/client.ts +24 -1
  62. package/src/errors.ts +48 -17
  63. package/src/examples/continuationBridgeSettle.ts +99 -0
  64. package/src/examples/continuationSettle.ts +113 -0
  65. package/src/examples/run.ts +8 -0
  66. package/src/generated/config.generated.ts +111 -2
  67. package/src/generated/operations.generated.ts +99 -1
  68. package/src/index.ts +6 -2
  69. package/src/outputs.ts +3 -2
  70. package/src/responseSchemas.ts +9 -5
  71. package/src/run/inputs.ts +3 -12
  72. package/src/sdk.ts +0 -1
  73. package/src/examples/swapWithFee.ts +0 -59
@@ -16,6 +16,8 @@
16
16
  * approve-deposit — approve vault allowance then deposit USDC
17
17
  * consolidate — consolidate ERC-20 balances to USDC
18
18
  * consolidate-eth — consolidate ERC-20 balances to native ETH
19
+ * continuation-settle — swap USDC to WETH on Base, escrow it for a deferred settlement
20
+ * continuation-bridge-settle — bridge Arbitrum USDC into a Base settlement escrow
19
21
  * deposit-proxy — deposit tokens already on the proxy into Aave
20
22
  * dust-sweep — split USDC 80/20 and sweep leftover dust
21
23
  * swap — swap WETH to USDC via LI.FI
@@ -62,6 +64,8 @@ import { buildRedeemFromVault, buildWrapEth } from './callContract.js';
62
64
  import { API_KEY, BASE_URL, OWNER, PROXY, RECIPIENT } from './config.js';
63
65
  import { buildConsolidateToEth } from './consolidateToEth.js';
64
66
  import { buildConsolidateStablesToUsdc } from './consolidateToUsdc.js';
67
+ import { buildContinuationBridgeSettleExample } from './continuationBridgeSettle.js';
68
+ import { buildContinuationSettleExample } from './continuationSettle.js';
65
69
  import { buildDepositFromProxy } from './depositFromProxy.js';
66
70
  import { buildDustSweepExample } from './dustSweep.js';
67
71
  import { buildFlySwapExample } from './flySwap.js';
@@ -134,6 +138,10 @@ const EXAMPLES: Record<string, () => ComposeCompileRequest> = {
134
138
  usdtAmount: '1000000000',
135
139
  daiAmount: '1000000000000000000000',
136
140
  }).request,
141
+ 'continuation-settle': () =>
142
+ buildContinuationSettleExample({ owner: OWNER }).request,
143
+ 'continuation-bridge-settle': () =>
144
+ buildContinuationBridgeSettleExample({ owner: OWNER }).request,
137
145
  'deposit-proxy': () =>
138
146
  buildDepositFromProxy({
139
147
  owner: OWNER,
@@ -1,6 +1,8 @@
1
1
  // AUTO-GENERATED from manifest.json — do not edit by hand.
2
2
  // Regenerate with: yarn workspace @lifi/composer-sdk generate
3
3
 
4
+ import type { Flow } from '@lifi/compose-spec';
5
+
4
6
  import type { Address, IntegerStringInput } from '../types.js';
5
7
 
6
8
  /**
@@ -253,7 +255,7 @@ export interface LifiBridgeConfig {
253
255
  token: Address;
254
256
  chainId: Positive;
255
257
  };
256
- destination: StartsWith0X;
258
+ destination?: StartsWith0X;
257
259
  slippage?: Between01;
258
260
  timing?: {
259
261
  swapStepTimingStrategies?: {
@@ -1228,7 +1230,7 @@ export interface ParaswapBuyConfig {
1228
1230
  */
1229
1231
  partnerAddress?: string;
1230
1232
  /**
1231
- * Integrator fee in basis points; non-negative integer string capped at 9000.
1233
+ * Paraswap partner fee in basis points; non-negative integer string capped at 9000.
1232
1234
  */
1233
1235
  partnerFeeBps?: string;
1234
1236
  }
@@ -1278,6 +1280,54 @@ export interface FlySwapConfig {
1278
1280
  maxSlippageBps?: Between05000;
1279
1281
  }
1280
1282
 
1283
+ /**
1284
+ * a number between -8640000000000000 and 8640000000000000
1285
+ */
1286
+ export type Between86400000000000008640000000000000 = number;
1287
+
1288
+ export interface ContinuationSettleConfig {
1289
+ /**
1290
+ * @minItems 1
1291
+ */
1292
+ outcomes: [
1293
+ {
1294
+ /**
1295
+ * EVM address: 0x followed by 40 hex characters
1296
+ */
1297
+ token: Address;
1298
+ minAmount?: IntegerStringInput;
1299
+ /**
1300
+ * EVM address: 0x followed by 40 hex characters
1301
+ */
1302
+ destination: Address;
1303
+ chainId: Positive;
1304
+ },
1305
+ ...{
1306
+ /**
1307
+ * EVM address: 0x followed by 40 hex characters
1308
+ */
1309
+ token: Address;
1310
+ minAmount?: IntegerStringInput;
1311
+ /**
1312
+ * EVM address: 0x followed by 40 hex characters
1313
+ */
1314
+ destination: Address;
1315
+ chainId: Positive;
1316
+ }[],
1317
+ ];
1318
+ continuationFlow?: Flow;
1319
+ validity: {
1320
+ expiresAtMs: Between86400000000000008640000000000000;
1321
+ };
1322
+ provider?: string;
1323
+ funding?: 'inline' | 'external';
1324
+ /**
1325
+ * EVM address: 0x followed by 40 hex characters
1326
+ */
1327
+ refund?: Address;
1328
+ exact?: boolean;
1329
+ }
1330
+
1281
1331
  export interface UniswapV2AddLiquidityConfig {
1282
1332
  /**
1283
1333
  * EVM address: 0x followed by 40 hex characters
@@ -1355,6 +1405,64 @@ export interface UniswapV3IncreaseLiquidityConfig {
1355
1405
  tokenId: string;
1356
1406
  }
1357
1407
 
1408
+ /**
1409
+ * a number less than 1
1410
+ */
1411
+ export type LessThan1 = number;
1412
+ /**
1413
+ * a number between 1 and 300
1414
+ */
1415
+ export type Between1300 = number;
1416
+ /**
1417
+ * a number between 0 and 120
1418
+ */
1419
+ export type Between0120 = number;
1420
+
1421
+ export interface LifiIntentsOrderConfig {
1422
+ resourceOut:
1423
+ | {
1424
+ kind: 'native';
1425
+ chainId: Positive;
1426
+ }
1427
+ | {
1428
+ kind: 'erc20';
1429
+ /**
1430
+ * EVM address: 0x followed by 40 hex characters
1431
+ */
1432
+ token: Address;
1433
+ chainId: Positive;
1434
+ };
1435
+ destination?: StartsWith0X;
1436
+ slippage?: LessThan1;
1437
+ validitySeconds?: Between1300;
1438
+ exclusiveSeconds?: Between0120;
1439
+ }
1440
+
1441
+ export interface LifiIntentsRefundConfig {
1442
+ /**
1443
+ * The order id: lifiIntents.order's delivery.trackingId, or topic1 of the escrow's Open log
1444
+ */
1445
+ orderId: string;
1446
+ }
1447
+
1448
+ export interface LifiIntentsAttestNonFillConfig {
1449
+ /**
1450
+ * The order id: lifiIntents.order's delivery.trackingId, or topic1 of the escrow's Open log
1451
+ */
1452
+ orderId: string;
1453
+ }
1454
+
1455
+ export interface LifiIntentsRefundOnNonFillConfig {
1456
+ /**
1457
+ * The order id: lifiIntents.order's delivery.trackingId, or topic1 of the escrow's Open log
1458
+ */
1459
+ orderId: string;
1460
+ /**
1461
+ * The output-chain transaction of lifiIntents.attestNonFill
1462
+ */
1463
+ attestationTxHash: string;
1464
+ }
1465
+
1358
1466
  export interface SlippageGuardConfig {
1359
1467
  port: string;
1360
1468
  bps: Between010000;
@@ -1390,6 +1498,7 @@ export type DirectDepositMaterialiserConfig =
1390
1498
  | {
1391
1499
  allowNonExact: true;
1392
1500
  simAmount?: string;
1501
+ minAmount?: IntegerStringInput;
1393
1502
  };
1394
1503
 
1395
1504
  export interface CallMaterialiserConfig {
@@ -27,6 +27,7 @@ import type {
27
27
  AaveRepayConfig,
28
28
  AaveRepayWithATokensConfig,
29
29
  AaveSetEModeConfig,
30
+ ContinuationSettleConfig,
30
31
  CoreApproveConfig,
31
32
  CoreAsResourceConfig,
32
33
  CoreBalanceOfConfig,
@@ -54,6 +55,10 @@ import type {
54
55
  InvariantNumericConfig,
55
56
  InvariantNumericInRangeConfig,
56
57
  LifiBridgeConfig,
58
+ LifiIntentsAttestNonFillConfig,
59
+ LifiIntentsOrderConfig,
60
+ LifiIntentsRefundConfig,
61
+ LifiIntentsRefundOnNonFillConfig,
57
62
  LifiSwapConfig,
58
63
  LifiZapAsyncConfig,
59
64
  LifiZapConfig,
@@ -431,7 +436,7 @@ export interface CoreTransferArgs {
431
436
  readonly amount: Bindable<'resource'>;
432
437
  readonly recipient: Bindable<'address'>;
433
438
  };
434
- readonly config: CoreTransferConfig;
439
+ readonly config?: CoreTransferConfig;
435
440
  readonly guards?: readonly TypedGuard<'transferred'>[];
436
441
  }
437
442
 
@@ -668,6 +673,15 @@ export interface FlySwapArgs {
668
673
  readonly guards?: readonly TypedGuard<'unspentIn'>[];
669
674
  }
670
675
 
676
+ /** Fund a deferred settlement and commit to a future outcome */
677
+ export interface ContinuationSettleArgs {
678
+ readonly bind: {
679
+ readonly input: Bindable<'resource'>;
680
+ };
681
+ readonly config: ContinuationSettleConfig;
682
+ readonly guards?: readonly TypedGuard<never>[];
683
+ }
684
+
671
685
  /** Deposit two ERC-20 tokens into an existing Uniswap V2 pair (or an ABI-identical fork such as SushiSwap V2) through its Router02 and receive the pair's LP token; unused input returns as residuals. Asserts on chain that the router's factory is `factory`, that the factory's pair for the two tokens is `pair`, and that the pair holds non-zero reserves. Exposes the pool price read before the deposit as `poolPrice`. The deposit is protected only with a `band` guard on `poolPrice` and a `slippage` guard on `liquidity`. Fee-on-transfer tokens are unsupported. */
672
686
  export interface UniswapV2AddLiquidityArgs {
673
687
  readonly bind: {
@@ -715,6 +729,36 @@ export interface UniswapV3IncreaseLiquidityArgs {
715
729
  >[];
716
730
  }
717
731
 
732
+ /** Swap or bridge tokens through a LI.FI Intents order a solver fills */
733
+ export interface LifiIntentsOrderArgs {
734
+ readonly bind: {
735
+ readonly amountIn: Bindable<'resource'>;
736
+ };
737
+ readonly config: LifiIntentsOrderConfig;
738
+ readonly guards?: readonly TypedGuard<'unspentIn'>[];
739
+ }
740
+
741
+ /** Refund a LI.FI Intents escrow order after its expiry. Anyone may call; the escrow pays the order's user. Only an order the order server reports before delivery (status Open or Signed) is refunded. */
742
+ export interface LifiIntentsRefundArgs {
743
+ readonly bind: Record<string, never>;
744
+ readonly config: LifiIntentsRefundConfig;
745
+ readonly guards?: readonly TypedGuard<never>[];
746
+ }
747
+
748
+ /** Step 1 of the early refund of a cross-chain LI.FI Intents order: on the order's output chain, after its fill deadline, record that the output was not filled. Keep the transaction hash for lifiIntents.refundOnNonFill. */
749
+ export interface LifiIntentsAttestNonFillArgs {
750
+ readonly bind: Record<string, never>;
751
+ readonly config: LifiIntentsAttestNonFillConfig;
752
+ readonly guards?: readonly TypedGuard<never>[];
753
+ }
754
+
755
+ /** Step 2 of the early refund of a cross-chain LI.FI Intents order: on the order's input chain, prove the non-fill attestation through Polymer and refund the order's user. A resolution_error means the proof is not ready yet; retry. */
756
+ export interface LifiIntentsRefundOnNonFillArgs {
757
+ readonly bind: Record<string, never>;
758
+ readonly config: LifiIntentsRefundOnNonFillConfig;
759
+ readonly guards?: readonly TypedGuard<never>[];
760
+ }
761
+
718
762
  export interface CoreSplitOutputs {
719
763
  readonly a: OutputHandle<'resource'>;
720
764
  readonly b: OutputHandle<'resource'>;
@@ -872,6 +916,10 @@ export interface FlySwapOutputs {
872
916
  readonly unspentIn: OutputHandle<'resource'>;
873
917
  }
874
918
 
919
+ export interface ContinuationSettleOutputs {
920
+ readonly output: OutputHandle<'resource'>;
921
+ }
922
+
875
923
  export interface UniswapV2AddLiquidityOutputs {
876
924
  readonly liquidity: OutputHandle<'resource'>;
877
925
  readonly residualA: OutputHandle<'resource'>;
@@ -899,6 +947,11 @@ export interface UniswapV3IncreaseLiquidityOutputs {
899
947
  readonly residualB: OutputHandle<'resource'>;
900
948
  }
901
949
 
950
+ export interface LifiIntentsOrderOutputs {
951
+ readonly amountOut: OutputHandle<'resource'>;
952
+ readonly unspentIn: OutputHandle<'resource'>;
953
+ }
954
+
902
955
  export type GeneratedOps = {
903
956
  readonly core: {
904
957
  /** Split a resource into two outputs by basis-point ratio. Output `a` receives `bps` of the source, rounded up, and `b` takes the remainder. — original id: "core.split" */
@@ -1149,6 +1202,13 @@ export type GeneratedOps = {
1149
1202
  args: MorphoBlueGetPositionArgs,
1150
1203
  ) => MorphoBlueGetPositionOutputs;
1151
1204
  };
1205
+ readonly continuation: {
1206
+ /** Fund a deferred settlement and commit to a future outcome — original id: "continuation.settle" */
1207
+ readonly settle: (
1208
+ nodeId: string,
1209
+ args: ContinuationSettleArgs,
1210
+ ) => ContinuationSettleOutputs;
1211
+ };
1152
1212
  readonly paraswap: {
1153
1213
  /** Exact-output (BUY) swap via the Paraswap/Velora Market API: produce exactly `exactAmountOut` of the destination token, pulling only the source needed and exposing the genuinely-unspent source as `unspentIn`. — original id: "paraswap.buy" */
1154
1214
  readonly buy: (nodeId: string, args: ParaswapBuyArgs) => ParaswapBuyOutputs;
@@ -1181,6 +1241,25 @@ export type GeneratedOps = {
1181
1241
  args: UniswapV3IncreaseLiquidityArgs,
1182
1242
  ) => UniswapV3IncreaseLiquidityOutputs;
1183
1243
  };
1244
+ readonly lifiIntents: {
1245
+ /** Swap or bridge tokens through a LI.FI Intents order a solver fills — original id: "lifiIntents.order" */
1246
+ readonly order: (
1247
+ nodeId: string,
1248
+ args: LifiIntentsOrderArgs,
1249
+ ) => LifiIntentsOrderOutputs;
1250
+ /** Refund a LI.FI Intents escrow order after its expiry. Anyone may call; the escrow pays the order's user. Only an order the order server reports before delivery (status Open or Signed) is refunded. — original id: "lifiIntents.refund" */
1251
+ readonly refund: (nodeId: string, args: LifiIntentsRefundArgs) => void;
1252
+ /** Step 1 of the early refund of a cross-chain LI.FI Intents order: on the order's output chain, after its fill deadline, record that the output was not filled. Keep the transaction hash for lifiIntents.refundOnNonFill. — original id: "lifiIntents.attestNonFill" */
1253
+ readonly attestNonFill: (
1254
+ nodeId: string,
1255
+ args: LifiIntentsAttestNonFillArgs,
1256
+ ) => void;
1257
+ /** Step 2 of the early refund of a cross-chain LI.FI Intents order: on the order's input chain, prove the non-fill attestation through Polymer and refund the order's user. A resolution_error means the proof is not ready yet; retry. — original id: "lifiIntents.refundOnNonFill" */
1258
+ readonly refundOnNonFill: (
1259
+ nodeId: string,
1260
+ args: LifiIntentsRefundOnNonFillArgs,
1261
+ ) => void;
1262
+ };
1184
1263
  };
1185
1264
 
1186
1265
  export const bindGeneratedOps = (
@@ -1470,6 +1549,12 @@ export const bindGeneratedOps = (
1470
1549
  collateral: 'uint128',
1471
1550
  } as const),
1472
1551
  },
1552
+ continuation: {
1553
+ settle: (nodeId: string, args: ContinuationSettleArgs) =>
1554
+ builder.call(nodeId, 'continuation.settle', args, {
1555
+ output: 'resource',
1556
+ } as const),
1557
+ },
1473
1558
  paraswap: {
1474
1559
  buy: (nodeId: string, args: ParaswapBuyArgs) =>
1475
1560
  builder.call(nodeId, 'paraswap.buy', args, {
@@ -1515,4 +1600,17 @@ export const bindGeneratedOps = (
1515
1600
  residualB: 'resource',
1516
1601
  } as const),
1517
1602
  },
1603
+ lifiIntents: {
1604
+ order: (nodeId: string, args: LifiIntentsOrderArgs) =>
1605
+ builder.call(nodeId, 'lifiIntents.order', args, {
1606
+ amountOut: 'resource',
1607
+ unspentIn: 'resource',
1608
+ } as const),
1609
+ refund: (nodeId: string, args: LifiIntentsRefundArgs) =>
1610
+ builder.call(nodeId, 'lifiIntents.refund', args, {}),
1611
+ attestNonFill: (nodeId: string, args: LifiIntentsAttestNonFillArgs) =>
1612
+ builder.call(nodeId, 'lifiIntents.attestNonFill', args, {}),
1613
+ refundOnNonFill: (nodeId: string, args: LifiIntentsRefundOnNonFillArgs) =>
1614
+ builder.call(nodeId, 'lifiIntents.refundOnNonFill', args, {}),
1615
+ },
1518
1616
  });
package/src/index.ts CHANGED
@@ -49,8 +49,8 @@ export type {
49
49
  ComposeCompilePartialData,
50
50
  ComposeAction,
51
51
  ComposeFill,
52
- ComposeFee,
53
52
  ComposeUserProgramSimulation,
53
+ ComposeWarning,
54
54
  ComposeCompileRequest,
55
55
  ComposeCompileResult,
56
56
  ComposeCompileSuccessData,
@@ -83,8 +83,10 @@ export type {
83
83
  RouteAmountExact,
84
84
  SimulationPolicy,
85
85
  SimulationRevert,
86
+ DeliveryErrorDetails,
87
+ DeliveryErrorReason,
86
88
  SolType,
87
- SweepTo,
89
+ ForwardTo,
88
90
  SimulateRequest,
89
91
  SimulateResult,
90
92
  SimulateOkResult,
@@ -101,12 +103,14 @@ export type {
101
103
  ContinuationOutcome,
102
104
  SettlementWire,
103
105
  SettlementEscrowWire,
106
+ SettlementBindingWire,
104
107
  } from '@lifi/compose-spec';
105
108
  export {
106
109
  SIMULATE_MAX_TRACKED_BALANCES,
107
110
  SIMULATE_MAX_REQUIREMENTS,
108
111
  } from '@lifi/compose-spec';
109
112
  export {
113
+ isComposeDeliveryError,
110
114
  isComposeError,
111
115
  isComposePreparationError,
112
116
  isComposeSdkOutdatedError,
package/src/outputs.ts CHANGED
@@ -2,8 +2,9 @@ import type { Outputs, TerminalOutput } from '@lifi/compose-spec';
2
2
 
3
3
  /**
4
4
  * The entries of `outputs` the caller actually receives: every port no later
5
- * node spends, keyed `<nodeId>.<portName>` as on the wire. Consumed ports
6
- * (intermediate amounts a later op takes as input) are dropped.
5
+ * node spends, keyed `<nodeId>.<portName>` as on the wire, and every resource
6
+ * input no node spends, keyed `input.<name>`. Consumed ports (intermediate
7
+ * amounts a later op takes as input) are dropped.
7
8
  */
8
9
  export const terminalOutputs = (
9
10
  outputs: Outputs,
@@ -1,4 +1,8 @@
1
- import type { SimulateResult, SimulationRevert } from '@lifi/compose-spec';
1
+ import type {
2
+ DeliveryErrorDetails,
3
+ SimulateResult,
4
+ SimulationRevert,
5
+ } from '@lifi/compose-spec';
2
6
  import z from 'zod';
3
7
 
4
8
  /**
@@ -138,7 +142,7 @@ export interface ServerErrorBody {
138
142
  readonly sdkVersion?: string;
139
143
  readonly serverVersion?: string;
140
144
  readonly minimumSdkVersion?: string;
141
- readonly details?: SimulationRevert;
145
+ readonly details?: SimulationRevert | DeliveryErrorDetails;
142
146
  readonly failedOps?: readonly ServerFailedPreparedOp[];
143
147
  readonly succeededOps?: readonly string[];
144
148
  };
@@ -155,8 +159,8 @@ const failedPreparedOpSchema = z.object({
155
159
  });
156
160
 
157
161
  // `details` is passed through (`z.custom`) rather than parsed: the SDK does not
158
- // own the `SimulationRevert` schema and forwards the field verbatim onto
159
- // `ComposeError`.
162
+ // own the `SimulationRevert` or `DeliveryErrorDetails` schemas and forwards
163
+ // the field verbatim onto `ComposeError`.
160
164
  //
161
165
  // `failedOps`/`succeededOps` are optional here because every error kind shares
162
166
  // this envelope; they are only populated for `preparation_error` (422). Zod
@@ -174,7 +178,7 @@ const serverErrorBodySchema = z.object({
174
178
  sdkVersion: z.string().optional(),
175
179
  serverVersion: z.string().optional(),
176
180
  minimumSdkVersion: z.string().optional(),
177
- details: z.custom<SimulationRevert>().optional(),
181
+ details: z.custom<SimulationRevert | DeliveryErrorDetails>().optional(),
178
182
  failedOps: z.array(failedPreparedOpSchema).readonly().optional(),
179
183
  succeededOps: z.array(z.string()).readonly().optional(),
180
184
  })
package/src/run/inputs.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import type {
2
2
  ComposeRun,
3
+ ForwardTo,
3
4
  InputSpec,
4
5
  MaterialiserInput,
5
6
  Precondition,
6
7
  SimulationPolicy,
7
- SweepTo,
8
8
  } from '@lifi/compose-spec';
9
9
 
10
10
  import type { Address, InputSchema, InputSpecOf } from '../types.js';
@@ -33,13 +33,6 @@ export interface ComposeRunInput<T extends InputSchema = InputSchema> {
33
33
  readonly assumptions?: { readonly [K in keyof T]?: bigint };
34
34
  /** Optional integrator referrer identifier. */
35
35
  readonly referrer?: string;
36
- /**
37
- * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).
38
- * A non-zero value requires the request to be authenticated with an
39
- * integration-scoped API key — the integration is derived from the key, not
40
- * this field. Defaults to `0` (no fee) when omitted.
41
- */
42
- readonly integratorFeeBps?: number;
43
36
  /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */
44
37
  readonly maxPriceImpactBps?: number;
45
38
  /**
@@ -47,7 +40,7 @@ export interface ComposeRunInput<T extends InputSchema = InputSchema> {
47
40
  * Pass a literal `0x`-prefixed address or `{ $ref: "context.sender" }` to
48
41
  * send remaining tokens to the signer.
49
42
  */
50
- readonly sweepTo?: SweepTo;
43
+ readonly sweepTo?: ForwardTo;
51
44
  /**
52
45
  * Controls behavior when simulation detects a revert.
53
46
  * `'strict'` (default) returns an error; `'allow-revert'` returns a partial
@@ -123,9 +116,8 @@ export const buildRun = (run: {
123
116
  signer: string;
124
117
  assumptions?: Record<string, bigint>;
125
118
  referrer?: string;
126
- integratorFeeBps?: number;
127
119
  maxPriceImpactBps?: number;
128
- sweepTo?: SweepTo;
120
+ sweepTo?: ForwardTo;
129
121
  simulationPolicy?: SimulationPolicy;
130
122
  simulateUserProgram?: boolean;
131
123
  checkOnChainAllowances?: boolean;
@@ -137,7 +129,6 @@ export const buildRun = (run: {
137
129
  preconditions: run.preconditions?.length ? run.preconditions : undefined,
138
130
  assumptions: run.assumptions,
139
131
  referrer: run.referrer,
140
- integratorFeeBps: run.integratorFeeBps,
141
132
  maxPriceImpactBps: run.maxPriceImpactBps,
142
133
  sweepTo: run.sweepTo,
143
134
  simulationPolicy: run.simulationPolicy,
package/src/sdk.ts CHANGED
@@ -201,7 +201,6 @@ export const createComposeSdk = (options: ComposeSdkOptions): ComposeSdk => {
201
201
  signer: run.signer,
202
202
  assumptions: run.assumptions as Record<string, bigint> | undefined,
203
203
  referrer: run.referrer,
204
- integratorFeeBps: run.integratorFeeBps,
205
204
  maxPriceImpactBps: run.maxPriceImpactBps,
206
205
  sweepTo: run.sweepTo,
207
206
  simulationPolicy: run.simulationPolicy,
@@ -1,59 +0,0 @@
1
- import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
2
-
3
- import { createComposeSdk, materialisers, resources } from '../index.js';
4
-
5
- import { API_KEY, BASE_URL, OWNER } from './config.js';
6
-
7
- const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
8
- const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
9
-
10
- /**
11
- * Swap WETH to USDC via LI.FI while collecting an integrator fee.
12
- *
13
- * Demonstrates:
14
- * - Setting `integratorFeeBps` on the compile request (50 bps = 0.5%)
15
- * - The fee is taken on the input token; the backend injects the fee transfer
16
- *
17
- * A non-zero `integratorFeeBps` requires the SDK to be configured with an
18
- * integration-scoped API key (`apiKey`); the integration is derived from the
19
- * key, not the request body.
20
- */
21
- export const buildSwapWithFeeExample = (): {
22
- flow: Flow;
23
- request: ComposeCompileRequest;
24
- } => {
25
- const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
26
-
27
- // Declare the flow with a single WETH input on Ethereum mainnet.
28
- const builder = sdk.flow(1, {
29
- name: 'swap-with-fee',
30
- inputs: {
31
- amountIn: resources.erc20(WETH, 1),
32
- },
33
- });
34
-
35
- // Swap WETH → USDC via LI.FI.
36
- builder.lifi.swap('swap', {
37
- bind: { amountIn: builder.inputs.amountIn },
38
- config: {
39
- resourceOut: resources.erc20(USDC, 1),
40
- slippage: 0.03,
41
- },
42
- });
43
-
44
- const flow = builder.build();
45
-
46
- // Build the compile request with a 50 bps (0.5%) integrator fee.
47
- const request = sdk.request(flow, {
48
- signer: OWNER,
49
- inputs: {
50
- amountIn: materialisers.directDeposit({
51
- amount: '1000000000000000000',
52
- }),
53
- },
54
- integratorFeeBps: 50,
55
- sweepTo: builder.context.sender,
56
- });
57
-
58
- return { flow, request };
59
- };