@lifi/composer-sdk 0.7.0 → 0.7.1
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 +4 -0
- package/dist/authoring/FlowBuilderCore.cjs +1 -1
- package/dist/authoring/FlowBuilderCore.cjs.map +1 -1
- package/dist/authoring/FlowBuilderCore.js +1 -1
- package/dist/authoring/FlowBuilderCore.js.map +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.js +1 -1
- package/dist/generated/operations.generated.cjs +29 -1
- package/dist/generated/operations.generated.cjs.map +1 -1
- package/dist/generated/operations.generated.d.cts +83 -2
- package/dist/generated/operations.generated.d.ts +83 -2
- package/dist/generated/operations.generated.js +29 -1
- package/dist/generated/operations.generated.js.map +1 -1
- package/package.json +2 -2
- package/src/authoring/FlowBuilderCore.ts +4 -1
- package/src/examples/aaveBorrow.ts +129 -0
- package/src/examples/aaveHealthFactorExplode.ts +63 -0
- package/src/examples/morphoBlueBorrow.ts +94 -0
- package/src/examples/morphoBlueRepay.ts +133 -0
- package/src/examples/run.ts +30 -0
- package/src/generated/operations.generated.ts +159 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
2
|
+
|
|
3
|
+
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
|
+
import type { Address } from '../types.js';
|
|
5
|
+
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
|
+
|
|
8
|
+
// Morpho Blue WETH/USDC market on Base (chainId 8453).
|
|
9
|
+
const ADAPTIVE_CURVE_IRM_BASE = '0x46415998764C29aB2a25CbeA6254146D50D22687';
|
|
10
|
+
const BASE_USDC = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';
|
|
11
|
+
const BASE_WETH = '0x4200000000000000000000000000000000000006';
|
|
12
|
+
const WETH_USDC_ORACLE = '0xFEa2D58cEfCb9fcb597723c6bAE66fFE4193aFE4';
|
|
13
|
+
const WETH_USDC_LLTV = '860000000000000000';
|
|
14
|
+
|
|
15
|
+
const WETH_USDC_MARKET = {
|
|
16
|
+
loanToken: BASE_USDC,
|
|
17
|
+
collateralToken: BASE_WETH,
|
|
18
|
+
oracle: WETH_USDC_ORACLE,
|
|
19
|
+
irm: ADAPTIVE_CURVE_IRM_BASE,
|
|
20
|
+
lltv: WETH_USDC_LLTV,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export interface MorphoBlueRepayInput {
|
|
24
|
+
readonly owner: Address;
|
|
25
|
+
/** WETH supplied as collateral for the in-flow borrow (18 dp). */
|
|
26
|
+
readonly collateralAmount: `${bigint}`;
|
|
27
|
+
/** USDC borrowed against the collateral, then repaid by this flow (6 dp). */
|
|
28
|
+
readonly borrowAmount: `${bigint}`;
|
|
29
|
+
/**
|
|
30
|
+
* USDC deposited to repay the debt (6 dp). Must exceed `borrowAmount`:
|
|
31
|
+
* Morpho's share rounding can leave the debt a wei above the borrowed
|
|
32
|
+
* amount, so the `max`-mode repay needs a little headroom. The leftover
|
|
33
|
+
* surfaces on the `residual` port.
|
|
34
|
+
*/
|
|
35
|
+
readonly repayAmount: `${bigint}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Open and close a Morpho Blue WETH/USDC position on Base in one flow —
|
|
40
|
+
* a self-contained supplyCollateral → borrow → repay → withdrawCollateral
|
|
41
|
+
* round trip that creates the debt it retires.
|
|
42
|
+
*
|
|
43
|
+
* Demonstrates:
|
|
44
|
+
* - `morphoBlue.supplyCollateral` to post WETH (collateral is internal
|
|
45
|
+
* position state — no receipt token).
|
|
46
|
+
* - `morphoBlue.borrow` to mint USDC debt against it.
|
|
47
|
+
* - `morphoBlue.repay` with `mode: 'max'`, which reads the proxy's current
|
|
48
|
+
* `borrowShares` on-chain and repays in shares mode to retire the debt to
|
|
49
|
+
* the wei. Unused USDC surfaces on the `residual` Resource port.
|
|
50
|
+
* - `morphoBlue.withdrawCollateral` to pull the freed WETH once the debt
|
|
51
|
+
* is cleared.
|
|
52
|
+
* - `sweepTo` to return the borrowed USDC, the repay residual, and the
|
|
53
|
+
* freed WETH to the signer.
|
|
54
|
+
*/
|
|
55
|
+
export const buildMorphoBlueRepay = ({
|
|
56
|
+
owner,
|
|
57
|
+
collateralAmount,
|
|
58
|
+
borrowAmount,
|
|
59
|
+
repayAmount,
|
|
60
|
+
}: MorphoBlueRepayInput): {
|
|
61
|
+
flow: Flow;
|
|
62
|
+
request: ComposeCompileRequest;
|
|
63
|
+
} => {
|
|
64
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
65
|
+
|
|
66
|
+
const builder = sdk.flow(8453, {
|
|
67
|
+
name: 'morpho-blue-repay-usdc-withdraw-weth',
|
|
68
|
+
inputs: {
|
|
69
|
+
collateralIn: resources.erc20(BASE_WETH, 8453),
|
|
70
|
+
repayIn: resources.erc20(BASE_USDC, 8453),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Post WETH collateral so the proxy can open the debt it will repay.
|
|
75
|
+
builder.morphoBlue.supplyCollateral('supply-collateral', {
|
|
76
|
+
bind: {
|
|
77
|
+
assetIn: builder.inputs.collateralIn,
|
|
78
|
+
},
|
|
79
|
+
config: {
|
|
80
|
+
marketParams: WETH_USDC_MARKET,
|
|
81
|
+
mode: 'exact',
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Borrow USDC against the collateral; the borrowed USDC stays on the
|
|
86
|
+
// proxy as a terminal resource and is swept back to the signer.
|
|
87
|
+
builder.morphoBlue.borrow('borrow', {
|
|
88
|
+
bind: {},
|
|
89
|
+
config: {
|
|
90
|
+
marketParams: WETH_USDC_MARKET,
|
|
91
|
+
amount: borrowAmount,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Retire the just-opened debt from the deposited USDC. mode 'max' reads
|
|
96
|
+
// the live borrowShares and repays in shares mode, clearing the debt to
|
|
97
|
+
// the wei; the unused USDC surfaces on the `residual` port.
|
|
98
|
+
builder.morphoBlue.repay('repay', {
|
|
99
|
+
bind: {
|
|
100
|
+
assetIn: builder.inputs.repayIn,
|
|
101
|
+
onBehalfOf: builder.context.executionAddress,
|
|
102
|
+
},
|
|
103
|
+
config: {
|
|
104
|
+
marketParams: WETH_USDC_MARKET,
|
|
105
|
+
mode: 'max',
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// The debt is cleared, so the full collateral can be withdrawn. The freed
|
|
110
|
+
// WETH lands on the proxy and is swept to the signer.
|
|
111
|
+
builder.morphoBlue.withdrawCollateral('withdraw-collateral', {
|
|
112
|
+
bind: {},
|
|
113
|
+
config: {
|
|
114
|
+
marketParams: WETH_USDC_MARKET,
|
|
115
|
+
amount: collateralAmount,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const flow = builder.build();
|
|
120
|
+
|
|
121
|
+
const request = sdk.request(flow, {
|
|
122
|
+
signer: owner,
|
|
123
|
+
inputs: {
|
|
124
|
+
collateralIn: materialisers.directDeposit({ amount: collateralAmount }),
|
|
125
|
+
repayIn: materialisers.directDeposit({ amount: repayAmount }),
|
|
126
|
+
},
|
|
127
|
+
// Sweep the borrowed USDC, the repay residual, and the freed WETH back
|
|
128
|
+
// to the signer.
|
|
129
|
+
sweepTo: builder.context.sender,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
return { flow, request };
|
|
133
|
+
};
|
package/src/examples/run.ts
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
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-borrow — supply USDC to Aave v3, borrow against it with a health-factor guard
|
|
12
|
+
* aave-hf-explode — read the Aave v3 health factor and assert it stays >= 1.0
|
|
11
13
|
* aave-repay — repay an Aave v3 WETH debt by supplying WETH
|
|
12
14
|
* aave-repay-atoken — repay an Aave v3 USDC debt by burning proxy aTokens
|
|
13
15
|
* aave-emode — switch the proxy's Aave v3 eMode category
|
|
@@ -21,6 +23,8 @@
|
|
|
21
23
|
* split-arithmetic — split USDC 70/30 with arithmetic assertions
|
|
22
24
|
* zap — zap USDC into Aave lending position
|
|
23
25
|
* zap-async — zap USDC into an async Aave position (future output)
|
|
26
|
+
* morpho-borrow — supply WETH collateral to Morpho Blue and borrow USDC
|
|
27
|
+
* morpho-repay — open, repay and close a Morpho Blue WETH/USDC position
|
|
24
28
|
* fly-swap — exit a Pendle PT position and swap ALL proceeds to WETH
|
|
25
29
|
* swap-zap — swap WETH to USDC then zap into Aave
|
|
26
30
|
* swap-check — swap WETH to USDC with balance check
|
|
@@ -46,6 +50,8 @@ import type {
|
|
|
46
50
|
import { bigintReplacer } from '../client.js';
|
|
47
51
|
import { type ComposeSdk, createComposeSdk } from '../sdk.js';
|
|
48
52
|
|
|
53
|
+
import { buildAaveBorrow } from './aaveBorrow.js';
|
|
54
|
+
import { buildAaveHealthFactorExplode } from './aaveHealthFactorExplode.js';
|
|
49
55
|
import { buildAaveRepay } from './aaveRepay.js';
|
|
50
56
|
import { buildAaveRepayWithATokens } from './aaveRepayWithATokens.js';
|
|
51
57
|
import { buildAaveSetEMode } from './aaveSetEMode.js';
|
|
@@ -60,6 +66,8 @@ import { buildFlySwapExample } from './flySwap.js';
|
|
|
60
66
|
import { buildLifiSwapExample } from './lifiSwap.js';
|
|
61
67
|
import { buildLifiZapExample } from './lifiZap.js';
|
|
62
68
|
import { buildLifiZapAsyncExample } from './lifiZapAsync.js';
|
|
69
|
+
import { buildMorphoBlueBorrow } from './morphoBlueBorrow.js';
|
|
70
|
+
import { buildMorphoBlueRepay } from './morphoBlueRepay.js';
|
|
63
71
|
import { buildRawCallWithArithmetic } from './rawCallWithArithmetic.js';
|
|
64
72
|
import { buildReadContractState } from './readContractState.js';
|
|
65
73
|
import {
|
|
@@ -81,6 +89,15 @@ const stringifyJson = (value: unknown) =>
|
|
|
81
89
|
JSON.stringify(value, bigintReplacer, 2);
|
|
82
90
|
|
|
83
91
|
const EXAMPLES: Record<string, () => ComposeCompileRequest> = {
|
|
92
|
+
'aave-borrow': () =>
|
|
93
|
+
buildAaveBorrow({
|
|
94
|
+
owner: OWNER,
|
|
95
|
+
recipient: RECIPIENT,
|
|
96
|
+
collateralAmount: '1000000000',
|
|
97
|
+
borrowAmount: '500000000',
|
|
98
|
+
}).request,
|
|
99
|
+
'aave-hf-explode': () =>
|
|
100
|
+
buildAaveHealthFactorExplode({ signer: OWNER }).request,
|
|
84
101
|
'aave-repay': () =>
|
|
85
102
|
buildAaveRepay({
|
|
86
103
|
owner: OWNER,
|
|
@@ -128,6 +145,19 @@ const EXAMPLES: Record<string, () => ComposeCompileRequest> = {
|
|
|
128
145
|
'zap-async': () =>
|
|
129
146
|
buildLifiZapAsyncExample({ owner: OWNER, recipient: RECIPIENT }).request,
|
|
130
147
|
'fly-swap': () => buildFlySwapExample().request,
|
|
148
|
+
'morpho-borrow': () =>
|
|
149
|
+
buildMorphoBlueBorrow({
|
|
150
|
+
owner: OWNER,
|
|
151
|
+
collateralAmount: '1000000000000000000',
|
|
152
|
+
borrowAmount: '1200000000',
|
|
153
|
+
}).request,
|
|
154
|
+
'morpho-repay': () =>
|
|
155
|
+
buildMorphoBlueRepay({
|
|
156
|
+
owner: OWNER,
|
|
157
|
+
collateralAmount: '1000000000000000000',
|
|
158
|
+
borrowAmount: '500000000',
|
|
159
|
+
repayAmount: '501000000',
|
|
160
|
+
}).request,
|
|
131
161
|
'swap-zap': () => buildSwapAndZapExample().request,
|
|
132
162
|
'swap-check': () =>
|
|
133
163
|
buildSwapWithBalanceCheck({ owner: OWNER, amount: '1000000000000000000' })
|
|
@@ -23,6 +23,7 @@ import type { TypedGuard } from '../types.js';
|
|
|
23
23
|
import type {
|
|
24
24
|
AaveBorrowConfig,
|
|
25
25
|
AaveClaimRewardsConfig,
|
|
26
|
+
AaveGetHealthFactorConfig,
|
|
26
27
|
AaveRepayConfig,
|
|
27
28
|
AaveRepayWithATokensConfig,
|
|
28
29
|
AaveSetEModeConfig,
|
|
@@ -55,8 +56,13 @@ import type {
|
|
|
55
56
|
LifiSwapConfig,
|
|
56
57
|
LifiZapAsyncConfig,
|
|
57
58
|
LifiZapConfig,
|
|
59
|
+
MorphoBlueBorrowConfig,
|
|
60
|
+
MorphoBlueGetPositionConfig,
|
|
61
|
+
MorphoBlueRepayConfig,
|
|
58
62
|
MorphoBlueSupplyCollateralConfig,
|
|
63
|
+
MorphoBlueSupplyConfig,
|
|
59
64
|
MorphoBlueWithdrawCollateralConfig,
|
|
65
|
+
MorphoBlueWithdrawConfig,
|
|
60
66
|
ParaswapBuyConfig,
|
|
61
67
|
} from './config.generated.js';
|
|
62
68
|
|
|
@@ -532,6 +538,13 @@ export interface AaveSetEModeArgs {
|
|
|
532
538
|
readonly guards?: readonly TypedGuard<never>[];
|
|
533
539
|
}
|
|
534
540
|
|
|
541
|
+
/** 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. */
|
|
542
|
+
export interface AaveGetHealthFactorArgs {
|
|
543
|
+
readonly bind: Record<string, never>;
|
|
544
|
+
readonly config: AaveGetHealthFactorConfig;
|
|
545
|
+
readonly guards?: readonly TypedGuard<'healthFactor'>[];
|
|
546
|
+
}
|
|
547
|
+
|
|
535
548
|
/** 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). */
|
|
536
549
|
export interface MorphoBlueSupplyCollateralArgs {
|
|
537
550
|
readonly bind: {
|
|
@@ -548,6 +561,54 @@ export interface MorphoBlueWithdrawCollateralArgs {
|
|
|
548
561
|
readonly guards?: readonly TypedGuard<'collateralWithdrawn'>[];
|
|
549
562
|
}
|
|
550
563
|
|
|
564
|
+
/** 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. */
|
|
565
|
+
export interface MorphoBlueBorrowArgs {
|
|
566
|
+
readonly bind: Record<string, never>;
|
|
567
|
+
readonly config: MorphoBlueBorrowConfig;
|
|
568
|
+
readonly guards?: readonly TypedGuard<'assetsBorrowed' | 'sharesBorrowed'>[];
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/** 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. */
|
|
572
|
+
export interface MorphoBlueRepayArgs {
|
|
573
|
+
readonly bind: {
|
|
574
|
+
readonly assetIn: Bindable<'resource'>;
|
|
575
|
+
readonly onBehalfOf: Bindable<'address'>;
|
|
576
|
+
};
|
|
577
|
+
readonly config: MorphoBlueRepayConfig;
|
|
578
|
+
readonly guards?: readonly TypedGuard<
|
|
579
|
+
'actualRepaid' | 'sharesRepaid' | 'residual'
|
|
580
|
+
>[];
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/** 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. */
|
|
584
|
+
export interface MorphoBlueSupplyArgs {
|
|
585
|
+
readonly bind: {
|
|
586
|
+
readonly assetIn: Bindable<'resource'>;
|
|
587
|
+
};
|
|
588
|
+
readonly config: MorphoBlueSupplyConfig;
|
|
589
|
+
readonly guards?: readonly TypedGuard<
|
|
590
|
+
'assetsSupplied' | 'sharesSupplied' | 'residual'
|
|
591
|
+
>[];
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/** 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. */
|
|
595
|
+
export interface MorphoBlueWithdrawArgs {
|
|
596
|
+
readonly bind: Record<string, never>;
|
|
597
|
+
readonly config: MorphoBlueWithdrawConfig;
|
|
598
|
+
readonly guards?: readonly TypedGuard<
|
|
599
|
+
'assetsWithdrawn' | 'sharesWithdrawn'
|
|
600
|
+
>[];
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/** 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). */
|
|
604
|
+
export interface MorphoBlueGetPositionArgs {
|
|
605
|
+
readonly bind: Record<string, never>;
|
|
606
|
+
readonly config: MorphoBlueGetPositionConfig;
|
|
607
|
+
readonly guards?: readonly TypedGuard<
|
|
608
|
+
'supplyShares' | 'borrowShares' | 'collateral'
|
|
609
|
+
>[];
|
|
610
|
+
}
|
|
611
|
+
|
|
551
612
|
/** Route tokens into a DeFi protocol position via the edge catalog */
|
|
552
613
|
export interface LifiZapArgs {
|
|
553
614
|
readonly bind: {
|
|
@@ -685,11 +746,45 @@ export interface AaveClaimRewardsOutputs {
|
|
|
685
746
|
readonly claimedAmount: OutputHandle<'uint256'>;
|
|
686
747
|
}
|
|
687
748
|
|
|
749
|
+
export interface AaveGetHealthFactorOutputs {
|
|
750
|
+
readonly healthFactor: OutputHandle<'uint256'>;
|
|
751
|
+
}
|
|
752
|
+
|
|
688
753
|
export interface MorphoBlueWithdrawCollateralOutputs {
|
|
689
754
|
readonly withdrawn: OutputHandle<'resource'>;
|
|
690
755
|
readonly collateralWithdrawn: OutputHandle<'uint256'>;
|
|
691
756
|
}
|
|
692
757
|
|
|
758
|
+
export interface MorphoBlueBorrowOutputs {
|
|
759
|
+
readonly borrowed: OutputHandle<'resource'>;
|
|
760
|
+
readonly assetsBorrowed: OutputHandle<'uint256'>;
|
|
761
|
+
readonly sharesBorrowed: OutputHandle<'uint256'>;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
export interface MorphoBlueRepayOutputs {
|
|
765
|
+
readonly actualRepaid: OutputHandle<'uint256'>;
|
|
766
|
+
readonly sharesRepaid: OutputHandle<'uint256'>;
|
|
767
|
+
readonly residual: OutputHandle<'resource'>;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
export interface MorphoBlueSupplyOutputs {
|
|
771
|
+
readonly assetsSupplied: OutputHandle<'uint256'>;
|
|
772
|
+
readonly sharesSupplied: OutputHandle<'uint256'>;
|
|
773
|
+
readonly residual: OutputHandle<'resource'>;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
export interface MorphoBlueWithdrawOutputs {
|
|
777
|
+
readonly withdrawn: OutputHandle<'resource'>;
|
|
778
|
+
readonly assetsWithdrawn: OutputHandle<'uint256'>;
|
|
779
|
+
readonly sharesWithdrawn: OutputHandle<'uint256'>;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
export interface MorphoBlueGetPositionOutputs {
|
|
783
|
+
readonly supplyShares: OutputHandle<'uint256'>;
|
|
784
|
+
readonly borrowShares: OutputHandle<'uint128'>;
|
|
785
|
+
readonly collateral: OutputHandle<'uint128'>;
|
|
786
|
+
}
|
|
787
|
+
|
|
693
788
|
export interface LifiZapOutputs {
|
|
694
789
|
readonly amountOut: OutputHandle<'resource'>;
|
|
695
790
|
}
|
|
@@ -914,6 +1009,11 @@ export type GeneratedOps = {
|
|
|
914
1009
|
) => AaveClaimRewardsOutputs;
|
|
915
1010
|
/** 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" */
|
|
916
1011
|
readonly setEMode: (nodeId: string, args: AaveSetEModeArgs) => void;
|
|
1012
|
+
/** 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" */
|
|
1013
|
+
readonly getHealthFactor: (
|
|
1014
|
+
nodeId: string,
|
|
1015
|
+
args: AaveGetHealthFactorArgs,
|
|
1016
|
+
) => AaveGetHealthFactorOutputs;
|
|
917
1017
|
};
|
|
918
1018
|
readonly morphoBlue: {
|
|
919
1019
|
/** 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" */
|
|
@@ -926,6 +1026,31 @@ export type GeneratedOps = {
|
|
|
926
1026
|
nodeId: string,
|
|
927
1027
|
args: MorphoBlueWithdrawCollateralArgs,
|
|
928
1028
|
) => MorphoBlueWithdrawCollateralOutputs;
|
|
1029
|
+
/** 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" */
|
|
1030
|
+
readonly borrow: (
|
|
1031
|
+
nodeId: string,
|
|
1032
|
+
args: MorphoBlueBorrowArgs,
|
|
1033
|
+
) => MorphoBlueBorrowOutputs;
|
|
1034
|
+
/** 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" */
|
|
1035
|
+
readonly repay: (
|
|
1036
|
+
nodeId: string,
|
|
1037
|
+
args: MorphoBlueRepayArgs,
|
|
1038
|
+
) => MorphoBlueRepayOutputs;
|
|
1039
|
+
/** 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" */
|
|
1040
|
+
readonly supply: (
|
|
1041
|
+
nodeId: string,
|
|
1042
|
+
args: MorphoBlueSupplyArgs,
|
|
1043
|
+
) => MorphoBlueSupplyOutputs;
|
|
1044
|
+
/** 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" */
|
|
1045
|
+
readonly withdraw: (
|
|
1046
|
+
nodeId: string,
|
|
1047
|
+
args: MorphoBlueWithdrawArgs,
|
|
1048
|
+
) => MorphoBlueWithdrawOutputs;
|
|
1049
|
+
/** 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" */
|
|
1050
|
+
readonly getPosition: (
|
|
1051
|
+
nodeId: string,
|
|
1052
|
+
args: MorphoBlueGetPositionArgs,
|
|
1053
|
+
) => MorphoBlueGetPositionOutputs;
|
|
929
1054
|
};
|
|
930
1055
|
readonly paraswap: {
|
|
931
1056
|
/** 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" */
|
|
@@ -1173,6 +1298,10 @@ export const bindGeneratedOps = (
|
|
|
1173
1298
|
} as const),
|
|
1174
1299
|
setEMode: (nodeId: string, args: AaveSetEModeArgs) =>
|
|
1175
1300
|
builder.call(nodeId, 'aave.setEMode', args, {}),
|
|
1301
|
+
getHealthFactor: (nodeId: string, args: AaveGetHealthFactorArgs) =>
|
|
1302
|
+
builder.call(nodeId, 'aave.getHealthFactor', args, {
|
|
1303
|
+
healthFactor: 'uint256',
|
|
1304
|
+
} as const),
|
|
1176
1305
|
},
|
|
1177
1306
|
morphoBlue: {
|
|
1178
1307
|
supplyCollateral: (nodeId: string, args: MorphoBlueSupplyCollateralArgs) =>
|
|
@@ -1185,6 +1314,36 @@ export const bindGeneratedOps = (
|
|
|
1185
1314
|
withdrawn: 'resource',
|
|
1186
1315
|
collateralWithdrawn: 'uint256',
|
|
1187
1316
|
} as const),
|
|
1317
|
+
borrow: (nodeId: string, args: MorphoBlueBorrowArgs) =>
|
|
1318
|
+
builder.call(nodeId, 'morphoBlue.borrow', args, {
|
|
1319
|
+
borrowed: 'resource',
|
|
1320
|
+
assetsBorrowed: 'uint256',
|
|
1321
|
+
sharesBorrowed: 'uint256',
|
|
1322
|
+
} as const),
|
|
1323
|
+
repay: (nodeId: string, args: MorphoBlueRepayArgs) =>
|
|
1324
|
+
builder.call(nodeId, 'morphoBlue.repay', args, {
|
|
1325
|
+
actualRepaid: 'uint256',
|
|
1326
|
+
sharesRepaid: 'uint256',
|
|
1327
|
+
residual: 'resource',
|
|
1328
|
+
} as const),
|
|
1329
|
+
supply: (nodeId: string, args: MorphoBlueSupplyArgs) =>
|
|
1330
|
+
builder.call(nodeId, 'morphoBlue.supply', args, {
|
|
1331
|
+
assetsSupplied: 'uint256',
|
|
1332
|
+
sharesSupplied: 'uint256',
|
|
1333
|
+
residual: 'resource',
|
|
1334
|
+
} as const),
|
|
1335
|
+
withdraw: (nodeId: string, args: MorphoBlueWithdrawArgs) =>
|
|
1336
|
+
builder.call(nodeId, 'morphoBlue.withdraw', args, {
|
|
1337
|
+
withdrawn: 'resource',
|
|
1338
|
+
assetsWithdrawn: 'uint256',
|
|
1339
|
+
sharesWithdrawn: 'uint256',
|
|
1340
|
+
} as const),
|
|
1341
|
+
getPosition: (nodeId: string, args: MorphoBlueGetPositionArgs) =>
|
|
1342
|
+
builder.call(nodeId, 'morphoBlue.getPosition', args, {
|
|
1343
|
+
supplyShares: 'uint256',
|
|
1344
|
+
borrowShares: 'uint128',
|
|
1345
|
+
collateral: 'uint128',
|
|
1346
|
+
} as const),
|
|
1188
1347
|
},
|
|
1189
1348
|
paraswap: {
|
|
1190
1349
|
buy: (nodeId: string, args: ParaswapBuyArgs) =>
|