@lifi/composer-sdk 0.0.1-alpha → 0.2.0-staging.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -1
- package/dist/authoring/signatureArgs.cjs +2 -2
- package/dist/authoring/signatureArgs.cjs.map +1 -1
- package/dist/authoring/signatureArgs.js +2 -2
- package/dist/authoring/signatureArgs.js.map +1 -1
- package/dist/client.cjs +2 -2
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +2 -2
- package/dist/client.js.map +1 -1
- package/dist/generated/config.generated.cjs.map +1 -1
- package/dist/generated/config.generated.d.cts +307 -16
- package/dist/generated/config.generated.d.ts +307 -16
- package/dist/generated/guards.generated.cjs +6 -0
- package/dist/generated/guards.generated.cjs.map +1 -1
- package/dist/generated/guards.generated.d.cts +1 -1
- package/dist/generated/guards.generated.d.ts +1 -1
- package/dist/generated/guards.generated.js +5 -0
- package/dist/generated/guards.generated.js.map +1 -1
- package/dist/generated/materialisers.generated.cjs +8 -2
- package/dist/generated/materialisers.generated.cjs.map +1 -1
- package/dist/generated/materialisers.generated.d.cts +1 -1
- package/dist/generated/materialisers.generated.d.ts +1 -1
- package/dist/generated/materialisers.generated.js +6 -1
- package/dist/generated/materialisers.generated.js.map +1 -1
- package/dist/generated/operations.generated.cjs +84 -14
- package/dist/generated/operations.generated.cjs.map +1 -1
- package/dist/generated/operations.generated.d.cts +208 -13
- package/dist/generated/operations.generated.d.ts +208 -13
- package/dist/generated/operations.generated.js +84 -14
- package/dist/generated/operations.generated.js.map +1 -1
- package/dist/guards.generated-BPLFwe7y.d.ts +19 -0
- package/dist/guards.generated-M3VAIevI.d.cts +19 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/materialisers.generated-BfWJ-g7t.d.ts +29 -0
- package/dist/materialisers.generated-DaJRwiRe.d.cts +29 -0
- package/dist/run/inputs.cjs +8 -5
- package/dist/run/inputs.cjs.map +1 -1
- package/dist/run/inputs.d.cts +8 -0
- package/dist/run/inputs.d.ts +8 -0
- package/dist/run/inputs.js +8 -5
- package/dist/run/inputs.js.map +1 -1
- package/dist/sdk.cjs +1 -0
- package/dist/sdk.cjs.map +1 -1
- package/dist/sdk.js +1 -0
- package/dist/sdk.js.map +1 -1
- package/package.json +16 -7
- package/src/authoring/signatureArgs.ts +2 -2
- package/src/client.ts +1 -1
- package/src/examples/aaveClaimRewards.ts +80 -0
- package/src/examples/aaveRepay.ts +69 -0
- package/src/examples/aaveRepayWithATokens.ts +81 -0
- package/src/examples/aaveSetEMode.ts +68 -0
- package/src/examples/run.ts +41 -4
- package/src/examples/swapToRecipient.ts +0 -19
- package/src/examples/swapWithFee.ts +59 -0
- package/src/generated/config.generated.ts +364 -18
- package/src/generated/guards.generated.ts +12 -1
- package/src/generated/materialisers.generated.ts +24 -12
- package/src/generated/operations.generated.ts +373 -13
- package/src/run/inputs.ts +16 -5
- package/src/sdk.ts +1 -0
- package/dist/guards.generated-DKKDKREA.d.ts +0 -14
- package/dist/guards.generated-hrQ1KPNv.d.cts +0 -14
- package/dist/materialisers.generated-BsA1uDW8.d.ts +0 -24
- package/dist/materialisers.generated-nMxTAaVi.d.cts +0 -24
|
@@ -18,6 +18,12 @@ import {
|
|
|
18
18
|
import type { TypedGuard } from '../types.js';
|
|
19
19
|
|
|
20
20
|
import type {
|
|
21
|
+
AaveBorrowConfig,
|
|
22
|
+
AaveClaimRewardsConfig,
|
|
23
|
+
AaveGetHealthFactorConfig,
|
|
24
|
+
AaveRepayConfig,
|
|
25
|
+
AaveRepayWithATokensConfig,
|
|
26
|
+
AaveSetEModeConfig,
|
|
21
27
|
CoreApproveConfig,
|
|
22
28
|
CoreAsResourceConfig,
|
|
23
29
|
CoreBalanceOfConfig,
|
|
@@ -29,8 +35,17 @@ import type {
|
|
|
29
35
|
CoreSplitConfig,
|
|
30
36
|
CoreStaticCallConfig,
|
|
31
37
|
CoreTransferConfig,
|
|
38
|
+
LifiFlashloanRepayConfig,
|
|
32
39
|
LifiSwapConfig,
|
|
33
40
|
LifiZapConfig,
|
|
41
|
+
MorphoBlueBorrowConfig,
|
|
42
|
+
MorphoBlueGetPositionConfig,
|
|
43
|
+
MorphoBlueRepayConfig,
|
|
44
|
+
MorphoBlueSupplyCollateralConfig,
|
|
45
|
+
MorphoBlueSupplyConfig,
|
|
46
|
+
MorphoBlueWithdrawCollateralConfig,
|
|
47
|
+
MorphoBlueWithdrawConfig,
|
|
48
|
+
ParaswapBuyConfig,
|
|
34
49
|
} from './config.generated.js';
|
|
35
50
|
|
|
36
51
|
/** Split a resource into two outputs by basis-point ratio */
|
|
@@ -69,15 +84,6 @@ export interface InvariantBalanceAtLeastArgs {
|
|
|
69
84
|
readonly guards?: readonly TypedGuard<never>[];
|
|
70
85
|
}
|
|
71
86
|
|
|
72
|
-
/** Route tokens into a DeFi protocol position via the edge catalog */
|
|
73
|
-
export interface LifiZapArgs {
|
|
74
|
-
readonly bind: {
|
|
75
|
-
readonly amountIn: Bindable<'resource'>;
|
|
76
|
-
};
|
|
77
|
-
readonly config: LifiZapConfig;
|
|
78
|
-
readonly guards?: readonly TypedGuard<'amountOut'>[];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
87
|
/** Add two unsigned integers (a + b) */
|
|
82
88
|
export interface CoreAddArgs {
|
|
83
89
|
readonly bind: {
|
|
@@ -266,6 +272,145 @@ export interface CoreAsResourceArgs {
|
|
|
266
272
|
readonly guards?: readonly TypedGuard<'resource'>[];
|
|
267
273
|
}
|
|
268
274
|
|
|
275
|
+
/** Borrow an asset from an Aave v3 pool against existing collateral, exposing the borrowed asset as a Resource */
|
|
276
|
+
export interface AaveBorrowArgs {
|
|
277
|
+
readonly bind: Record<string, never>;
|
|
278
|
+
readonly config: AaveBorrowConfig;
|
|
279
|
+
readonly guards?: readonly TypedGuard<'debtBalance'>[];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** 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. */
|
|
283
|
+
export interface AaveRepayArgs {
|
|
284
|
+
readonly bind: {
|
|
285
|
+
readonly assetIn: Bindable<'resource'>;
|
|
286
|
+
readonly onBehalfOf: Bindable<'address'>;
|
|
287
|
+
};
|
|
288
|
+
readonly config: AaveRepayConfig;
|
|
289
|
+
readonly guards?: readonly TypedGuard<'actualRepaid' | 'residual'>[];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Repay an Aave v3 variable-rate debt by burning the caller's aToken balance, returning any unspent residual */
|
|
293
|
+
export interface AaveRepayWithATokensArgs {
|
|
294
|
+
readonly bind: {
|
|
295
|
+
readonly aTokenIn: Bindable<'resource'>;
|
|
296
|
+
};
|
|
297
|
+
readonly config: AaveRepayWithATokensConfig;
|
|
298
|
+
readonly guards?: readonly TypedGuard<'actualRepaid' | 'residual'>[];
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Claim a specific Aave v3 incentives reward token against a set of receipt-token positions, exposing the claimed amount as a Resource */
|
|
302
|
+
export interface AaveClaimRewardsArgs {
|
|
303
|
+
readonly bind: Record<string, never>;
|
|
304
|
+
readonly config: AaveClaimRewardsConfig;
|
|
305
|
+
readonly guards?: readonly TypedGuard<'claimedAmount'>[];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** 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. */
|
|
309
|
+
export interface AaveSetEModeArgs {
|
|
310
|
+
readonly bind: Record<string, never>;
|
|
311
|
+
readonly config: AaveSetEModeConfig;
|
|
312
|
+
readonly guards?: readonly TypedGuard<never>[];
|
|
313
|
+
}
|
|
314
|
+
|
|
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
|
+
/** 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
|
+
export interface MorphoBlueSupplyCollateralArgs {
|
|
324
|
+
readonly bind: {
|
|
325
|
+
readonly assetIn: Bindable<'resource'>;
|
|
326
|
+
};
|
|
327
|
+
readonly config: MorphoBlueSupplyCollateralConfig;
|
|
328
|
+
readonly guards?: readonly TypedGuard<never>[];
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** Withdraw collateral from a Morpho Blue market position to the receiver address. Exposes the withdrawn ERC20 amount as a Resource output. */
|
|
332
|
+
export interface MorphoBlueWithdrawCollateralArgs {
|
|
333
|
+
readonly bind: Record<string, never>;
|
|
334
|
+
readonly config: MorphoBlueWithdrawCollateralConfig;
|
|
335
|
+
readonly guards?: readonly TypedGuard<'collateralWithdrawn'>[];
|
|
336
|
+
}
|
|
337
|
+
|
|
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
|
+
/** Route tokens into a DeFi protocol position via the edge catalog */
|
|
397
|
+
export interface LifiZapArgs {
|
|
398
|
+
readonly bind: {
|
|
399
|
+
readonly amountIn: Bindable<'resource'>;
|
|
400
|
+
};
|
|
401
|
+
readonly config: LifiZapConfig;
|
|
402
|
+
readonly guards?: readonly TypedGuard<'amountOut'>[];
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** 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`. */
|
|
406
|
+
export interface ParaswapBuyArgs {
|
|
407
|
+
readonly bind: {
|
|
408
|
+
readonly amountIn: Bindable<'resource'>;
|
|
409
|
+
};
|
|
410
|
+
readonly config: ParaswapBuyConfig;
|
|
411
|
+
readonly guards?: readonly TypedGuard<'unspentIn'>[];
|
|
412
|
+
}
|
|
413
|
+
|
|
269
414
|
/** Read a smart contract value at compile time (off-chain eth_call); result is baked as a literal */
|
|
270
415
|
export interface CorePeekArgs {
|
|
271
416
|
readonly bind: Record<string, never>;
|
|
@@ -287,10 +432,6 @@ export interface LifiSwapOutputs {
|
|
|
287
432
|
readonly unspentIn: OutputHandle<'resource'>;
|
|
288
433
|
}
|
|
289
434
|
|
|
290
|
-
export interface LifiZapOutputs {
|
|
291
|
-
readonly amountOut: OutputHandle<'resource'>;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
435
|
export interface CoreAddOutputs {
|
|
295
436
|
readonly result: OutputHandle<'uint256'>;
|
|
296
437
|
}
|
|
@@ -336,6 +477,74 @@ export interface CoreAsResourceOutputs {
|
|
|
336
477
|
readonly resource: OutputHandle<'resource'>;
|
|
337
478
|
}
|
|
338
479
|
|
|
480
|
+
export interface AaveBorrowOutputs {
|
|
481
|
+
readonly borrowed: OutputHandle<'resource'>;
|
|
482
|
+
readonly debtBalance: OutputHandle<'uint256'>;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export interface AaveRepayOutputs {
|
|
486
|
+
readonly actualRepaid: OutputHandle<'uint256'>;
|
|
487
|
+
readonly residual: OutputHandle<'resource'>;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export interface AaveRepayWithATokensOutputs {
|
|
491
|
+
readonly actualRepaid: OutputHandle<'uint256'>;
|
|
492
|
+
readonly residual: OutputHandle<'resource'>;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export interface AaveClaimRewardsOutputs {
|
|
496
|
+
readonly claimed: OutputHandle<'resource'>;
|
|
497
|
+
readonly claimedAmount: OutputHandle<'uint256'>;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
export interface AaveGetHealthFactorOutputs {
|
|
501
|
+
readonly healthFactor: OutputHandle<'uint256'>;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export interface MorphoBlueWithdrawCollateralOutputs {
|
|
505
|
+
readonly withdrawn: OutputHandle<'resource'>;
|
|
506
|
+
readonly collateralWithdrawn: OutputHandle<'uint256'>;
|
|
507
|
+
}
|
|
508
|
+
|
|
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
|
+
export interface LifiZapOutputs {
|
|
540
|
+
readonly amountOut: OutputHandle<'resource'>;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export interface ParaswapBuyOutputs {
|
|
544
|
+
readonly amountOut: OutputHandle<'resource'>;
|
|
545
|
+
readonly unspentIn: OutputHandle<'resource'>;
|
|
546
|
+
}
|
|
547
|
+
|
|
339
548
|
export interface CorePeekOutputs {
|
|
340
549
|
readonly result: OutputHandle<'uint256'>;
|
|
341
550
|
}
|
|
@@ -433,6 +642,11 @@ export type GeneratedOps = {
|
|
|
433
642
|
readonly lifi: {
|
|
434
643
|
/** Swap tokens via the LI.FI aggregator API — original id: "lifi.swap" */
|
|
435
644
|
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;
|
|
436
650
|
/** Route tokens into a DeFi protocol position via the edge catalog — original id: "lifi.zap" */
|
|
437
651
|
readonly zap: (nodeId: string, args: LifiZapArgs) => LifiZapOutputs;
|
|
438
652
|
};
|
|
@@ -443,6 +657,73 @@ export type GeneratedOps = {
|
|
|
443
657
|
args: InvariantBalanceAtLeastArgs,
|
|
444
658
|
) => void;
|
|
445
659
|
};
|
|
660
|
+
readonly aave: {
|
|
661
|
+
/** Borrow an asset from an Aave v3 pool against existing collateral, exposing the borrowed asset as a Resource — original id: "aave.borrow" */
|
|
662
|
+
readonly borrow: (
|
|
663
|
+
nodeId: string,
|
|
664
|
+
args: AaveBorrowArgs,
|
|
665
|
+
) => AaveBorrowOutputs;
|
|
666
|
+
/** 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" */
|
|
667
|
+
readonly repay: (nodeId: string, args: AaveRepayArgs) => AaveRepayOutputs;
|
|
668
|
+
/** Repay an Aave v3 variable-rate debt by burning the caller's aToken balance, returning any unspent residual — original id: "aave.repayWithATokens" */
|
|
669
|
+
readonly repayWithATokens: (
|
|
670
|
+
nodeId: string,
|
|
671
|
+
args: AaveRepayWithATokensArgs,
|
|
672
|
+
) => AaveRepayWithATokensOutputs;
|
|
673
|
+
/** 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" */
|
|
674
|
+
readonly claimRewards: (
|
|
675
|
+
nodeId: string,
|
|
676
|
+
args: AaveClaimRewardsArgs,
|
|
677
|
+
) => AaveClaimRewardsOutputs;
|
|
678
|
+
/** 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
|
+
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
|
+
};
|
|
686
|
+
readonly morphoBlue: {
|
|
687
|
+
/** 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" */
|
|
688
|
+
readonly supplyCollateral: (
|
|
689
|
+
nodeId: string,
|
|
690
|
+
args: MorphoBlueSupplyCollateralArgs,
|
|
691
|
+
) => void;
|
|
692
|
+
/** 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" */
|
|
693
|
+
readonly withdrawCollateral: (
|
|
694
|
+
nodeId: string,
|
|
695
|
+
args: MorphoBlueWithdrawCollateralArgs,
|
|
696
|
+
) => 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
|
+
};
|
|
723
|
+
readonly paraswap: {
|
|
724
|
+
/** 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" */
|
|
725
|
+
readonly buy: (nodeId: string, args: ParaswapBuyArgs) => ParaswapBuyOutputs;
|
|
726
|
+
};
|
|
446
727
|
};
|
|
447
728
|
|
|
448
729
|
export const bindGeneratedOps = (
|
|
@@ -551,6 +832,8 @@ export const bindGeneratedOps = (
|
|
|
551
832
|
amountOut: 'resource',
|
|
552
833
|
unspentIn: 'resource',
|
|
553
834
|
} as const),
|
|
835
|
+
flashloanRepay: (nodeId: string, args: LifiFlashloanRepayArgs) =>
|
|
836
|
+
builder.call(nodeId, 'lifi.flashloanRepay', args, {}),
|
|
554
837
|
zap: (nodeId: string, args: LifiZapArgs) =>
|
|
555
838
|
builder.call(nodeId, 'lifi.zap', args, {
|
|
556
839
|
amountOut: 'resource',
|
|
@@ -565,4 +848,81 @@ export const bindGeneratedOps = (
|
|
|
565
848
|
{},
|
|
566
849
|
),
|
|
567
850
|
},
|
|
851
|
+
aave: {
|
|
852
|
+
borrow: (nodeId: string, args: AaveBorrowArgs) =>
|
|
853
|
+
builder.call(nodeId, 'aave.borrow', args, {
|
|
854
|
+
borrowed: 'resource',
|
|
855
|
+
debtBalance: 'uint256',
|
|
856
|
+
} as const),
|
|
857
|
+
repay: (nodeId: string, args: AaveRepayArgs) =>
|
|
858
|
+
builder.call(nodeId, 'aave.repay', args, {
|
|
859
|
+
actualRepaid: 'uint256',
|
|
860
|
+
residual: 'resource',
|
|
861
|
+
} as const),
|
|
862
|
+
repayWithATokens: (nodeId: string, args: AaveRepayWithATokensArgs) =>
|
|
863
|
+
builder.call(nodeId, 'aave.repayWithATokens', args, {
|
|
864
|
+
actualRepaid: 'uint256',
|
|
865
|
+
residual: 'resource',
|
|
866
|
+
} as const),
|
|
867
|
+
claimRewards: (nodeId: string, args: AaveClaimRewardsArgs) =>
|
|
868
|
+
builder.call(nodeId, 'aave.claimRewards', args, {
|
|
869
|
+
claimed: 'resource',
|
|
870
|
+
claimedAmount: 'uint256',
|
|
871
|
+
} as const),
|
|
872
|
+
setEMode: (nodeId: string, args: AaveSetEModeArgs) =>
|
|
873
|
+
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
|
+
},
|
|
879
|
+
morphoBlue: {
|
|
880
|
+
supplyCollateral: (nodeId: string, args: MorphoBlueSupplyCollateralArgs) =>
|
|
881
|
+
builder.call(nodeId, 'morphoBlue.supplyCollateral', args, {}),
|
|
882
|
+
withdrawCollateral: (
|
|
883
|
+
nodeId: string,
|
|
884
|
+
args: MorphoBlueWithdrawCollateralArgs,
|
|
885
|
+
) =>
|
|
886
|
+
builder.call(nodeId, 'morphoBlue.withdrawCollateral', args, {
|
|
887
|
+
withdrawn: 'resource',
|
|
888
|
+
collateralWithdrawn: 'uint256',
|
|
889
|
+
} 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
|
+
},
|
|
921
|
+
paraswap: {
|
|
922
|
+
buy: (nodeId: string, args: ParaswapBuyArgs) =>
|
|
923
|
+
builder.call(nodeId, 'paraswap.buy', args, {
|
|
924
|
+
amountOut: 'resource',
|
|
925
|
+
unspentIn: 'resource',
|
|
926
|
+
} as const),
|
|
927
|
+
},
|
|
568
928
|
});
|
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
|
|
107
|
-
...(run.
|
|
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
|
|
111
|
-
...(run.simulationPolicy
|
|
121
|
+
...(run.sweepTo !== undefined && { sweepTo: run.sweepTo }),
|
|
122
|
+
...(run.simulationPolicy !== undefined && {
|
|
112
123
|
simulationPolicy: run.simulationPolicy,
|
|
113
124
|
}),
|
|
114
|
-
...(run.checkOnChainAllowances
|
|
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 };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MaterialiserConfigOf, MaterialiserInput } from '@lifi/compose-spec';
|
|
2
|
-
import { BalanceOfMaterialiserConfig, CallMaterialiserConfig, DirectDepositMaterialiserConfig } from './generated/config.generated.js';
|
|
3
|
-
|
|
4
|
-
type BalanceOfMaterialiserInput = MaterialiserConfigOf<BalanceOfMaterialiserConfig>;
|
|
5
|
-
/** Read the on-chain token balance of an address as the input amount — accepts: resource */
|
|
6
|
-
declare const balanceOf: (config: BalanceOfMaterialiserInput) => MaterialiserInput;
|
|
7
|
-
type DirectDepositMaterialiserInput = MaterialiserConfigOf<DirectDepositMaterialiserConfig>;
|
|
8
|
-
/** Deposit tokens into the VM — native via msg.value, ERC-20 via transferFrom — accepts: resource */
|
|
9
|
-
declare const directDeposit: (config: DirectDepositMaterialiserInput) => MaterialiserInput;
|
|
10
|
-
type CallMaterialiserInput = MaterialiserConfigOf<CallMaterialiserConfig>;
|
|
11
|
-
/** Execute an arbitrary contract call and measure the resulting token balance diff — accepts: resource */
|
|
12
|
-
declare const call: (config: CallMaterialiserInput) => MaterialiserInput;
|
|
13
|
-
|
|
14
|
-
type materialisersMod_BalanceOfMaterialiserInput = BalanceOfMaterialiserInput;
|
|
15
|
-
type materialisersMod_CallMaterialiserInput = CallMaterialiserInput;
|
|
16
|
-
type materialisersMod_DirectDepositMaterialiserInput = DirectDepositMaterialiserInput;
|
|
17
|
-
declare const materialisersMod_balanceOf: typeof balanceOf;
|
|
18
|
-
declare const materialisersMod_call: typeof call;
|
|
19
|
-
declare const materialisersMod_directDeposit: typeof directDeposit;
|
|
20
|
-
declare namespace materialisersMod {
|
|
21
|
-
export { type materialisersMod_BalanceOfMaterialiserInput as BalanceOfMaterialiserInput, type materialisersMod_CallMaterialiserInput as CallMaterialiserInput, type materialisersMod_DirectDepositMaterialiserInput as DirectDepositMaterialiserInput, materialisersMod_balanceOf as balanceOf, materialisersMod_call as call, materialisersMod_directDeposit as directDeposit };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { type BalanceOfMaterialiserInput as B, type CallMaterialiserInput as C, type DirectDepositMaterialiserInput as D, balanceOf as b, call as c, directDeposit as d, materialisersMod as m };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MaterialiserConfigOf, MaterialiserInput } from '@lifi/compose-spec';
|
|
2
|
-
import { BalanceOfMaterialiserConfig, CallMaterialiserConfig, DirectDepositMaterialiserConfig } from './generated/config.generated.cjs';
|
|
3
|
-
|
|
4
|
-
type BalanceOfMaterialiserInput = MaterialiserConfigOf<BalanceOfMaterialiserConfig>;
|
|
5
|
-
/** Read the on-chain token balance of an address as the input amount — accepts: resource */
|
|
6
|
-
declare const balanceOf: (config: BalanceOfMaterialiserInput) => MaterialiserInput;
|
|
7
|
-
type DirectDepositMaterialiserInput = MaterialiserConfigOf<DirectDepositMaterialiserConfig>;
|
|
8
|
-
/** Deposit tokens into the VM — native via msg.value, ERC-20 via transferFrom — accepts: resource */
|
|
9
|
-
declare const directDeposit: (config: DirectDepositMaterialiserInput) => MaterialiserInput;
|
|
10
|
-
type CallMaterialiserInput = MaterialiserConfigOf<CallMaterialiserConfig>;
|
|
11
|
-
/** Execute an arbitrary contract call and measure the resulting token balance diff — accepts: resource */
|
|
12
|
-
declare const call: (config: CallMaterialiserInput) => MaterialiserInput;
|
|
13
|
-
|
|
14
|
-
type materialisersMod_BalanceOfMaterialiserInput = BalanceOfMaterialiserInput;
|
|
15
|
-
type materialisersMod_CallMaterialiserInput = CallMaterialiserInput;
|
|
16
|
-
type materialisersMod_DirectDepositMaterialiserInput = DirectDepositMaterialiserInput;
|
|
17
|
-
declare const materialisersMod_balanceOf: typeof balanceOf;
|
|
18
|
-
declare const materialisersMod_call: typeof call;
|
|
19
|
-
declare const materialisersMod_directDeposit: typeof directDeposit;
|
|
20
|
-
declare namespace materialisersMod {
|
|
21
|
-
export { type materialisersMod_BalanceOfMaterialiserInput as BalanceOfMaterialiserInput, type materialisersMod_CallMaterialiserInput as CallMaterialiserInput, type materialisersMod_DirectDepositMaterialiserInput as DirectDepositMaterialiserInput, materialisersMod_balanceOf as balanceOf, materialisersMod_call as call, materialisersMod_directDeposit as directDeposit };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { type BalanceOfMaterialiserInput as B, type CallMaterialiserInput as C, type DirectDepositMaterialiserInput as D, balanceOf as b, call as c, directDeposit as d, materialisersMod as m };
|