@lifi/composer-sdk 0.0.1-alpha → 0.1.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 (71) hide show
  1. package/README.md +37 -1
  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/authoring/signatureArgs.cjs +2 -2
  7. package/dist/authoring/signatureArgs.cjs.map +1 -1
  8. package/dist/authoring/signatureArgs.js +2 -2
  9. package/dist/authoring/signatureArgs.js.map +1 -1
  10. package/dist/client.cjs +2 -2
  11. package/dist/client.cjs.map +1 -1
  12. package/dist/client.js +2 -2
  13. package/dist/client.js.map +1 -1
  14. package/dist/generated/config.generated.cjs.map +1 -1
  15. package/dist/generated/config.generated.d.cts +327 -16
  16. package/dist/generated/config.generated.d.ts +327 -16
  17. package/dist/generated/guards.generated.cjs +6 -0
  18. package/dist/generated/guards.generated.cjs.map +1 -1
  19. package/dist/generated/guards.generated.d.cts +1 -1
  20. package/dist/generated/guards.generated.d.ts +1 -1
  21. package/dist/generated/guards.generated.js +5 -0
  22. package/dist/generated/guards.generated.js.map +1 -1
  23. package/dist/generated/materialisers.generated.cjs.map +1 -1
  24. package/dist/generated/materialisers.generated.d.cts +1 -1
  25. package/dist/generated/materialisers.generated.d.ts +1 -1
  26. package/dist/generated/materialisers.generated.js.map +1 -1
  27. package/dist/generated/operations.generated.cjs +103 -14
  28. package/dist/generated/operations.generated.cjs.map +1 -1
  29. package/dist/generated/operations.generated.d.cts +255 -10
  30. package/dist/generated/operations.generated.d.ts +255 -10
  31. package/dist/generated/operations.generated.js +103 -14
  32. package/dist/generated/operations.generated.js.map +1 -1
  33. package/dist/guards.generated-BPLFwe7y.d.ts +19 -0
  34. package/dist/guards.generated-M3VAIevI.d.cts +19 -0
  35. package/dist/index.d.cts +3 -3
  36. package/dist/index.d.ts +3 -3
  37. package/dist/materialisers.generated-BMkBQgWZ.d.ts +24 -0
  38. package/dist/materialisers.generated-BWq5oePO.d.cts +24 -0
  39. package/dist/run/inputs.cjs +8 -5
  40. package/dist/run/inputs.cjs.map +1 -1
  41. package/dist/run/inputs.d.cts +8 -0
  42. package/dist/run/inputs.d.ts +8 -0
  43. package/dist/run/inputs.js +8 -5
  44. package/dist/run/inputs.js.map +1 -1
  45. package/dist/sdk.cjs +1 -0
  46. package/dist/sdk.cjs.map +1 -1
  47. package/dist/sdk.js +1 -0
  48. package/dist/sdk.js.map +1 -1
  49. package/package.json +16 -7
  50. package/src/authoring/handles.ts +19 -10
  51. package/src/authoring/signatureArgs.ts +2 -2
  52. package/src/client.ts +1 -1
  53. package/src/examples/aaveClaimRewards.ts +80 -0
  54. package/src/examples/aaveRepay.ts +69 -0
  55. package/src/examples/aaveRepayWithATokens.ts +81 -0
  56. package/src/examples/aaveSetEMode.ts +68 -0
  57. package/src/examples/emitCustomEvent.ts +75 -0
  58. package/src/examples/invariantChecks.ts +95 -0
  59. package/src/examples/run.ts +41 -4
  60. package/src/examples/swapToRecipient.ts +0 -19
  61. package/src/examples/swapWithFee.ts +59 -0
  62. package/src/generated/config.generated.ts +388 -16
  63. package/src/generated/guards.generated.ts +12 -1
  64. package/src/generated/materialisers.generated.ts +12 -12
  65. package/src/generated/operations.generated.ts +438 -9
  66. package/src/run/inputs.ts +16 -5
  67. package/src/sdk.ts +1 -0
  68. package/dist/guards.generated-DKKDKREA.d.ts +0 -14
  69. package/dist/guards.generated-hrQ1KPNv.d.cts +0 -14
  70. package/dist/materialisers.generated-BsA1uDW8.d.ts +0 -24
  71. package/dist/materialisers.generated-nMxTAaVi.d.cts +0 -24
@@ -7,38 +7,38 @@ import type {
7
7
  } from '@lifi/compose-spec';
8
8
 
