@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
@@ -8,12 +8,16 @@
8
8
  * LIFI_API_KEY=your-key COMPOSER_BASE_URL=https://composer.li.quest yarn example <name>
9
9
  *
10
10
  * Available examples:
11
+ * aave-repay — repay an Aave v3 WETH debt by supplying WETH
12
+ * aave-repay-atoken — repay an Aave v3 USDC debt by burning proxy aTokens
13
+ * aave-claim — claim AAVE rewards and forward to a recipient
11
14
  * approve-deposit — approve vault allowance then deposit USDC
12
15
  * consolidate — consolidate ERC-20 balances to USDC
13
16
  * consolidate-eth — consolidate ERC-20 balances to native ETH
14
17
  * deposit-proxy — deposit tokens already on the proxy into Aave
15
18
  * dust-sweep — split USDC 80/20 and sweep leftover dust
16
19
  * swap — swap WETH to USDC via LI.FI
20
+ * swap-fee — swap WETH to USDC with a 50 bps integrator fee
17
21
  * split-zap — split USDC 60/40 and zap into Aave + Morpho vaults
18
22
  * split-arithmetic — split USDC 70/30 with arithmetic assertions
19
23
  * zap — zap USDC into Aave lending position
@@ -35,6 +39,9 @@ import type { ComposeCompileRequest } from '@lifi/compose-spec';
35
39
 
36
40
  import { createComposeSdk } from '../sdk.js';
37
41
 
42
+ import { buildAaveClaimRewards } from './aaveClaimRewards.js';
43
+ import { buildAaveRepay } from './aaveRepay.js';
44
+ import { buildAaveRepayWithATokens } from './aaveRepayWithATokens.js';
38
45
  import { buildApproveAndDeposit } from './approveAndDeposit.js';
