@lifi/composer-sdk 0.2.0-staging.4 → 0.2.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 (88) hide show
  1. package/README.md +81 -0
  2. package/dist/authoring/handles.cjs.map +1 -1
  3. package/dist/authoring/handles.d.cts +13 -6
  4. package/dist/authoring/handles.d.ts +13 -6
  5. package/dist/authoring/handles.js.map +1 -1
  6. package/dist/client.cjs +38 -6
  7. package/dist/client.cjs.map +1 -1
  8. package/dist/client.d.cts +25 -1
  9. package/dist/client.d.ts +25 -1
  10. package/dist/client.js +41 -6
  11. package/dist/client.js.map +1 -1
  12. package/dist/errors.cjs +4 -1
  13. package/dist/errors.cjs.map +1 -1
  14. package/dist/errors.js +6 -1
  15. package/dist/errors.js.map +1 -1
  16. package/dist/generated/config.generated.cjs.map +1 -1
  17. package/dist/generated/config.generated.d.cts +82 -7
  18. package/dist/generated/config.generated.d.ts +82 -7
  19. package/dist/generated/materialisers.generated.cjs +2 -8
  20. package/dist/generated/materialisers.generated.cjs.map +1 -1
  21. package/dist/generated/materialisers.generated.d.cts +1 -1
  22. package/dist/generated/materialisers.generated.d.ts +1 -1
  23. package/dist/generated/materialisers.generated.js +1 -6
  24. package/dist/generated/materialisers.generated.js.map +1 -1
  25. package/dist/generated/operations.generated.cjs +56 -31
  26. package/dist/generated/operations.generated.cjs.map +1 -1
  27. package/dist/generated/operations.generated.d.cts +204 -94
  28. package/dist/generated/operations.generated.d.ts +204 -94
  29. package/dist/generated/operations.generated.js +56 -31
  30. package/dist/generated/operations.generated.js.map +1 -1
  31. package/dist/index.cjs +8 -0
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +4 -3
  34. package/dist/index.d.ts +4 -3
  35. package/dist/index.js +8 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/{materialisers.generated-BfWJ-g7t.d.ts → materialisers.generated-BMkBQgWZ.d.ts} +3 -8
  38. package/dist/{materialisers.generated-DaJRwiRe.d.cts → materialisers.generated-BWq5oePO.d.cts} +3 -8
  39. package/dist/responseSchemas.cjs +110 -0
  40. package/dist/responseSchemas.cjs.map +1 -0
  41. package/dist/responseSchemas.d.cts +36 -0
  42. package/dist/responseSchemas.d.ts +36 -0
  43. package/dist/responseSchemas.js +74 -0
  44. package/dist/responseSchemas.js.map +1 -0
  45. package/dist/run/simulate.cjs +41 -0
  46. package/dist/run/simulate.cjs.map +1 -0
  47. package/dist/run/simulate.d.cts +59 -0
  48. package/dist/run/simulate.d.ts +59 -0
  49. package/dist/run/simulate.js +17 -0
  50. package/dist/run/simulate.js.map +1 -0
  51. package/dist/sdk.cjs +6 -1
  52. package/dist/sdk.cjs.map +1 -1
  53. package/dist/sdk.d.cts +13 -1
  54. package/dist/sdk.d.ts +13 -1
  55. package/dist/sdk.js +6 -1
  56. package/dist/sdk.js.map +1 -1
  57. package/package.json +7 -5
  58. package/src/authoring/handles.ts +19 -10
  59. package/src/client.ts +86 -11
  60. package/src/errors.ts +8 -10
  61. package/src/examples/aaveRepay.ts +55 -16
  62. package/src/examples/aaveRepayWithATokens.ts +41 -30
  63. package/src/examples/aaveRounding.ts +42 -0
  64. package/src/examples/aaveSetEMode.ts +0 -1
  65. package/src/examples/config.ts +1 -1
  66. package/src/examples/emitCustomEvent.ts +75 -0
  67. package/src/examples/invariantChecks.ts +96 -0
  68. package/src/examples/run.ts +20 -18
  69. package/src/examples/simulateCompiledSwap.ts +76 -0
  70. package/src/examples/simulateRawTransaction.ts +39 -0
  71. package/src/examples/untypedOpWithTypedRef.ts +26 -20
  72. package/src/generated/config.generated.ts +229 -6
  73. package/src/generated/materialisers.generated.ts +0 -12
  74. package/src/generated/operations.generated.ts +330 -177
  75. package/src/index.ts +19 -0
  76. package/src/responseSchemas.ts +143 -0
  77. package/src/run/simulate.ts +78 -0
  78. package/src/sdk.ts +20 -1
  79. package/src/examples/staged/aaveBorrow.ts +0 -104
  80. package/src/examples/staged/aaveDebtRebalanceExactOut.ts +0 -301
  81. package/src/examples/staged/aaveHealthFactorExplode.ts +0 -70
  82. package/src/examples/staged/aaveToMorphoDebtMigration.ts +0 -190
  83. package/src/examples/staged/aaveToMorphoDebtMigrationWithSwap.ts +0 -221
  84. package/src/examples/staged/aaveToMorphoDebtMigrationWithSwapExactOut.ts +0 -302
  85. package/src/examples/staged/flashloanRepay.ts +0 -138
  86. package/src/examples/staged/morphoBlueBorrow.ts +0 -89
  87. package/src/examples/staged/morphoBlueRepay.ts +0 -91
  88. package/src/examples/staged/registry.ts +0 -78