9
9
  import type {
10
- BalanceOfMaterialiserConfig,
11
- CallMaterialiserConfig,
12
- DirectDepositMaterialiserConfig,
10
+ BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfigSchema,
11
+ CallMaterialiserConfig as CallMaterialiserConfigSchema,
12
+ DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfigSchema,
13
13
  } from './config.generated.js';
14
14
 
15
- export type BalanceOfMaterialiserInput =
16
- MaterialiserConfigOf<BalanceOfMaterialiserConfig>;
15
+ export type BalanceOfMaterialiserConfig =
16
+ MaterialiserConfigOf<BalanceOfMaterialiserConfigSchema>;
17
17
 
18
18
  /** Read the on-chain token balance of an address as the input amount — accepts: resource */
19
19
  export const balanceOf = (
20
- config: BalanceOfMaterialiserInput,
20
+ config: BalanceOfMaterialiserConfig,
21
21
  ): MaterialiserInput => ({
22
22
  kind: 'balanceOf',
23
23
  ...config,
24
24
  });
25
25
 
26
- export type DirectDepositMaterialiserInput =
27
- MaterialiserConfigOf<DirectDepositMaterialiserConfig>;
26
+ export type DirectDepositMaterialiserConfig =
27
+ MaterialiserConfigOf<DirectDepositMaterialiserConfigSchema>;
28
28
 
29
29
  /** Deposit tokens into the VM — native via msg.value, ERC-20 via transferFrom — accepts: resource */
30
30
  export const directDeposit = (
31
- config: DirectDepositMaterialiserInput,
31
+ config: DirectDepositMaterialiserConfig,
32
32
  ): MaterialiserInput => ({
33
33
  kind: 'directDeposit',
34
34
  ...config,
35
35
  });
36
36
 
37
- export type CallMaterialiserInput =
38
- MaterialiserConfigOf<CallMaterialiserConfig>;
37
+ export type CallMaterialiserConfig =
38
+ MaterialiserConfigOf<CallMaterialiserConfigSchema>;
39
39
 
40
40
  /** Execute an arbitrary contract call and measure the resulting token balance diff — accepts: resource */