39
46
  import {
40
47
  buildClaimRewards,
@@ -56,11 +63,22 @@ import { buildSwapAndZapExample } from './swapAndZap.js';
56
63
  import { buildSwapToRecipient } from './swapToRecipient.js';
57
64
  import { buildSwapWithAllowRevertExample } from './swapWithAllowRevert.js';
58
65
  import { buildSwapWithBalanceCheck } from './swapWithBalanceCheck.js';
66
+ import { buildSwapWithFeeExample } from './swapWithFee.js';
59
67
  import { buildSwapWithOutputValidation } from './swapWithOutputValidation.js';
60
68
  import { buildPartialTransfer, buildTransferTokens } from './transferTokens.js';
61
69
  import { buildUntypedOpWithTypedRef } from './untypedOpWithTypedRef.js';
62
70
 
63
71
  const EXAMPLES: Record<string, () => ComposeCompileRequest> = {
72
+ 'aave-repay': () =>
73
+ buildAaveRepay({ owner: OWNER, amount: '500000000000000000' }).request,
74
+ 'aave-repay-atoken': () =>
75
+ buildAaveRepayWithATokens({
76
+ owner: OWNER,
77
+ proxyAddress: PROXY,
78
+ expectedATokenBalance: '1000000000',
79
+ }).request,
80
+ 'aave-claim': () =>
81
+ buildAaveClaimRewards({ owner: OWNER, recipient: RECIPIENT }).request,
64
82
  'approve-deposit': () =>
65
83
  buildApproveAndDeposit({ owner: OWNER, amount: '1000000000' }).request,
66
84
  consolidate: () =>
@@ -87,6 +105,7 @@ const EXAMPLES: Record<string, () => ComposeCompileRequest> = {
87
105
  }).request,
88
106
  'dust-sweep': () => buildDustSweepExample().request,
89
107
  swap: () => buildLifiSwapExample().request,
108
+ 'swap-fee': () => buildSwapWithFeeExample().request,
90
109
  'split-zap': () => buildSplitAndZapExample().request,
91
110
  'split-arithmetic': () =>
92
111
  buildSplitWithArithmetic({ owner: OWNER, amount: '1000000000' }).request,
@@ -133,17 +152,35 @@ const EXAMPLES: Record<string, () => ComposeCompileRequest> = {
133
152
  };
134
153
 
135
154
  const run = async () => {
136
- const name = process.argv[2];
137
- const builder = name ? EXAMPLES[name] : undefined;
155
+ const args = process.argv.slice(2);
156
+ const useStaged = args.includes('--staged');
157
+ const name = args.find((arg) => arg !== '--staged');
158
+
159
+ // Staged examples live under examples/staged/ and reference not-yet-prod
160
+ // definitions, so they are deliberately excluded from this production file's
161
+ // type-check. With --staged, pull their registry in via a NON-LITERAL dynamic
162
+ // import (kept `any` to tsc, so the staged files are not dragged into the
163
+ // production program). Requires the SDK to have been regenerated with
164
+ // `yarn generate --staged` first, so the staged ops/materialisers exist at
165
+ // runtime; run `yarn generate` afterwards to restore the production surface.
166
+ let examples: Record<string, () => ComposeCompileRequest> = EXAMPLES;
167
+ if (useStaged) {
168
+ const stagedModule = (await import(
169
+ `${import.meta.dirname}/staged/registry.js`
170
+ )) as { STAGED_EXAMPLES: Record<string, () => ComposeCompileRequest> };
171
+ examples = { ...EXAMPLES, ...stagedModule.STAGED_EXAMPLES };
172
+ }
173
+
174
+ const builder = name ? examples[name] : undefined;
138
175
 
139
176
  if (!builder) {
140
- const valid = Object.keys(EXAMPLES).join(', ');
177
+ const valid = Object.keys(examples).join(', ');
141
178
  console.error(
142
179
  `Error: ${
143
180
  name ? `unknown example "${name}"` : 'no example specified'
144
181
  }\n` +
145
182
  `Valid examples: ${valid}\n` +
146
- `Usage: COMPOSER_BASE_URL=https://composer.li.quest yarn example <name>`,
183
+ `Usage: COMPOSER_BASE_URL=https://composer.li.quest yarn example [--staged] <name>`,
147
184
  );
148
185
  process.exit(1);
149
186
  }
@@ -17,32 +17,13 @@ export interface SwapToRecipientInput {
17
17
  }
18
18
 
19
19
  /**
20
- <<<<<<< HEAD
21
- <<<<<<< HEAD
22
- * Swap WETH and DAI into USDC, merge the outputs, transfer to a recipient,
23
- =======
24
- * Swap WETH and DAI into USDC, merge the outputs, transfer to the recipient,
25
- >>>>>>> a2c178fd (chore: fix examples)
26
- * and verify the recipient holds the combined balance.
27
- =======
28
20
  * Swap WETH and DAI into USDC, merge the outputs, and deliver to a recipient.
29
- >>>>>>> 4c49ff9b (fix: support resource bindings for handle ports)
30
21
  *
31
22
  * Demonstrates:
32
23
  * - Multiple resource inputs (two ERC-20 tokens)
33
24
  * - A handle input (recipient address as a scalar value)
34
25
  * - Chaining two swaps through a merge node
35
- <<<<<<< HEAD
36
- <<<<<<< HEAD
37
- * - Explicit core.transfer to send merged tokens to the recipient
38
- * - Copy-mode resource input on invariant.balanceAtLeast (reads without consuming)
39
- =======
40
- * - core.transfer to send merged tokens to the recipient
41
- * - Using invariant.balanceAtLeast with a handle input for the account
42
- >>>>>>> a2c178fd (chore: fix examples)
43
- =======
44
26
  * - Using `sweepTo` with a handle input to deliver tokens to the recipient
45
- >>>>>>> 4c49ff9b (fix: support resource bindings for handle ports)
46
27
  * - Typed request inputs inferred from the flow schema
47
28
  */
48
29
  export const buildSwapToRecipient = ({
@@ -0,0 +1,59 @@
1
+ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
2
+
3
+ import { createComposeSdk, materialisers, resources } from '../index.js';
4
+
5
+ import { 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 });
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
+ };
@@ -11,6 +11,16 @@ export interface CoreSplitConfig {
11
11
  * a positive number
12
12
  */
13
13
  export type Positive = number;
14
+ /**
15
+ * a string at most 64 character(s) long
16
+ */
17
+ export type MaxLength64 = string;
18
+ /**
19
+ * an array of at most 50 item(s)
20
+ *
21
+ * @maxItems 50
22
+ */
23
+ export type MaxItems50 = MaxLength64[];
14
24
 
15
25
  export interface LifiSwapConfig {
16
26
  resourceOut:
@@ -38,19 +48,21 @@ export interface LifiSwapConfig {
38
48
  reduceEveryMs: number;
39
49
  }[];
40
50
  };
51
+ exchanges?: {
52
+ allow?: MaxItems50;
53
+ deny?: MaxItems50;
54
+ prefer?: MaxItems50;
55
+ };
41
56
  }
42
57
 
43
- export interface LifiZapConfig {
44
- resourceOut:
45
- | {
46
- kind: 'native';
47
- chainId: Positive;
48
- }
49
- | {
50
- kind: 'erc20';
51
- token: Address;
52
- chainId: Positive;
53
- };
58
+ export interface InvariantNumericConfig {
59
+ op: 'gte' | 'gt' | 'lte' | 'lt' | 'eq' | 'neq';
60
+ threshold: IntegerStringInput;
61
+ }
62
+
63
+ export interface InvariantNumericInRangeConfig {
64
+ min: IntegerStringInput;
65
+ max: IntegerStringInput;
54
66
  }
55
67
 
56
68
  export interface CoreBpsDownConfig {
@@ -74,6 +86,22 @@ export interface CoreTransferConfig {
74
86
  amount?: IntegerStringInput;
75
87
  }
76
88
 
89
+ export interface CoreEmitEvent1Config {
90
+ signature: string;
91
+ }
92
+
93
+ export interface CoreEmitEvent2Config {
94
+ signature: string;
95
+ }
96
+
97
+ export interface CoreEmitEvent3Config {
98
+ signature: string;
99
+ }
100
+
101
+ export interface CoreEmitEvent4Config {
102
+ signature: string;
103
+ }
104
+
77
105
  export interface CoreCallConfig {
78
106
  target: Address;
79
107
  functionSignature: string;
@@ -120,22 +148,357 @@ export interface CoreAsResourceConfig {
120
148
  };
121
149
  }
122
150
 
123
- export interface CorePeekConfig {
124
- target: Address;
125
- functionSignature: string;
126
- args?: string[];
151
+ export interface AaveBorrowConfig {
152
+ pool: string;
153
+ asset: string;
154
+ variableDebtToken: string;
155
+ amount: IntegerStringInput;
156
+ referralId?: number;
157
+ }
158
+
159
+ export type AaveRepayConfig =
160
+ | {
161
+ pool: string;
162
+ mode: 'exact';
163
+ }
164
+ | {
165
+ pool: string;
166
+ mode: 'max';
167
+ };
168
+
169
+ export interface AaveRepayWithATokensConfig {
170
+ pool: string;
171
+ asset: string;
172
+ }
173
+
174
+ export interface AaveClaimRewardsConfig {
175
+ rewardsController: string;
176
+ assets: string[];
177
+ reward: string;
178
+ amount?: IntegerStringInput;
179
+ to?: string;
180
+ }
181
+
182
+ /**
183
+ * a number between 0 and 255
184
+ */
185
+ export type Between0255 = number;
186
+
187
+ export interface AaveSetEModeConfig {
188
+ pool: string;
189
+ category: Between0255;
190
+ }
191
+
192
+ export interface AaveGetHealthFactorConfig {
193
+ pool: string;
194
+ user?: string;
195
+ }
196
+
197
+ export type MorphoBlueSupplyCollateralConfig =
198
+ | (
199
+ | {
200
+ morpho?: string;
201
+ onBehalfOf?: string;
202
+ mode: 'exact';
203
+ /**
204
+ * a string matching the pattern ^0x[0-9a-fA-F]{64}$
205
+ */
206
+ marketId: string;
207
+ }
208
+ | {
209
+ morpho?: string;
210
+ onBehalfOf?: string;
211
+ mode: 'exact';
212
+ marketParams: {
213
+ loanToken: string;
214
+ collateralToken: string;
215
+ oracle: string;
216
+ irm: string;
217
+ lltv: string;
218
+ };
219
+ }
220
+ )
221
+ | (
222
+ | {
223
+ morpho?: string;
224
+ onBehalfOf?: string;
225
+ mode: 'all';
226
+ /**
227
+ * a string matching the pattern ^0x[0-9a-fA-F]{64}$
228
+ */
229
+ marketId: string;
230
+ }
231
+ | {
232
+ morpho?: string;
233
+ onBehalfOf?: string;
234
+ mode: 'all';
235
+ marketParams: {
236
+ loanToken: string;
237
+ collateralToken: string;
238
+ oracle: string;
239
+ irm: string;
240
+ lltv: string;
241
+ };
242
+ }
243
+ );
244
+
245
+ export type MorphoBlueWithdrawCollateralConfig =
246
+ | {
247
+ morpho?: string;
248
+ amount: IntegerStringInput;
249
+ onBehalfOf?: string;
250
+ receiver?: string;
251
+ /**
252
+ * a string matching the pattern ^0x[0-9a-fA-F]{64}$
253
+ */
254
+ marketId: string;
255
+ }
256
+ | {
257
+ morpho?: string;
258
+ amount: IntegerStringInput;
259
+ onBehalfOf?: string;
260
+ receiver?: string;
261
+ marketParams: {
262
+ loanToken: string;
263
+ collateralToken: string;
264
+ oracle: string;
265
+ irm: string;
266
+ lltv: string;
267
+ };
268
+ };
269
+
270
+ export type MorphoBlueBorrowConfig =
271
+ | {
272
+ morpho?: string;
273
+ amount: IntegerStringInput;
274
+ onBehalfOf?: string;
275
+ receiver?: string;
276
+ /**
277
+ * a string matching the pattern ^0x[0-9a-fA-F]{64}$
278
+ */
279
+ marketId: string;
280
+ }
281
+ | {
282
+ morpho?: string;
283
+ amount: IntegerStringInput;
284
+ onBehalfOf?: string;
285
+ receiver?: string;
286
+ marketParams: {
287
+ loanToken: string;
288
+ collateralToken: string;
289
+ oracle: string;
290
+ irm: string;
291
+ lltv: string;
292
+ };
293
+ };
294
+
295
+ export type MorphoBlueRepayConfig =
296
+ | (
297
+ | {
298
+ morpho?: string;
299
+ mode: 'exact';
300
+ /**
301
+ * a string matching the pattern ^0x[0-9a-fA-F]{64}$
302
+ */
303
+ marketId: string;
304
+ }
305
+ | {
306
+ morpho?: string;
307
+ mode: 'exact';
308
+ marketParams: {
309
+ loanToken: string;
310
+ collateralToken: string;
311
+ oracle: string;
312
+ irm: string;
313
+ lltv: string;
314
+ };
315
+ }
316
+ )
317
+ | (
318
+ | {
319
+ morpho?: string;
320
+ mode: 'max';
321
+ /**
322
+ * a string matching the pattern ^0x[0-9a-fA-F]{64}$
323
+ */
324
+ marketId: string;
325
+ }
326
+ | {
327
+ morpho?: string;
328
+ mode: 'max';
329
+ marketParams: {
330
+ loanToken: string;
331
+ collateralToken: string;
332
+ oracle: string;
333
+ irm: string;
334
+ lltv: string;
335
+ };
336
+ }
337
+ );
338
+
339
+ export type MorphoBlueSupplyConfig =
340
+ | {
341
+ morpho?: string;
342
+ onBehalfOf?: string;
343
+ /**
344
+ * a string matching the pattern ^0x[0-9a-fA-F]{64}$
345
+ */
346
+ marketId: string;
347
+ }
348
+ | {
349
+ morpho?: string;
350
+ onBehalfOf?: string;
351
+ marketParams: {
352
+ loanToken: string;
353
+ collateralToken: string;
354
+ oracle: string;
355
+ irm: string;
356
+ lltv: string;
357
+ };
358
+ };
359
+
360
+ export type MorphoBlueWithdrawConfig =
361
+ | (
362
+ | {
363
+ morpho?: string;
364
+ mode: 'exact';
365
+ amount: IntegerStringInput;
366
+ onBehalfOf?: string;
367
+ receiver?: string;
368
+ /**
369
+ * a string matching the pattern ^0x[0-9a-fA-F]{64}$
370
+ */
371
+ marketId: string;
372
+ }
373
+ | {
374
+ morpho?: string;
375
+ mode: 'exact';
376
+ amount: IntegerStringInput;
377
+ onBehalfOf?: string;
378
+ receiver?: string;
379
+ marketParams: {
380
+ loanToken: string;
381
+ collateralToken: string;
382
+ oracle: string;
383
+ irm: string;
384
+ lltv: string;
385
+ };
386
+ }
387
+ )
388
+ | (
389
+ | {
390
+ morpho?: string;
391
+ mode: 'max';
392
+ onBehalfOf?: string;
393
+ receiver?: string;
394
+ /**
395
+ * a string matching the pattern ^0x[0-9a-fA-F]{64}$
396
+ */
397
+ marketId: string;
398
+ }
399
+ | {
400
+ morpho?: string;
401
+ mode: 'max';
402
+ onBehalfOf?: string;
403
+ receiver?: string;
404
+ marketParams: {
405
+ loanToken: string;
406
+ collateralToken: string;
407
+ oracle: string;
408
+ irm: string;
409
+ lltv: string;
410
+ };
411
+ }
412
+ );
413
+
414
+ export type MorphoBlueGetPositionConfig =
415
+ | {
416
+ morpho?: string;
417
+ user?: string;
418
+ /**
419
+ * a string matching the pattern ^0x[0-9a-fA-F]{64}$
420
+ */
421
+ marketId: string;
422
+ }
423
+ | {
424
+ morpho?: string;
425
+ user?: string;
426
+ marketParams: {
427
+ loanToken: string;
428
+ collateralToken: string;
429
+ oracle: string;
430
+ irm: string;
431
+ lltv: string;
432
+ };
433
+ };
434
+
435
+ export interface LifiFlashloanRepayConfig {
436
+ leg: string;
437
+ fee?: string;
127
438
  }
128
439
 
440
+ export interface LifiZapConfig {
441
+ resourceOut:
442
+ | {
443
+ kind: 'native';
444
+ chainId: Positive;
445
+ }
446
+ | {
447
+ kind: 'erc20';
448
+ token: Address;
449
+ chainId: Positive;
450
+ };
451
+ }
452
+
453
+ /**
454
+ * a non-negative number
455
+ */
456
+ export type GreaterThanOrEqualTo0 = number;
129
457
  /**
130
458
  * a number between 0 and 10000
131
459
  */
132
460
  export type Between010000 = number;
133
461
 
462
+ export interface ParaswapBuyConfig {
463
+ resourceOut:
464
+ | {
465
+ kind: 'native';
466
+ chainId: Positive;
467
+ }
468
+ | {
469
+ kind: 'erc20';
470
+ token: Address;
471
+ chainId: Positive;
472
+ };
473
+ exactAmountOut: string;
474
+ srcDecimals: GreaterThanOrEqualTo0;
475
+ destDecimals: GreaterThanOrEqualTo0;
476
+ maxSlippageBps?: Between010000;
477
+ partner?: string;
478
+ partnerAddress?: string;
479
+ /**
480
+ * Integrator fee in basis points; non-negative integer string capped at 9000.
481
+ */
482
+ partnerFeeBps?: string;
483
+ }
484
+
485
+ export interface CorePeekConfig {
486
+ target: Address;
487
+ functionSignature: string;
488
+ args?: string[];
489
+ }
490
+
134
491
  export interface SlippageGuardConfig {
135
492
  port: string;
136
493
  bps: Between010000;
137
494
  }
138
495
 
496
+ export interface CoreNumericInvariantGuardConfig {
497
+ port: string;
498
+ op: 'gte' | 'gt' | 'lte' | 'lt' | 'eq' | 'neq';
499
+ threshold: IntegerStringInput;
500
+ }
501
+
139
502
  export interface BalanceOfMaterialiserConfig {
140
503
  owner: Address;
141
504
  }
@@ -146,8 +509,12 @@ export type DirectDepositMaterialiserConfig =
146
509
  allowNonExact?: false;
147
510
  }
148
511
  | {
149
- amount?: IntegerStringInput;
512
+ amount: IntegerStringInput;
150
513
  allowNonExact: true;
514
+ }
515
+ | {
516
+ allowNonExact: true;
517
+ simAmount?: string;
151
518
  };
152
519
 
153
520
  export interface CallMaterialiserConfig {
@@ -155,6 +522,11 @@ export interface CallMaterialiserConfig {
155
522
  calldata: string;
156
523
  }
157
524
 
525
+ export interface FlashloanMaterialiserConfig {
526
+ providerKind: 'aave-v3' | 'erc3156' | 'balancer-v2' | 'morpho-blue';
527
+ amount: IntegerStringInput;
528
+ }
529
+
158
530
  export interface Erc20BalancePreconditionConfig {
159
531
  wallet: Address;
160
532
  token: Address;
@@ -3,7 +3,10 @@
3
3
 
4
4
  import type { TypedGuard } from '../types.js';
5
5
 
6
- import type { SlippageGuardConfig } from './config.generated.js';
6
+ import type {
7
+ CoreNumericInvariantGuardConfig,
8
+ SlippageGuardConfig,
9
+ } from './config.generated.js';
7
10
 
8
11
  /** Assert that output amounts are within a slippage tolerance in basis points */
9
12
  export const slippage = <P extends string>(
@@ -12,3 +15,11 @@ export const slippage = <P extends string>(
12
15
  kind: 'slippage',
13
16
  ...config,
14
17
  });
18
+
19
+ /** Assert a numeric (uint256) handle output of the target op satisfies a comparison against a constant threshold. Emits one IR1 binary invariant; reverts the run on violation. */
20
+ export const coreNumericInvariant = <P extends string>(
21
+ config: Omit<CoreNumericInvariantGuardConfig, 'port'> & { port: P },
22
+ ): TypedGuard<P> => ({
23
+ kind: 'core.numericInvariant',
24
+ ...config,
25
+ });