@@ -20,7 +20,6 @@ import type { TypedGuard } from '../types.js';
20
20
  import type {
21
21
  AaveBorrowConfig,
22
22
  AaveClaimRewardsConfig,
23
- AaveGetHealthFactorConfig,
24
23
  AaveRepayConfig,
25
24
  AaveRepayWithATokensConfig,
26
25
  AaveSetEModeConfig,
@@ -30,21 +29,27 @@ import type {
30
29
  CoreBpsDownConfig,
31
30
  CoreBpsUpConfig,
32
31
  CoreCallConfig,
32
+ CoreEmitEvent1Config,
33
+ CoreEmitEvent2Config,
34
+ CoreEmitEvent3Config,
35
+ CoreEmitEvent4Config,
33
36
  CorePeekConfig,
34
37
  CoreRawCallConfig,
35
38
  CoreSplitConfig,
36
39
  CoreStaticCallConfig,
37
40
  CoreTransferConfig,
38
- LifiFlashloanRepayConfig,
41
+ InvariantEqConfig,
42
+ InvariantGtConfig,
43
+ InvariantGteConfig,
44
+ InvariantLtConfig,
45
+ InvariantLteConfig,
46
+ InvariantNeqConfig,
47
+ InvariantNumericConfig,
48
+ InvariantNumericInRangeConfig,
39
49
  LifiSwapConfig,
40
50
  LifiZapConfig,
41
- MorphoBlueBorrowConfig,
42
- MorphoBlueGetPositionConfig,
43
- MorphoBlueRepayConfig,
44
51
  MorphoBlueSupplyCollateralConfig,
45
- MorphoBlueSupplyConfig,
46
52
  MorphoBlueWithdrawCollateralConfig,
47
- MorphoBlueWithdrawConfig,
48
53
  ParaswapBuyConfig,
49
54
  } from './config.generated.js';
50
55
 
@@ -84,6 +89,147 @@ export interface InvariantBalanceAtLeastArgs {
84
89
  readonly guards?: readonly TypedGuard<never>[];
85
90
  }
86
91
 
92
+ /** Assert that an account holds exactly an expected token balance */
93
+ export interface InvariantBalanceEqualsArgs {
94
+ readonly bind: {
95
+ readonly expectedAmount: Bindable<'resource'>;
96
+ readonly account: Bindable<'address'>;
97
+ };
98
+ readonly guards?: readonly TypedGuard<never>[];
99
+ }
100
+
101
+ /** Assert that an account holds at most a maximum token balance */
102
+ export interface InvariantBalanceAtMostArgs {
103
+ readonly bind: {
104
+ readonly maximumAmount: Bindable<'resource'>;
105
+ readonly account: Bindable<'address'>;
106
+ };
107
+ readonly guards?: readonly TypedGuard<never>[];
108
+ }
109
+
110
+ /** Assert that an account's token balance is between a minimum and a maximum (inclusive) */
111
+ export interface InvariantBalanceInRangeArgs {
112
+ readonly bind: {
113
+ readonly minimumAmount: Bindable<'resource'>;
114
+ readonly maximumAmount: Bindable<'uint256'>;
115
+ readonly account: Bindable<'address'>;
116
+ };
117
+ readonly guards?: readonly TypedGuard<never>[];
118
+ }
119
+
120
+ /** Assert that a spender is permitted to move at least a minimum allowance on behalf of an owner */
121
+ export interface InvariantAllowanceAtLeastArgs {
122
+ readonly bind: {
123
+ readonly minimumAmount: Bindable<'resource'>;
124
+ readonly owner: Bindable<'address'>;
125
+ readonly spender: Bindable<'address'>;
126
+ };
127
+ readonly guards?: readonly TypedGuard<never>[];
128
+ }
129
+
130
+ /** Assert that a spender's allowance on behalf of an owner exactly equals an expected amount */
131
+ export interface InvariantAllowanceEqualsArgs {
132
+ readonly bind: {
133
+ readonly expectedAmount: Bindable<'resource'>;
134
+ readonly owner: Bindable<'address'>;
135
+ readonly spender: Bindable<'address'>;
136
+ };
137
+ readonly guards?: readonly TypedGuard<never>[];
138
+ }
139
+
140
+ /** Assert that a spender is permitted to move at most a maximum allowance on behalf of an owner */
141
+ export interface InvariantAllowanceAtMostArgs {
142
+ readonly bind: {
143
+ readonly maximumAmount: Bindable<'resource'>;
144
+ readonly owner: Bindable<'address'>;
145
+ readonly spender: Bindable<'address'>;
146
+ };
147
+ readonly guards?: readonly TypedGuard<never>[];
148
+ }
149
+
150
+ /** Assert that a spender's allowance on behalf of an owner is between a minimum and a maximum (inclusive) */
151
+ export interface InvariantAllowanceInRangeArgs {
152
+ readonly bind: {
153
+ readonly minimumAmount: Bindable<'resource'>;
154
+ readonly maximumAmount: Bindable<'uint256'>;
155
+ readonly owner: Bindable<'address'>;
156
+ readonly spender: Bindable<'address'>;
157
+ };
158
+ readonly guards?: readonly TypedGuard<never>[];
159
+ }
160
+
161
+ /** Assert a uint256 value satisfies a comparison against a constant threshold; reverts on violation */
162
+ export interface InvariantNumericArgs {
163
+ readonly bind: {
164
+ readonly value: Bindable<'uint256'>;
165
+ };
166
+ readonly config: InvariantNumericConfig;
167
+ readonly guards?: readonly TypedGuard<never>[];
168
+ }
169
+
170
+ /** Assert min <= value <= max against constant bounds; reverts if outside the range */
171
+ export interface InvariantNumericInRangeArgs {
172
+ readonly bind: {
173
+ readonly value: Bindable<'uint256'>;
174
+ };
175
+ readonly config: InvariantNumericInRangeConfig;
176
+ readonly guards?: readonly TypedGuard<never>[];
177
+ }
178
+
179
+ /** Assert a uint256 value is greater than or equal to a constant threshold; reverts on violation */
180
+ export interface InvariantGteArgs {
181
+ readonly bind: {
182
+ readonly value: Bindable<'uint256'>;
183
+ };
184
+ readonly config: InvariantGteConfig;
185
+ readonly guards?: readonly TypedGuard<never>[];
186
+ }
187
+
188
+ /** Assert a uint256 value is strictly greater than a constant threshold; reverts on violation */
189
+ export interface InvariantGtArgs {
190
+ readonly bind: {
191
+ readonly value: Bindable<'uint256'>;
192
+ };
193
+ readonly config: InvariantGtConfig;
194
+ readonly guards?: readonly TypedGuard<never>[];
195
+ }
196
+
197
+ /** Assert a uint256 value is less than or equal to a constant threshold; reverts on violation */
198
+ export interface InvariantLteArgs {
199
+ readonly bind: {
200
+ readonly value: Bindable<'uint256'>;
201
+ };
202
+ readonly config: InvariantLteConfig;
203
+ readonly guards?: readonly TypedGuard<never>[];
204
+ }
205
+
206
+ /** Assert a uint256 value is strictly less than a constant threshold; reverts on violation */
207
+ export interface InvariantLtArgs {
208
+ readonly bind: {
209
+ readonly value: Bindable<'uint256'>;
210
+ };
211
+ readonly config: InvariantLtConfig;
212
+ readonly guards?: readonly TypedGuard<never>[];
213
+ }
214
+
215
+ /** Assert a uint256 value equals a constant threshold; reverts on violation */
216
+ export interface InvariantEqArgs {
217
+ readonly bind: {
218
+ readonly value: Bindable<'uint256'>;
219
+ };
220
+ readonly config: InvariantEqConfig;
221
+ readonly guards?: readonly TypedGuard<never>[];
222
+ }
223
+
224
+ /** Assert a uint256 value does not equal a constant threshold; reverts on violation */
225
+ export interface InvariantNeqArgs {
226
+ readonly bind: {
227
+ readonly value: Bindable<'uint256'>;
228
+ };
229
+ readonly config: InvariantNeqConfig;
230
+ readonly guards?: readonly TypedGuard<never>[];
231
+ }
232
+
87
233
  /** Add two unsigned integers (a + b) */
88
234
  export interface CoreAddArgs {
89
235
  readonly bind: {
@@ -237,6 +383,48 @@ export interface CoreTransferArgs {
237
383
  readonly guards?: readonly TypedGuard<'transferred' | 'remainder'>[];
238
384
  }
239
385
 
386
+ /** Emit a custom on-chain event carrying 1 32-byte payload value. The value becomes a non-indexed data word in a fixed VM log event; the signature is hashed into a discriminator word (it is NOT an indexed EVM topic). */
387
+ export interface CoreEmitEvent1Args {
388
+ readonly bind: {
389
+ readonly value0: Bindable<'bytes32'>;
390
+ };
391
+ readonly config: CoreEmitEvent1Config;
392
+ readonly guards?: readonly TypedGuard<never>[];
393
+ }
394
+
395
+ /** Emit a custom on-chain event carrying 2 32-byte payload values. The values become non-indexed data words in a fixed VM log event; the signature is hashed into a discriminator word (it is NOT an indexed EVM topic). */
396
+ export interface CoreEmitEvent2Args {
397
+ readonly bind: {
398
+ readonly value0: Bindable<'bytes32'>;
399
+ readonly value1: Bindable<'bytes32'>;
400
+ };
401
+ readonly config: CoreEmitEvent2Config;
402
+ readonly guards?: readonly TypedGuard<never>[];
403
+ }
404
+
405
+ /** Emit a custom on-chain event carrying 3 32-byte payload values. The values become non-indexed data words in a fixed VM log event; the signature is hashed into a discriminator word (it is NOT an indexed EVM topic). */
406
+ export interface CoreEmitEvent3Args {
407
+ readonly bind: {
408
+ readonly value0: Bindable<'bytes32'>;
409
+ readonly value1: Bindable<'bytes32'>;
410
+ readonly value2: Bindable<'bytes32'>;
411
+ };
412
+ readonly config: CoreEmitEvent3Config;
413
+ readonly guards?: readonly TypedGuard<never>[];
414
+ }
415
+
416
+ /** Emit a custom on-chain event carrying 4 32-byte payload values. The values become non-indexed data words in a fixed VM log event; the signature is hashed into a discriminator word (it is NOT an indexed EVM topic). */
417
+ export interface CoreEmitEvent4Args {
418
+ readonly bind: {
419
+ readonly value0: Bindable<'bytes32'>;
420
+ readonly value1: Bindable<'bytes32'>;
421
+ readonly value2: Bindable<'bytes32'>;
422
+ readonly value3: Bindable<'bytes32'>;
423
+ };
424
+ readonly config: CoreEmitEvent4Config;
425
+ readonly guards?: readonly TypedGuard<never>[];
426
+ }
427
+
240
428
  /** Invoke a smart contract function, optionally spending a token resource */
241
429
  export interface CoreCallArgs<TSig extends string = string> {
242
430
  readonly resource?: Bindable<'resource'>;
@@ -312,13 +500,6 @@ export interface AaveSetEModeArgs {
312
500
  readonly guards?: readonly TypedGuard<never>[];
313
501
  }
314
502
 
315
- /** Read the current Aave v3 health factor (WAD-scaled, 1e18; type(uint256).max for users with no debt) by static-calling IPool.getUserAccountData and decomposing the returned tuple. Exposes the healthFactor element as a uint256 handle suitable for use with core.numericInvariant. */
316
- export interface AaveGetHealthFactorArgs {
317
- readonly bind: Record<string, never>;
318
- readonly config: AaveGetHealthFactorConfig;
319
- readonly guards?: readonly TypedGuard<'healthFactor'>[];
320
- }
321
-
322
503
  /** Deposit the collateral asset of a Morpho Blue market on behalf of the execution proxy. mode: 'exact' pulls the input handle's amount. mode: 'all' reads the proxy's current ERC20 balance of the market's collateral token and pulls that amount, ignoring the input handle's literal value — note this pulls the proxy's total balance (including unrelated upstream residuals), not just the input port's delivery. Credits Position.collateral on the Morpho singleton; emits no return value and exposes no resource output (the collateral is non-transferable accounting state). */
323
504
  export interface MorphoBlueSupplyCollateralArgs {
324
505
  readonly bind: {
@@ -335,64 +516,6 @@ export interface MorphoBlueWithdrawCollateralArgs {
335
516
  readonly guards?: readonly TypedGuard<'collateralWithdrawn'>[];
336
517
  }
337
518
 
338
- /** Borrow the loan asset from a Morpho Blue market against existing collateral. Exposes the borrowed amount as a Resource and the (assetsBorrowed, sharesBorrowed) tuple as handles. */
339
- export interface MorphoBlueBorrowArgs {
340
- readonly bind: Record<string, never>;
341
- readonly config: MorphoBlueBorrowConfig;
342
- readonly guards?: readonly TypedGuard<'assetsBorrowed' | 'sharesBorrowed'>[];
343
- }
344
-
345
- /** Repay a Morpho Blue debt position with the supplied asset. mode: 'exact' repays the input handle amount; mode: 'max' reads Position.borrowShares via a precursor static call and repays in shares mode to retire the debt to the wei. Returns any unspent residual as a Resource. */
346
- export interface MorphoBlueRepayArgs {
347
- readonly bind: {
348
- readonly assetIn: Bindable<'resource'>;
349
- readonly onBehalfOf: Bindable<'address'>;
350
- };
351
- readonly config: MorphoBlueRepayConfig;
352
- readonly guards?: readonly TypedGuard<
353
- 'actualRepaid' | 'sharesRepaid' | 'residual'
354
- >[];
355
- }
356
-
357
- /** Supply the loan asset of a Morpho Blue market and receive supplyShares accounting credit. Returns the (assetsSupplied, sharesSupplied) tuple as handles and any unspent residual as a Resource. */
358
- export interface MorphoBlueSupplyArgs {
359
- readonly bind: {
360
- readonly assetIn: Bindable<'resource'>;
361
- };
362
- readonly config: MorphoBlueSupplyConfig;
363
- readonly guards?: readonly TypedGuard<
364
- 'assetsSupplied' | 'sharesSupplied' | 'residual'
365
- >[];
366
- }
367
-
368
- /** Withdraw the loan asset from a Morpho Blue supply position. mode: 'exact' withdraws the configured amount; mode: 'max' reads Position.supplyShares via a precursor static call and burns all shares to retire the supply to the wei. Exposes the withdrawn amount as a Resource. */
369
- export interface MorphoBlueWithdrawArgs {
370
- readonly bind: Record<string, never>;
371
- readonly config: MorphoBlueWithdrawConfig;
372
- readonly guards?: readonly TypedGuard<
373
- 'assetsWithdrawn' | 'sharesWithdrawn'
374
- >[];
375
- }
376
-
377
- /** Read a Morpho Blue Position struct via a static call on the singleton. Exposes (supplyShares, borrowShares, collateral) as handles whose kinds match the on-chain field types (uint256, uint128, uint128). */
378
- export interface MorphoBlueGetPositionArgs {
379
- readonly bind: Record<string, never>;
380
- readonly config: MorphoBlueGetPositionConfig;
381
- readonly guards?: readonly TypedGuard<
382
- 'supplyShares' | 'borrowShares' | 'collateral'
383
- >[];
384
- }
385
-
386
- /** Transfer principal + fee back to the LiFi flashloan adapter for one leg */
387
- export interface LifiFlashloanRepayArgs {
388
- readonly bind: {
389
- readonly funds: Bindable<'resource'>;
390
- readonly feeBuffer?: Bindable<'resource'>;
391
- };
392
- readonly config: LifiFlashloanRepayConfig;
393
- readonly guards?: readonly TypedGuard<never>[];
394
- }
395
-
396
519
  /** Route tokens into a DeFi protocol position via the edge catalog */
397
520
  export interface LifiZapArgs {
398
521
  readonly bind: {
@@ -497,45 +620,11 @@ export interface AaveClaimRewardsOutputs {
497
620
  readonly claimedAmount: OutputHandle<'uint256'>;
498
621
  }
499
622
 
500
- export interface AaveGetHealthFactorOutputs {
501
- readonly healthFactor: OutputHandle<'uint256'>;
502
- }
503
-
504
623
  export interface MorphoBlueWithdrawCollateralOutputs {
505
624
  readonly withdrawn: OutputHandle<'resource'>;
506
625
  readonly collateralWithdrawn: OutputHandle<'uint256'>;
507
626
  }
508
627
 
509
- export interface MorphoBlueBorrowOutputs {
510
- readonly borrowed: OutputHandle<'resource'>;
511
- readonly assetsBorrowed: OutputHandle<'uint256'>;
512
- readonly sharesBorrowed: OutputHandle<'uint256'>;
513
- }
514
-
515
- export interface MorphoBlueRepayOutputs {
516
- readonly actualRepaid: OutputHandle<'uint256'>;
517
- readonly sharesRepaid: OutputHandle<'uint256'>;
518
- readonly residual: OutputHandle<'resource'>;
519
- }
520
-
521
- export interface MorphoBlueSupplyOutputs {
522
- readonly assetsSupplied: OutputHandle<'uint256'>;
523
- readonly sharesSupplied: OutputHandle<'uint256'>;
524
- readonly residual: OutputHandle<'resource'>;
525
- }
526
-
527
- export interface MorphoBlueWithdrawOutputs {
528
- readonly withdrawn: OutputHandle<'resource'>;
529
- readonly assetsWithdrawn: OutputHandle<'uint256'>;
530
- readonly sharesWithdrawn: OutputHandle<'uint256'>;
531
- }
532
-
533
- export interface MorphoBlueGetPositionOutputs {
534
- readonly supplyShares: OutputHandle<'uint256'>;
535
- readonly borrowShares: OutputHandle<'uint128'>;
536
- readonly collateral: OutputHandle<'uint128'>;
537
- }
538
-
539
628
  export interface LifiZapOutputs {
540
629
  readonly amountOut: OutputHandle<'resource'>;
541
630
  }
@@ -616,6 +705,14 @@ export type GeneratedOps = {
616
705
  nodeId: string,
617
706
  args: CoreTransferArgs,
618
707
  ) => CoreTransferOutputs;
708
+ /** Emit a custom on-chain event carrying 1 32-byte payload value. The value becomes a non-indexed data word in a fixed VM log event; the signature is hashed into a discriminator word (it is NOT an indexed EVM topic). — original id: "core.emitEvent1" */
709
+ readonly emitEvent1: (nodeId: string, args: CoreEmitEvent1Args) => void;
710
+ /** Emit a custom on-chain event carrying 2 32-byte payload values. The values become non-indexed data words in a fixed VM log event; the signature is hashed into a discriminator word (it is NOT an indexed EVM topic). — original id: "core.emitEvent2" */
711
+ readonly emitEvent2: (nodeId: string, args: CoreEmitEvent2Args) => void;
712
+ /** Emit a custom on-chain event carrying 3 32-byte payload values. The values become non-indexed data words in a fixed VM log event; the signature is hashed into a discriminator word (it is NOT an indexed EVM topic). — original id: "core.emitEvent3" */
713
+ readonly emitEvent3: (nodeId: string, args: CoreEmitEvent3Args) => void;
714
+ /** Emit a custom on-chain event carrying 4 32-byte payload values. The values become non-indexed data words in a fixed VM log event; the signature is hashed into a discriminator word (it is NOT an indexed EVM topic). — original id: "core.emitEvent4" */
715
+ readonly emitEvent4: (nodeId: string, args: CoreEmitEvent4Args) => void;
619
716
  /** Invoke a smart contract function, optionally spending a token resource — original id: "core.call" */
620
717
  readonly call: <TSig extends string>(
621
718
  nodeId: string,
@@ -642,11 +739,6 @@ export type GeneratedOps = {
642
739
  readonly lifi: {
643
740
  /** Swap tokens via the LI.FI aggregator API — original id: "lifi.swap" */
644
741
  readonly swap: (nodeId: string, args: LifiSwapArgs) => LifiSwapOutputs;
645
- /** Transfer principal + fee back to the LiFi flashloan adapter for one leg — original id: "lifi.flashloanRepay" */
646
- readonly flashloanRepay: (
647
- nodeId: string,
648
- args: LifiFlashloanRepayArgs,
649
- ) => void;
650
742
  /** Route tokens into a DeFi protocol position via the edge catalog — original id: "lifi.zap" */
651
743
  readonly zap: (nodeId: string, args: LifiZapArgs) => LifiZapOutputs;
652
744
  };
@@ -656,6 +748,60 @@ export type GeneratedOps = {
656
748
  nodeId: string,
657
749
  args: InvariantBalanceAtLeastArgs,
658
750
  ) => void;
751
+ /** Assert that an account holds exactly an expected token balance — original id: "invariant.balanceEquals" */
752
+ readonly balanceEquals: (
753
+ nodeId: string,
754
+ args: InvariantBalanceEqualsArgs,
755
+ ) => void;
756
+ /** Assert that an account holds at most a maximum token balance — original id: "invariant.balanceAtMost" */
757
+ readonly balanceAtMost: (
758
+ nodeId: string,
759
+ args: InvariantBalanceAtMostArgs,
760
+ ) => void;
761
+ /** Assert that an account's token balance is between a minimum and a maximum (inclusive) — original id: "invariant.balanceInRange" */
762
+ readonly balanceInRange: (
763
+ nodeId: string,
764
+ args: InvariantBalanceInRangeArgs,
765
+ ) => void;
766
+ /** Assert that a spender is permitted to move at least a minimum allowance on behalf of an owner — original id: "invariant.allowanceAtLeast" */
767
+ readonly allowanceAtLeast: (
768
+ nodeId: string,
769
+ args: InvariantAllowanceAtLeastArgs,
770
+ ) => void;
771
+ /** Assert that a spender's allowance on behalf of an owner exactly equals an expected amount — original id: "invariant.allowanceEquals" */
772
+ readonly allowanceEquals: (
773
+ nodeId: string,
774
+ args: InvariantAllowanceEqualsArgs,
775
+ ) => void;
776
+ /** Assert that a spender is permitted to move at most a maximum allowance on behalf of an owner — original id: "invariant.allowanceAtMost" */
777
+ readonly allowanceAtMost: (
778
+ nodeId: string,
779
+ args: InvariantAllowanceAtMostArgs,
780
+ ) => void;
781
+ /** Assert that a spender's allowance on behalf of an owner is between a minimum and a maximum (inclusive) — original id: "invariant.allowanceInRange" */
782
+ readonly allowanceInRange: (
783
+ nodeId: string,
784
+ args: InvariantAllowanceInRangeArgs,
785
+ ) => void;
786
+ /** Assert a uint256 value satisfies a comparison against a constant threshold; reverts on violation — original id: "invariant.numeric" */
787
+ readonly numeric: (nodeId: string, args: InvariantNumericArgs) => void;
788
+ /** Assert min <= value <= max against constant bounds; reverts if outside the range — original id: "invariant.numericInRange" */
789
+ readonly numericInRange: (
790
+ nodeId: string,
791
+ args: InvariantNumericInRangeArgs,
792
+ ) => void;
793
+ /** Assert a uint256 value is greater than or equal to a constant threshold; reverts on violation — original id: "invariant.gte" */
794
+ readonly gte: (nodeId: string, args: InvariantGteArgs) => void;
795
+ /** Assert a uint256 value is strictly greater than a constant threshold; reverts on violation — original id: "invariant.gt" */
796
+ readonly gt: (nodeId: string, args: InvariantGtArgs) => void;
797
+ /** Assert a uint256 value is less than or equal to a constant threshold; reverts on violation — original id: "invariant.lte" */
798
+ readonly lte: (nodeId: string, args: InvariantLteArgs) => void;
799
+ /** Assert a uint256 value is strictly less than a constant threshold; reverts on violation — original id: "invariant.lt" */
800
+ readonly lt: (nodeId: string, args: InvariantLtArgs) => void;
801
+ /** Assert a uint256 value equals a constant threshold; reverts on violation — original id: "invariant.eq" */
802
+ readonly eq: (nodeId: string, args: InvariantEqArgs) => void;
803
+ /** Assert a uint256 value does not equal a constant threshold; reverts on violation — original id: "invariant.neq" */
804
+ readonly neq: (nodeId: string, args: InvariantNeqArgs) => void;
659
805
  };
660
806
  readonly aave: {
661
807
  /** Borrow an asset from an Aave v3 pool against existing collateral, exposing the borrowed asset as a Resource — original id: "aave.borrow" */
@@ -677,11 +823,6 @@ export type GeneratedOps = {
677
823
  ) => AaveClaimRewardsOutputs;
678
824
  /** Switch the executionAddress's Aave v3 eMode category. 0 disables eMode. The pool reverts if the switch would make the position unhealthy or if any open borrow is for an asset outside the target category. — original id: "aave.setEMode" */
679
825
  readonly setEMode: (nodeId: string, args: AaveSetEModeArgs) => void;
680
- /** Read the current Aave v3 health factor (WAD-scaled, 1e18; type(uint256).max for users with no debt) by static-calling IPool.getUserAccountData and decomposing the returned tuple. Exposes the healthFactor element as a uint256 handle suitable for use with core.numericInvariant. — original id: "aave.getHealthFactor" */
681
- readonly getHealthFactor: (
682
- nodeId: string,
683
- args: AaveGetHealthFactorArgs,
684
- ) => AaveGetHealthFactorOutputs;
685
826
  };
686
827
  readonly morphoBlue: {
687
828
  /** Deposit the collateral asset of a Morpho Blue market on behalf of the execution proxy. mode: 'exact' pulls the input handle's amount. mode: 'all' reads the proxy's current ERC20 balance of the market's collateral token and pulls that amount, ignoring the input handle's literal value — note this pulls the proxy's total balance (including unrelated upstream residuals), not just the input port's delivery. Credits Position.collateral on the Morpho singleton; emits no return value and exposes no resource output (the collateral is non-transferable accounting state). — original id: "morphoBlue.supplyCollateral" */
@@ -694,31 +835,6 @@ export type GeneratedOps = {
694
835
  nodeId: string,
695
836
  args: MorphoBlueWithdrawCollateralArgs,
696
837
  ) => MorphoBlueWithdrawCollateralOutputs;
697
- /** Borrow the loan asset from a Morpho Blue market against existing collateral. Exposes the borrowed amount as a Resource and the (assetsBorrowed, sharesBorrowed) tuple as handles. — original id: "morphoBlue.borrow" */
698
- readonly borrow: (
699
- nodeId: string,
700
- args: MorphoBlueBorrowArgs,
701
- ) => MorphoBlueBorrowOutputs;
702
- /** Repay a Morpho Blue debt position with the supplied asset. mode: 'exact' repays the input handle amount; mode: 'max' reads Position.borrowShares via a precursor static call and repays in shares mode to retire the debt to the wei. Returns any unspent residual as a Resource. — original id: "morphoBlue.repay" */
703
- readonly repay: (
704
- nodeId: string,
705
- args: MorphoBlueRepayArgs,
706
- ) => MorphoBlueRepayOutputs;
707
- /** Supply the loan asset of a Morpho Blue market and receive supplyShares accounting credit. Returns the (assetsSupplied, sharesSupplied) tuple as handles and any unspent residual as a Resource. — original id: "morphoBlue.supply" */
708
- readonly supply: (
709
- nodeId: string,
710
- args: MorphoBlueSupplyArgs,
711
- ) => MorphoBlueSupplyOutputs;
712
- /** Withdraw the loan asset from a Morpho Blue supply position. mode: 'exact' withdraws the configured amount; mode: 'max' reads Position.supplyShares via a precursor static call and burns all shares to retire the supply to the wei. Exposes the withdrawn amount as a Resource. — original id: "morphoBlue.withdraw" */
713
- readonly withdraw: (
714
- nodeId: string,
715
- args: MorphoBlueWithdrawArgs,
716
- ) => MorphoBlueWithdrawOutputs;
717
- /** Read a Morpho Blue Position struct via a static call on the singleton. Exposes (supplyShares, borrowShares, collateral) as handles whose kinds match the on-chain field types (uint256, uint128, uint128). — original id: "morphoBlue.getPosition" */
718
- readonly getPosition: (
719
- nodeId: string,
720
- args: MorphoBlueGetPositionArgs,
721
- ) => MorphoBlueGetPositionOutputs;
722
838
  };
723
839
  readonly paraswap: {
724
840
  /** 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" */
@@ -790,6 +906,14 @@ export const bindGeneratedOps = (
790
906
  transferred: 'resource',
791
907
  remainder: 'resource',
792
908
  } as const),
909
+ emitEvent1: (nodeId: string, args: CoreEmitEvent1Args) =>
910
+ builder.call(nodeId, 'core.emitEvent1', args, {}),
911
+ emitEvent2: (nodeId: string, args: CoreEmitEvent2Args) =>
912
+ builder.call(nodeId, 'core.emitEvent2', args, {}),
913
+ emitEvent3: (nodeId: string, args: CoreEmitEvent3Args) =>
914
+ builder.call(nodeId, 'core.emitEvent3', args, {}),
915
+ emitEvent4: (nodeId: string, args: CoreEmitEvent4Args) =>
916
+ builder.call(nodeId, 'core.emitEvent4', args, {}),
793
917
  call: <TSig extends string>(nodeId: string, args: CoreCallArgs<TSig>) => {
794
918
  const wire = buildCallWireFormat({
795
919
  resource: args.resource,
@@ -832,8 +956,6 @@ export const bindGeneratedOps = (
832
956
  amountOut: 'resource',
833
957
  unspentIn: 'resource',
834
958
  } as const),
835
- flashloanRepay: (nodeId: string, args: LifiFlashloanRepayArgs) =>
836
- builder.call(nodeId, 'lifi.flashloanRepay', args, {}),
837
959
  zap: (nodeId: string, args: LifiZapArgs) =>
838
960
  builder.call(nodeId, 'lifi.zap', args, {
839
961
  amountOut: 'resource',
@@ -847,6 +969,71 @@ export const bindGeneratedOps = (
847
969
  { ...args, config: {} },
848
970
  {},
849
971
  ),
972
+ balanceEquals: (nodeId: string, args: InvariantBalanceEqualsArgs) =>
973
+ builder.call(
974
+ nodeId,
975
+ 'invariant.balanceEquals',
976
+ { ...args, config: {} },
977
+ {},
978
+ ),
979
+ balanceAtMost: (nodeId: string, args: InvariantBalanceAtMostArgs) =>
980
+ builder.call(
981
+ nodeId,
982
+ 'invariant.balanceAtMost',
983
+ { ...args, config: {} },
984
+ {},
985
+ ),
986
+ balanceInRange: (nodeId: string, args: InvariantBalanceInRangeArgs) =>
987
+ builder.call(
988
+ nodeId,
989
+ 'invariant.balanceInRange',
990
+ { ...args, config: {} },
991
+ {},
992
+ ),
993
+ allowanceAtLeast: (nodeId: string, args: InvariantAllowanceAtLeastArgs) =>
994
+ builder.call(
995
+ nodeId,
996
+ 'invariant.allowanceAtLeast',
997
+ { ...args, config: {} },
998
+ {},
999
+ ),
1000
+ allowanceEquals: (nodeId: string, args: InvariantAllowanceEqualsArgs) =>
1001
+ builder.call(
1002
+ nodeId,
1003
+ 'invariant.allowanceEquals',
1004
+ { ...args, config: {} },
1005
+ {},
1006
+ ),
1007
+ allowanceAtMost: (nodeId: string, args: InvariantAllowanceAtMostArgs) =>
1008
+ builder.call(
1009
+ nodeId,
1010
+ 'invariant.allowanceAtMost',
1011
+ { ...args, config: {} },
1012
+ {},
1013
+ ),
1014
+ allowanceInRange: (nodeId: string, args: InvariantAllowanceInRangeArgs) =>
1015
+ builder.call(
1016
+ nodeId,
1017
+ 'invariant.allowanceInRange',
1018
+ { ...args, config: {} },
1019
+ {},
1020
+ ),
1021
+ numeric: (nodeId: string, args: InvariantNumericArgs) =>
1022
+ builder.call(nodeId, 'invariant.numeric', args, {}),
1023
+ numericInRange: (nodeId: string, args: InvariantNumericInRangeArgs) =>
1024
+ builder.call(nodeId, 'invariant.numericInRange', args, {}),
1025
+ gte: (nodeId: string, args: InvariantGteArgs) =>
1026
+ builder.call(nodeId, 'invariant.gte', args, {}),
1027
+ gt: (nodeId: string, args: InvariantGtArgs) =>
1028
+ builder.call(nodeId, 'invariant.gt', args, {}),
1029
+ lte: (nodeId: string, args: InvariantLteArgs) =>
1030
+ builder.call(nodeId, 'invariant.lte', args, {}),
1031
+ lt: (nodeId: string, args: InvariantLtArgs) =>
1032
+ builder.call(nodeId, 'invariant.lt', args, {}),
1033
+ eq: (nodeId: string, args: InvariantEqArgs) =>
1034
+ builder.call(nodeId, 'invariant.eq', args, {}),
1035
+ neq: (nodeId: string, args: InvariantNeqArgs) =>
1036
+ builder.call(nodeId, 'invariant.neq', args, {}),
850
1037
  },
851
1038
  aave: {
852
1039
  borrow: (nodeId: string, args: AaveBorrowArgs) =>
@@ -871,10 +1058,6 @@ export const bindGeneratedOps = (
871
1058
  } as const),
872
1059
  setEMode: (nodeId: string, args: AaveSetEModeArgs) =>
873
1060
  builder.call(nodeId, 'aave.setEMode', args, {}),
874
- getHealthFactor: (nodeId: string, args: AaveGetHealthFactorArgs) =>
875
- builder.call(nodeId, 'aave.getHealthFactor', args, {
876
- healthFactor: 'uint256',
877
- } as const),
878
1061
  },
879
1062
  morphoBlue: {
880
1063
  supplyCollateral: (nodeId: string, args: MorphoBlueSupplyCollateralArgs) =>
@@ -887,36 +1070,6 @@ export const bindGeneratedOps = (
887
1070
  withdrawn: 'resource',
888
1071
  collateralWithdrawn: 'uint256',
889
1072
  } as const),
890
- borrow: (nodeId: string, args: MorphoBlueBorrowArgs) =>
891
- builder.call(nodeId, 'morphoBlue.borrow', args, {
892
- borrowed: 'resource',
893
- assetsBorrowed: 'uint256',
894
- sharesBorrowed: 'uint256',
895
- } as const),
896
- repay: (nodeId: string, args: MorphoBlueRepayArgs) =>
897
- builder.call(nodeId, 'morphoBlue.repay', args, {
898
- actualRepaid: 'uint256',
899
- sharesRepaid: 'uint256',
900
- residual: 'resource',
901
- } as const),
902
- supply: (nodeId: string, args: MorphoBlueSupplyArgs) =>
903
- builder.call(nodeId, 'morphoBlue.supply', args, {
904
- assetsSupplied: 'uint256',
905
- sharesSupplied: 'uint256',
906
- residual: 'resource',
907
- } as const),
908
- withdraw: (nodeId: string, args: MorphoBlueWithdrawArgs) =>
909
- builder.call(nodeId, 'morphoBlue.withdraw', args, {
910
- withdrawn: 'resource',
911
- assetsWithdrawn: 'uint256',
912
- sharesWithdrawn: 'uint256',
913
- } as const),
914
- getPosition: (nodeId: string, args: MorphoBlueGetPositionArgs) =>
915
- builder.call(nodeId, 'morphoBlue.getPosition', args, {
916
- supplyShares: 'uint256',
917
- borrowShares: 'uint128',
918
- collateral: 'uint128',
919
- } as const),
920
1073
  },
921
1074
  paraswap: {
922
1075
  buy: (nodeId: string, args: ParaswapBuyArgs) =>
package/src/index.ts CHANGED
@@ -51,6 +51,22 @@ export type {
51
51
  SimulationRevert,
52
52
  SolType,
53
53
  SweepTo,
54
+ SimulateRequest,
55
+ SimulateResult,
56
+ SimulateOkResult,
57
+ SimulateRevertResult,
58
+ SimulateRevertDecodeResult,
59
+ SimulateSetupErrorResult,
60
+ SimulateBalanceEntry,
61
+ TrackedBalance,
62
+ SlotFinderRequirement,
63
+ Erc20BalanceRequirement,
64
+ NativeBalanceRequirement,
65
+ Erc20AllowanceRequirement,
66
+ } from '@lifi/compose-spec';
67
+ export {
68
+ SIMULATE_MAX_TRACKED_BALANCES,
69
+ SIMULATE_MAX_REQUIREMENTS,
54
70
  } from '@lifi/compose-spec';
55
71
  export { isComposeError } from './errors.js';
56
72
 
@@ -70,6 +86,9 @@ export type { TypedFlow, FlowOptions } from './authoring/FlowBuilderCore.js';
70
86
  export type { ComposeRunInput } from './run/inputs.js';
71
87
  export { materialiser } from './run/inputs.js';
72
88
 
89
+ export { buildSimulateRequest } from './run/simulate.js';
90
+ export type { BuildSimulateRequestInput } from './run/simulate.js';
91
+
73
92
  export { createComposeSdk } from './sdk.js';
74
93
  export type { ComposeSdk, ComposeSdkOptions, FlowBuilder } from './sdk.js';
75
94