41
- export const call = (config: CallMaterialiserInput): MaterialiserInput => ({
41
+ export const call = (config: CallMaterialiserConfig): MaterialiserInput => ({
42
42
  kind: 'call',
43
43
  ...config,
44
44
  });
@@ -18,19 +18,33 @@ import {
18
18
  import type { TypedGuard } from '../types.js';
19
19
 
20
20
  import type {
21
+ AaveBorrowConfig,
22
+ AaveClaimRewardsConfig,
23
+ AaveRepayConfig,
24
+ AaveRepayWithATokensConfig,
25
+ AaveSetEModeConfig,
21
26
  CoreApproveConfig,
22
27
  CoreAsResourceConfig,
23
28
  CoreBalanceOfConfig,
24
29
  CoreBpsDownConfig,
25
30
  CoreBpsUpConfig,
26
31
  CoreCallConfig,
32
+ CoreEmitEvent1Config,
33
+ CoreEmitEvent2Config,
34
+ CoreEmitEvent3Config,
35
+ CoreEmitEvent4Config,
27
36
  CorePeekConfig,
28
37
  CoreRawCallConfig,
29
38
  CoreSplitConfig,
30
39
  CoreStaticCallConfig,
31
40
  CoreTransferConfig,
41
+ InvariantNumericConfig,
42
+ InvariantNumericInRangeConfig,
32
43
  LifiSwapConfig,
33
44
  LifiZapConfig,
45
+ MorphoBlueSupplyCollateralConfig,
46
+ MorphoBlueWithdrawCollateralConfig,
47
+ ParaswapBuyConfig,
34
48
  } from './config.generated.js';
35
49
 
36
50
  /** Split a resource into two outputs by basis-point ratio */
@@ -69,13 +83,91 @@ export interface InvariantBalanceAtLeastArgs {
69
83
  readonly guards?: readonly TypedGuard<never>[];
70
84
  }
71
85
 
72
- /** Route tokens into a DeFi protocol position via the edge catalog */
73
- export interface LifiZapArgs {
86
+ /** Assert that an account holds exactly an expected token balance */
87
+ export interface InvariantBalanceEqualsArgs {
74
88
  readonly bind: {
75
- readonly amountIn: Bindable<'resource'>;
89
+ readonly expectedAmount: Bindable<'resource'>;
90
+ readonly account: Bindable<'address'>;
76
91
  };
77
- readonly config: LifiZapConfig;
78
- readonly guards?: readonly TypedGuard<'amountOut'>[];
92
+ readonly guards?: readonly TypedGuard<never>[];
93
+ }
94
+
95
+ /** Assert that an account holds at most a maximum token balance */
96
+ export interface InvariantBalanceAtMostArgs {
97
+ readonly bind: {
98
+ readonly maximumAmount: Bindable<'resource'>;
99
+ readonly account: Bindable<'address'>;
100
+ };
101
+ readonly guards?: readonly TypedGuard<never>[];
102
+ }
103
+
104
+ /** Assert that an account's token balance is between a minimum and a maximum (inclusive) */
105
+ export interface InvariantBalanceInRangeArgs {
106
+ readonly bind: {
107
+ readonly minimumAmount: Bindable<'resource'>;
108
+ readonly maximumAmount: Bindable<'uint256'>;
109
+ readonly account: Bindable<'address'>;
110
+ };
111
+ readonly guards?: readonly TypedGuard<never>[];
112
+ }
113
+
114
+ /** Assert that a spender is permitted to move at least a minimum allowance on behalf of an owner */
115
+ export interface InvariantAllowanceAtLeastArgs {
116
+ readonly bind: {
117
+ readonly minimumAmount: Bindable<'resource'>;
118
+ readonly owner: Bindable<'address'>;
119
+ readonly spender: Bindable<'address'>;
120
+ };
121
+ readonly guards?: readonly TypedGuard<never>[];
122
+ }
123
+
124
+ /** Assert that a spender's allowance on behalf of an owner exactly equals an expected amount */
125
+ export interface InvariantAllowanceEqualsArgs {
126
+ readonly bind: {
127
+ readonly expectedAmount: Bindable<'resource'>;
128
+ readonly owner: Bindable<'address'>;
129
+ readonly spender: Bindable<'address'>;
130
+ };
131
+ readonly guards?: readonly TypedGuard<never>[];
132
+ }
133
+
134
+ /** Assert that a spender is permitted to move at most a maximum allowance on behalf of an owner */
135
+ export interface InvariantAllowanceAtMostArgs {
136
+ readonly bind: {
137
+ readonly maximumAmount: Bindable<'resource'>;
138
+ readonly owner: Bindable<'address'>;
139
+ readonly spender: Bindable<'address'>;
140
+ };
141
+ readonly guards?: readonly TypedGuard<never>[];
142
+ }
143
+
144
+ /** Assert that a spender's allowance on behalf of an owner is between a minimum and a maximum (inclusive) */
145
+ export interface InvariantAllowanceInRangeArgs {
146
+ readonly bind: {
147
+ readonly minimumAmount: Bindable<'resource'>;
148
+ readonly maximumAmount: Bindable<'uint256'>;
149
+ readonly owner: Bindable<'address'>;
150
+ readonly spender: Bindable<'address'>;
151
+ };
152
+ readonly guards?: readonly TypedGuard<never>[];
153
+ }
154
+
155
+ /** Assert a uint256 value satisfies a comparison against a constant threshold; reverts on violation */
156
+ export interface InvariantNumericArgs {
157
+ readonly bind: {
158
+ readonly value: Bindable<'uint256'>;
159
+ };
160
+ readonly config: InvariantNumericConfig;
161
+ readonly guards?: readonly TypedGuard<never>[];
162
+ }
163
+
164
+ /** Assert min <= value <= max against constant bounds; reverts if outside the range */
165
+ export interface InvariantNumericInRangeArgs {
166
+ readonly bind: {
167
+ readonly value: Bindable<'uint256'>;
168
+ };
169
+ readonly config: InvariantNumericInRangeConfig;
170
+ readonly guards?: readonly TypedGuard<never>[];
79
171
  }
80
172
 
81
173
  /** Add two unsigned integers (a + b) */
@@ -231,6 +323,48 @@ export interface CoreTransferArgs {
231
323
  readonly guards?: readonly TypedGuard<'transferred' | 'remainder'>[];
232
324
  }
233
325
 
326
+ /** 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). */
327
+ export interface CoreEmitEvent1Args {
328
+ readonly bind: {
329
+ readonly value0: Bindable<'bytes32'>;
330
+ };
331
+ readonly config: CoreEmitEvent1Config;
332
+ readonly guards?: readonly TypedGuard<never>[];
333
+ }
334
+
335
+ /** 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). */
336
+ export interface CoreEmitEvent2Args {
337
+ readonly bind: {
338
+ readonly value0: Bindable<'bytes32'>;
339
+ readonly value1: Bindable<'bytes32'>;
340
+ };
341
+ readonly config: CoreEmitEvent2Config;
342
+ readonly guards?: readonly TypedGuard<never>[];
343
+ }
344
+
345
+ /** 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). */
346
+ export interface CoreEmitEvent3Args {
347
+ readonly bind: {
348
+ readonly value0: Bindable<'bytes32'>;
349
+ readonly value1: Bindable<'bytes32'>;
350
+ readonly value2: Bindable<'bytes32'>;
351
+ };
352
+ readonly config: CoreEmitEvent3Config;
353
+ readonly guards?: readonly TypedGuard<never>[];
354
+ }
355
+
356
+ /** 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). */
357
+ export interface CoreEmitEvent4Args {
358
+ readonly bind: {
359
+ readonly value0: Bindable<'bytes32'>;
360
+ readonly value1: Bindable<'bytes32'>;
361
+ readonly value2: Bindable<'bytes32'>;
362
+ readonly value3: Bindable<'bytes32'>;
363
+ };
364
+ readonly config: CoreEmitEvent4Config;
365
+ readonly guards?: readonly TypedGuard<never>[];
366
+ }
367
+
234
368
  /** Invoke a smart contract function, optionally spending a token resource */
235
369
  export interface CoreCallArgs<TSig extends string = string> {
236
370
  readonly resource?: Bindable<'resource'>;
@@ -266,6 +400,80 @@ export interface CoreAsResourceArgs {
266
400
  readonly guards?: readonly TypedGuard<'resource'>[];
267
401
  }
268
402
 
403
+ /** Borrow an asset from an Aave v3 pool against existing collateral, exposing the borrowed asset as a Resource */
404
+ export interface AaveBorrowArgs {
405
+ readonly bind: Record<string, never>;
406
+ readonly config: AaveBorrowConfig;
407
+ readonly guards?: readonly TypedGuard<'debtBalance'>[];
408
+ }
409
+
410
+ /** Repay an Aave v3 variable-rate debt position with the supplied asset. mode: 'exact' passes the input handle amount; mode: 'max' passes type(uint256).max so Aave's Pool clamps paybackAmount to userVariableDebt exactly. Any unspent input is returned through the residual port. */
411
+ export interface AaveRepayArgs {
412
+ readonly bind: {
413
+ readonly assetIn: Bindable<'resource'>;
414
+ readonly onBehalfOf: Bindable<'address'>;
415
+ };
416
+ readonly config: AaveRepayConfig;
417
+ readonly guards?: readonly TypedGuard<'actualRepaid' | 'residual'>[];
418
+ }
419
+
420
+ /** Repay an Aave v3 variable-rate debt by burning the caller's aToken balance, returning any unspent residual */
421
+ export interface AaveRepayWithATokensArgs {
422
+ readonly bind: {
423
+ readonly aTokenIn: Bindable<'resource'>;
424
+ };
425
+ readonly config: AaveRepayWithATokensConfig;
426
+ readonly guards?: readonly TypedGuard<'actualRepaid' | 'residual'>[];
427
+ }
428
+
429
+ /** Claim a specific Aave v3 incentives reward token against a set of receipt-token positions, exposing the claimed amount as a Resource */
430
+ export interface AaveClaimRewardsArgs {
431
+ readonly bind: Record<string, never>;
432
+ readonly config: AaveClaimRewardsConfig;
433
+ readonly guards?: readonly TypedGuard<'claimedAmount'>[];
434
+ }
435
+
436
+ /** 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. */
437
+ export interface AaveSetEModeArgs {
438
+ readonly bind: Record<string, never>;
439
+ readonly config: AaveSetEModeConfig;
440
+ readonly guards?: readonly TypedGuard<never>[];
441
+ }
442
+
443
+ /** 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). */
444
+ export interface MorphoBlueSupplyCollateralArgs {
445
+ readonly bind: {
446
+ readonly assetIn: Bindable<'resource'>;
447
+ };
448
+ readonly config: MorphoBlueSupplyCollateralConfig;
449
+ readonly guards?: readonly TypedGuard<never>[];
450
+ }
451
+
452
+ /** Withdraw collateral from a Morpho Blue market position to the receiver address. Exposes the withdrawn ERC20 amount as a Resource output. */
453
+ export interface MorphoBlueWithdrawCollateralArgs {
454
+ readonly bind: Record<string, never>;
455
+ readonly config: MorphoBlueWithdrawCollateralConfig;
456
+ readonly guards?: readonly TypedGuard<'collateralWithdrawn'>[];
457
+ }
458
+
459
+ /** Route tokens into a DeFi protocol position via the edge catalog */
460
+ export interface LifiZapArgs {
461
+ readonly bind: {
462
+ readonly amountIn: Bindable<'resource'>;
463
+ };
464
+ readonly config: LifiZapConfig;
465
+ readonly guards?: readonly TypedGuard<'amountOut'>[];
466
+ }
467
+
468
+ /** 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`. */
469
+ export interface ParaswapBuyArgs {
470
+ readonly bind: {
471
+ readonly amountIn: Bindable<'resource'>;
472
+ };
473
+ readonly config: ParaswapBuyConfig;
474
+ readonly guards?: readonly TypedGuard<'unspentIn'>[];
475
+ }
476
+
269
477
  /** Read a smart contract value at compile time (off-chain eth_call); result is baked as a literal */
270
478
  export interface CorePeekArgs {
271
479
  readonly bind: Record<string, never>;
@@ -287,10 +495,6 @@ export interface LifiSwapOutputs {
287
495
  readonly unspentIn: OutputHandle<'resource'>;
288
496
  }
289
497
 
290
- export interface LifiZapOutputs {
291
- readonly amountOut: OutputHandle<'resource'>;
292
- }
293
-
294
498
  export interface CoreAddOutputs {
295
499
  readonly result: OutputHandle<'uint256'>;
296
500
  }
@@ -336,6 +540,40 @@ export interface CoreAsResourceOutputs {
336
540
  readonly resource: OutputHandle<'resource'>;
337
541
  }
338
542
 
543
+ export interface AaveBorrowOutputs {
544
+ readonly borrowed: OutputHandle<'resource'>;
545
+ readonly debtBalance: OutputHandle<'uint256'>;
546
+ }
547
+
548
+ export interface AaveRepayOutputs {
549
+ readonly actualRepaid: OutputHandle<'uint256'>;
550
+ readonly residual: OutputHandle<'resource'>;
551
+ }
552
+
553
+ export interface AaveRepayWithATokensOutputs {
554
+ readonly actualRepaid: OutputHandle<'uint256'>;
555
+ readonly residual: OutputHandle<'resource'>;
556
+ }
557
+
558
+ export interface AaveClaimRewardsOutputs {
559
+ readonly claimed: OutputHandle<'resource'>;
560
+ readonly claimedAmount: OutputHandle<'uint256'>;
561
+ }
562
+
563
+ export interface MorphoBlueWithdrawCollateralOutputs {
564
+ readonly withdrawn: OutputHandle<'resource'>;
565
+ readonly collateralWithdrawn: OutputHandle<'uint256'>;
566
+ }
567
+
568
+ export interface LifiZapOutputs {
569
+ readonly amountOut: OutputHandle<'resource'>;
570
+ }
571
+
572
+ export interface ParaswapBuyOutputs {
573
+ readonly amountOut: OutputHandle<'resource'>;
574
+ readonly unspentIn: OutputHandle<'resource'>;
575
+ }
576
+
339
577
  export interface CorePeekOutputs {
340
578
  readonly result: OutputHandle<'uint256'>;
341
579
  }
@@ -407,6 +645,14 @@ export type GeneratedOps = {
407
645
  nodeId: string,
408
646
  args: CoreTransferArgs,
409
647
  ) => CoreTransferOutputs;
648
+ /** 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" */
649
+ readonly emitEvent1: (nodeId: string, args: CoreEmitEvent1Args) => void;
650
+ /** 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" */
651
+ readonly emitEvent2: (nodeId: string, args: CoreEmitEvent2Args) => void;
652
+ /** 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" */
653
+ readonly emitEvent3: (nodeId: string, args: CoreEmitEvent3Args) => void;
654
+ /** 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" */
655
+ readonly emitEvent4: (nodeId: string, args: CoreEmitEvent4Args) => void;
410
656
  /** Invoke a smart contract function, optionally spending a token resource — original id: "core.call" */
411
657
  readonly call: <TSig extends string>(
412
658
  nodeId: string,
@@ -442,6 +688,85 @@ export type GeneratedOps = {
442
688
  nodeId: string,
443
689
  args: InvariantBalanceAtLeastArgs,
444
690
  ) => void;
691
+ /** Assert that an account holds exactly an expected token balance — original id: "invariant.balanceEquals" */
692
+ readonly balanceEquals: (
693
+ nodeId: string,
694
+ args: InvariantBalanceEqualsArgs,
695
+ ) => void;
696
+ /** Assert that an account holds at most a maximum token balance — original id: "invariant.balanceAtMost" */
697
+ readonly balanceAtMost: (
698
+ nodeId: string,
699
+ args: InvariantBalanceAtMostArgs,
700
+ ) => void;
701
+ /** Assert that an account's token balance is between a minimum and a maximum (inclusive) — original id: "invariant.balanceInRange" */
702
+ readonly balanceInRange: (
703
+ nodeId: string,
704
+ args: InvariantBalanceInRangeArgs,
705
+ ) => void;
706
+ /** Assert that a spender is permitted to move at least a minimum allowance on behalf of an owner — original id: "invariant.allowanceAtLeast" */
707
+ readonly allowanceAtLeast: (
708
+ nodeId: string,
709
+ args: InvariantAllowanceAtLeastArgs,
710
+ ) => void;
711
+ /** Assert that a spender's allowance on behalf of an owner exactly equals an expected amount — original id: "invariant.allowanceEquals" */
712
+ readonly allowanceEquals: (
713
+ nodeId: string,
714
+ args: InvariantAllowanceEqualsArgs,
715
+ ) => void;
716
+ /** Assert that a spender is permitted to move at most a maximum allowance on behalf of an owner — original id: "invariant.allowanceAtMost" */
717
+ readonly allowanceAtMost: (
718
+ nodeId: string,
719
+ args: InvariantAllowanceAtMostArgs,
720
+ ) => void;
721
+ /** Assert that a spender's allowance on behalf of an owner is between a minimum and a maximum (inclusive) — original id: "invariant.allowanceInRange" */
722
+ readonly allowanceInRange: (
723
+ nodeId: string,
724
+ args: InvariantAllowanceInRangeArgs,
725
+ ) => void;
726
+ /** Assert a uint256 value satisfies a comparison against a constant threshold; reverts on violation — original id: "invariant.numeric" */
727
+ readonly numeric: (nodeId: string, args: InvariantNumericArgs) => void;
728
+ /** Assert min <= value <= max against constant bounds; reverts if outside the range — original id: "invariant.numericInRange" */
729
+ readonly numericInRange: (
730
+ nodeId: string,
731
+ args: InvariantNumericInRangeArgs,
732
+ ) => void;
733
+ };
734
+ readonly aave: {
735
+ /** Borrow an asset from an Aave v3 pool against existing collateral, exposing the borrowed asset as a Resource — original id: "aave.borrow" */
736
+ readonly borrow: (
737
+ nodeId: string,
738
+ args: AaveBorrowArgs,
739
+ ) => AaveBorrowOutputs;
740
+ /** Repay an Aave v3 variable-rate debt position with the supplied asset. mode: 'exact' passes the input handle amount; mode: 'max' passes type(uint256).max so Aave's Pool clamps paybackAmount to userVariableDebt exactly. Any unspent input is returned through the residual port. — original id: "aave.repay" */
741
+ readonly repay: (nodeId: string, args: AaveRepayArgs) => AaveRepayOutputs;
742
+ /** Repay an Aave v3 variable-rate debt by burning the caller's aToken balance, returning any unspent residual — original id: "aave.repayWithATokens" */
743
+ readonly repayWithATokens: (
744
+ nodeId: string,
745
+ args: AaveRepayWithATokensArgs,
746
+ ) => AaveRepayWithATokensOutputs;
747
+ /** Claim a specific Aave v3 incentives reward token against a set of receipt-token positions, exposing the claimed amount as a Resource — original id: "aave.claimRewards" */
748
+ readonly claimRewards: (
749
+ nodeId: string,
750
+ args: AaveClaimRewardsArgs,
751
+ ) => AaveClaimRewardsOutputs;
752
+ /** 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" */
753
+ readonly setEMode: (nodeId: string, args: AaveSetEModeArgs) => void;
754
+ };
755
+ readonly morphoBlue: {
756
+ /** 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" */
757
+ readonly supplyCollateral: (
758
+ nodeId: string,
759
+ args: MorphoBlueSupplyCollateralArgs,
760
+ ) => void;
761
+ /** Withdraw collateral from a Morpho Blue market position to the receiver address. Exposes the withdrawn ERC20 amount as a Resource output. — original id: "morphoBlue.withdrawCollateral" */
762
+ readonly withdrawCollateral: (
763
+ nodeId: string,
764
+ args: MorphoBlueWithdrawCollateralArgs,
765
+ ) => MorphoBlueWithdrawCollateralOutputs;
766
+ };
767
+ readonly paraswap: {
768
+ /** 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" */
769
+ readonly buy: (nodeId: string, args: ParaswapBuyArgs) => ParaswapBuyOutputs;
445
770
  };
446
771
  };
447
772
 
@@ -509,6 +834,14 @@ export const bindGeneratedOps = (
509
834
  transferred: 'resource',
510
835
  remainder: 'resource',
511
836
  } as const),
837
+ emitEvent1: (nodeId: string, args: CoreEmitEvent1Args) =>
838
+ builder.call(nodeId, 'core.emitEvent1', args, {}),
839
+ emitEvent2: (nodeId: string, args: CoreEmitEvent2Args) =>
840
+ builder.call(nodeId, 'core.emitEvent2', args, {}),
841
+ emitEvent3: (nodeId: string, args: CoreEmitEvent3Args) =>
842
+ builder.call(nodeId, 'core.emitEvent3', args, {}),
843
+ emitEvent4: (nodeId: string, args: CoreEmitEvent4Args) =>
844
+ builder.call(nodeId, 'core.emitEvent4', args, {}),
512
845
  call: <TSig extends string>(nodeId: string, args: CoreCallArgs<TSig>) => {
513
846
  const wire = buildCallWireFormat({
514
847
  resource: args.resource,
@@ -564,5 +897,101 @@ export const bindGeneratedOps = (
564
897
  { ...args, config: {} },
565
898
  {},
566
899
  ),
900
+ balanceEquals: (nodeId: string, args: InvariantBalanceEqualsArgs) =>
901
+ builder.call(
902
+ nodeId,
903
+ 'invariant.balanceEquals',
904
+ { ...args, config: {} },
905
+ {},
906
+ ),
907
+ balanceAtMost: (nodeId: string, args: InvariantBalanceAtMostArgs) =>
908
+ builder.call(
909
+ nodeId,
910
+ 'invariant.balanceAtMost',
911
+ { ...args, config: {} },
912
+ {},
913
+ ),
914
+ balanceInRange: (nodeId: string, args: InvariantBalanceInRangeArgs) =>
915
+ builder.call(
916
+ nodeId,
917
+ 'invariant.balanceInRange',
918
+ { ...args, config: {} },
919
+ {},
920
+ ),
921
+ allowanceAtLeast: (nodeId: string, args: InvariantAllowanceAtLeastArgs) =>
922
+ builder.call(
923
+ nodeId,
924
+ 'invariant.allowanceAtLeast',
925
+ { ...args, config: {} },
926
+ {},
927
+ ),
928
+ allowanceEquals: (nodeId: string, args: InvariantAllowanceEqualsArgs) =>
929
+ builder.call(
930
+ nodeId,
931
+ 'invariant.allowanceEquals',
932
+ { ...args, config: {} },
933
+ {},
934
+ ),
935
+ allowanceAtMost: (nodeId: string, args: InvariantAllowanceAtMostArgs) =>
936
+ builder.call(
937
+ nodeId,
938
+ 'invariant.allowanceAtMost',
939
+ { ...args, config: {} },
940
+ {},
941
+ ),
942
+ allowanceInRange: (nodeId: string, args: InvariantAllowanceInRangeArgs) =>
943
+ builder.call(
944
+ nodeId,
945
+ 'invariant.allowanceInRange',
946
+ { ...args, config: {} },
947
+ {},
948
+ ),
949
+ numeric: (nodeId: string, args: InvariantNumericArgs) =>
950
+ builder.call(nodeId, 'invariant.numeric', args, {}),
951
+ numericInRange: (nodeId: string, args: InvariantNumericInRangeArgs) =>
952
+ builder.call(nodeId, 'invariant.numericInRange', args, {}),
953
+ },
954
+ aave: {
955
+ borrow: (nodeId: string, args: AaveBorrowArgs) =>
956
+ builder.call(nodeId, 'aave.borrow', args, {
957
+ borrowed: 'resource',
958
+ debtBalance: 'uint256',
959
+ } as const),
960
+ repay: (nodeId: string, args: AaveRepayArgs) =>
961
+ builder.call(nodeId, 'aave.repay', args, {
962
+ actualRepaid: 'uint256',
963
+ residual: 'resource',
964
+ } as const),
965
+ repayWithATokens: (nodeId: string, args: AaveRepayWithATokensArgs) =>
966
+ builder.call(nodeId, 'aave.repayWithATokens', args, {
967
+ actualRepaid: 'uint256',
968
+ residual: 'resource',
969
+ } as const),
970
+ claimRewards: (nodeId: string, args: AaveClaimRewardsArgs) =>
971
+ builder.call(nodeId, 'aave.claimRewards', args, {
972
+ claimed: 'resource',
973
+ claimedAmount: 'uint256',
974
+ } as const),
975
+ setEMode: (nodeId: string, args: AaveSetEModeArgs) =>
976
+ builder.call(nodeId, 'aave.setEMode', args, {}),
977
+ },
978
+ morphoBlue: {
979
+ supplyCollateral: (nodeId: string, args: MorphoBlueSupplyCollateralArgs) =>
980
+ builder.call(nodeId, 'morphoBlue.supplyCollateral', args, {}),
981
+ withdrawCollateral: (
982
+ nodeId: string,
983
+ args: MorphoBlueWithdrawCollateralArgs,
984
+ ) =>
985
+ builder.call(nodeId, 'morphoBlue.withdrawCollateral', args, {
986
+ withdrawn: 'resource',
987
+ collateralWithdrawn: 'uint256',
988
+ } as const),
989
+ },
990
+ paraswap: {
991
+ buy: (nodeId: string, args: ParaswapBuyArgs) =>
992
+ builder.call(nodeId, 'paraswap.buy', args, {
993
+ amountOut: 'resource',
994
+ unspentIn: 'resource',
995
+ } as const),
567
996
  },
568
997
  });
package/src/run/inputs.ts CHANGED
@@ -33,6 +33,13 @@ 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;
36
43
  /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */
37
44
  readonly maxPriceImpactBps?: number;
38
45
  /**
@@ -94,6 +101,7 @@ export const buildRun = (run: {
94
101
  signer: string;
95
102
  assumptions?: Record<string, bigint>;
96
103
  referrer?: string;
104
+ integratorFeeBps?: number;
97
105
  maxPriceImpactBps?: number;
98
106
  sweepTo?: SweepTo;
99
107
  simulationPolicy?: SimulationPolicy;
@@ -103,15 +111,18 @@ export const buildRun = (run: {
103
111
  ...(run.preconditions?.length && { preconditions: run.preconditions }),
104
112
  signer: run.signer,
105
113
  ...(run.assumptions && { assumptions: run.assumptions }),
106
- ...(run.referrer != null && { referrer: run.referrer }),
107
- ...(run.maxPriceImpactBps != null && {
114
+ ...(run.referrer !== undefined && { referrer: run.referrer }),
115
+ ...(run.integratorFeeBps !== undefined && {
116
+ integratorFeeBps: run.integratorFeeBps,
117
+ }),
118
+ ...(run.maxPriceImpactBps !== undefined && {
108
119
  maxPriceImpactBps: run.maxPriceImpactBps,
109
120
  }),
110
- ...(run.sweepTo != null && { sweepTo: run.sweepTo }),
111
- ...(run.simulationPolicy != null && {
121
+ ...(run.sweepTo !== undefined && { sweepTo: run.sweepTo }),
122
+ ...(run.simulationPolicy !== undefined && {
112
123
  simulationPolicy: run.simulationPolicy,
113
124
  }),
114
- ...(run.checkOnChainAllowances != null && {
125
+ ...(run.checkOnChainAllowances !== undefined && {
115
126
  checkOnChainAllowances: run.checkOnChainAllowances,
116
127
  }),
117
128
  });
package/src/sdk.ts CHANGED
@@ -144,6 +144,7 @@ export const createComposeSdk = (options: ComposeSdkOptions): ComposeSdk => {
144
144
  signer: run.signer,
145
145
  assumptions: run.assumptions as Record<string, bigint> | undefined,
146
146
  referrer: run.referrer,
147
+ integratorFeeBps: run.integratorFeeBps,
147
148
  maxPriceImpactBps: run.maxPriceImpactBps,
148
149
  sweepTo: run.sweepTo,
149
150
  simulationPolicy: run.simulationPolicy,
@@ -1,14 +0,0 @@
1
- import { TypedGuard } from './types.js';
2
- import { SlippageGuardConfig } from './generated/config.generated.js';
3
-
4
- /** Assert that output amounts are within a slippage tolerance in basis points */
5
- declare const slippage: <P extends string>(config: Omit<SlippageGuardConfig, "port"> & {
6
- port: P;
7
- }) => TypedGuard<P>;
8
-
9
- declare const guardsMod_slippage: typeof slippage;
10
- declare namespace guardsMod {
11
- export { guardsMod_slippage as slippage };
12
- }
13
-
14
- export { guardsMod as g, slippage as s };
@@ -1,14 +0,0 @@
1
- import { TypedGuard } from './types.cjs';
2
- import { SlippageGuardConfig } from './generated/config.generated.cjs';
3
-
4
- /** Assert that output amounts are within a slippage tolerance in basis points */
5
- declare const slippage: <P extends string>(config: Omit<SlippageGuardConfig, "port"> & {
6
- port: P;
7
- }) => TypedGuard<P>;
8
-
9
- declare const guardsMod_slippage: typeof slippage;
10
- declare namespace guardsMod {
11
- export { guardsMod_slippage as slippage };
12
- }
13
-
14
- export { guardsMod as g, slippage as s };