@continuumdao/ctm-mpc-defi 0.2.34 → 0.2.36

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 (94) hide show
  1. package/dist/agent/catalog.cjs +1562 -45
  2. package/dist/agent/catalog.cjs.map +1 -1
  3. package/dist/agent/catalog.d.ts +5995 -2960
  4. package/dist/agent/catalog.js +1502 -46
  5. package/dist/agent/catalog.js.map +1 -1
  6. package/dist/agent/skills/aave-v4/SKILL.md +19 -4
  7. package/dist/agent/skills/aerodrome/SKILL.md +2 -2
  8. package/dist/agent/skills/compound-v3/SKILL.md +2 -2
  9. package/dist/agent/skills/curve-dao/SKILL.md +14 -0
  10. package/dist/agent/skills/ethena/SKILL.md +3 -1
  11. package/dist/agent/skills/euler-v2/SKILL.md +1 -1
  12. package/dist/agent/skills/gmx/SKILL.md +1 -1
  13. package/dist/agent/skills/hyperliquid/SKILL.md +7 -5
  14. package/dist/agent/skills/lido/SKILL.md +3 -0
  15. package/dist/agent/skills/maple-syrup/SKILL.md +35 -3
  16. package/dist/agent/skills/morpho/SKILL.md +1 -1
  17. package/dist/agent/skills/pendle/SKILL.md +63 -0
  18. package/dist/agent/skills/sky/SKILL.md +2 -0
  19. package/dist/agent/skills/yield-compare/SKILL.md +81 -0
  20. package/dist/core/index.cjs +2 -1
  21. package/dist/core/index.cjs.map +1 -1
  22. package/dist/core/index.js +2 -1
  23. package/dist/core/index.js.map +1 -1
  24. package/dist/index.cjs +257 -29
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.js +257 -28
  28. package/dist/index.js.map +1 -1
  29. package/dist/protocols/evm/aave-v4/index.cjs +170 -0
  30. package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
  31. package/dist/protocols/evm/aave-v4/index.d.ts +59 -1
  32. package/dist/protocols/evm/aave-v4/index.js +164 -1
  33. package/dist/protocols/evm/aave-v4/index.js.map +1 -1
  34. package/dist/protocols/evm/aerodrome/index.cjs +1308 -901
  35. package/dist/protocols/evm/aerodrome/index.cjs.map +1 -1
  36. package/dist/protocols/evm/aerodrome/index.d.ts +69 -2
  37. package/dist/protocols/evm/aerodrome/index.js +1217 -807
  38. package/dist/protocols/evm/aerodrome/index.js.map +1 -1
  39. package/dist/protocols/evm/compound-v3/index.cjs +82 -6
  40. package/dist/protocols/evm/compound-v3/index.cjs.map +1 -1
  41. package/dist/protocols/evm/compound-v3/index.d.ts +89 -1
  42. package/dist/protocols/evm/compound-v3/index.js +80 -7
  43. package/dist/protocols/evm/compound-v3/index.js.map +1 -1
  44. package/dist/protocols/evm/curve-dao/index.cjs +447 -18
  45. package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
  46. package/dist/protocols/evm/curve-dao/index.d.ts +108 -1
  47. package/dist/protocols/evm/curve-dao/index.js +440 -19
  48. package/dist/protocols/evm/curve-dao/index.js.map +1 -1
  49. package/dist/protocols/evm/ethena/index.cjs +89 -0
  50. package/dist/protocols/evm/ethena/index.cjs.map +1 -1
  51. package/dist/protocols/evm/ethena/index.d.ts +17 -1
  52. package/dist/protocols/evm/ethena/index.js +89 -2
  53. package/dist/protocols/evm/ethena/index.js.map +1 -1
  54. package/dist/protocols/evm/euler-v2/index.cjs +29 -0
  55. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
  56. package/dist/protocols/evm/euler-v2/index.d.ts +21 -1
  57. package/dist/protocols/evm/euler-v2/index.js +29 -1
  58. package/dist/protocols/evm/euler-v2/index.js.map +1 -1
  59. package/dist/protocols/evm/gmx/index.cjs +83 -1
  60. package/dist/protocols/evm/gmx/index.cjs.map +1 -1
  61. package/dist/protocols/evm/gmx/index.d.ts +22 -2
  62. package/dist/protocols/evm/gmx/index.js +80 -2
  63. package/dist/protocols/evm/gmx/index.js.map +1 -1
  64. package/dist/protocols/evm/hyperliquid/index.cjs +67 -11
  65. package/dist/protocols/evm/hyperliquid/index.cjs.map +1 -1
  66. package/dist/protocols/evm/hyperliquid/index.d.ts +39 -2
  67. package/dist/protocols/evm/hyperliquid/index.js +64 -12
  68. package/dist/protocols/evm/hyperliquid/index.js.map +1 -1
  69. package/dist/protocols/evm/lido/index.cjs +13 -0
  70. package/dist/protocols/evm/lido/index.cjs.map +1 -1
  71. package/dist/protocols/evm/lido/index.d.ts +9 -1
  72. package/dist/protocols/evm/lido/index.js +13 -1
  73. package/dist/protocols/evm/lido/index.js.map +1 -1
  74. package/dist/protocols/evm/maple/index.cjs +129 -1
  75. package/dist/protocols/evm/maple/index.cjs.map +1 -1
  76. package/dist/protocols/evm/maple/index.d.ts +45 -1
  77. package/dist/protocols/evm/maple/index.js +124 -3
  78. package/dist/protocols/evm/maple/index.js.map +1 -1
  79. package/dist/protocols/evm/morpho/index.cjs +34 -7
  80. package/dist/protocols/evm/morpho/index.cjs.map +1 -1
  81. package/dist/protocols/evm/morpho/index.d.ts +23 -1
  82. package/dist/protocols/evm/morpho/index.js +34 -8
  83. package/dist/protocols/evm/morpho/index.js.map +1 -1
  84. package/dist/protocols/evm/pendle/index.cjs +1530 -0
  85. package/dist/protocols/evm/pendle/index.cjs.map +1 -0
  86. package/dist/protocols/evm/pendle/index.d.ts +463 -0
  87. package/dist/protocols/evm/pendle/index.js +1463 -0
  88. package/dist/protocols/evm/pendle/index.js.map +1 -0
  89. package/dist/protocols/evm/sky/index.cjs +52 -0
  90. package/dist/protocols/evm/sky/index.cjs.map +1 -1
  91. package/dist/protocols/evm/sky/index.d.ts +16 -1
  92. package/dist/protocols/evm/sky/index.js +50 -1
  93. package/dist/protocols/evm/sky/index.js.map +1 -1
  94. package/package.json +6 -1
@@ -909,7 +909,65 @@ declare function aaveReadSupplyMetrics(reserve: unknown, symbolForDisplay: strin
909
909
  availableLiquidity: string;
910
910
  };
911
911
 
912
+ type AaveV4MarketSummaryRow = {
913
+ chainId: number;
914
+ hubName: string;
915
+ marketId: AaveV4UiMarketId;
916
+ hubAddress: string;
917
+ symbol: string;
918
+ name: string;
919
+ underlying: string;
920
+ spoke: string | null;
921
+ canSupply: boolean;
922
+ canBorrow: boolean;
923
+ canUseAsCollateral: boolean;
924
+ supplyApyPercent: string;
925
+ borrowApyPercent: string;
926
+ supplied: string;
927
+ borrowed: string;
928
+ availableLiquidity: string;
929
+ utilizationPercent: string | null;
930
+ collateralFactorPercent: string;
931
+ };
932
+ type AaveV4ApyLike = {
933
+ normalized?: string;
934
+ value?: string;
935
+ } | null | undefined;
936
+ /** Parse GraphQL `supplyApy` / `borrowApy` to a percent number (e.g. 4.72). */
937
+ declare function parseAaveV4ApyPercent(apy: AaveV4ApyLike): number | null;
938
+ declare function formatAaveV4ApyPercentLabel(apy: AaveV4ApyLike): string;
939
+ /** Map one hub reserve row to the MCP market summary (null if the underlying address is invalid). */
940
+ declare function aaveV4MarketRowFromHubReserve(args: {
941
+ chainId: number;
942
+ hub: AaveV4Hub;
943
+ reserve: AaveV4HubReserve;
944
+ }): AaveV4MarketSummaryRow | null;
945
+ /** Live pool: has supplied or borrowed balance. Empty spokes are unused listings. */
946
+ declare function isAaveV4HubReserveActive(reserve: AaveV4HubReserve): boolean;
947
+ /** Drop unused spokes (zero supplied and zero borrowed). Keep every live pool, including multiple spokes for the same asset. */
948
+ declare function filterActiveAaveV4HubReserves(reserves: readonly AaveV4HubReserve[]): AaveV4HubReserve[];
949
+ /** MCP: list Aave v4 hub reserves with supply/borrow APY. No RPC — Aave v4 GraphQL only. */
950
+ declare function aaveV4FetchMarketsSummary(args: {
951
+ chainId: number;
952
+ marketId?: string;
953
+ underlying?: string;
954
+ }): Promise<{
955
+ chainId: number;
956
+ markets: AaveV4MarketSummaryRow[];
957
+ notes: string;
958
+ }>;
959
+ /** MCP: one underlying across hubs (or a single marketId) with live APY. */
960
+ declare function aaveV4FetchMarketSummary(args: {
961
+ chainId: number;
962
+ underlying: string;
963
+ marketId?: string;
964
+ }): Promise<{
965
+ chainId: number;
966
+ markets: AaveV4MarketSummaryRow[];
967
+ notes: string;
968
+ }>;
969
+
912
970
  declare const AAVE_V4_PROTOCOL_ID = "aave-v4";
913
971
  declare const aaveV4ProtocolModule: ProtocolModule;
914
972
 
915
- export { AAVE_V4_GRAPHQL_URL, AAVE_V4_PROTOCOL_ID, AAVE_V4_SPOKE_BORROW_DEFAULT_GAS_UNITS, AAVE_V4_SPOKE_REPAY_DEFAULT_GAS_UNITS, AAVE_V4_SPOKE_SUPPLY_DEFAULT_GAS_UNITS, AAVE_V4_SPOKE_WITHDRAW_DEFAULT_GAS_UNITS, type AaveBorrowInfoLike, type AaveDecimalValueLike, type AavePercentValueLike, type AaveSupplyInfoLike, type AaveV4BorrowTableRow, type AaveV4BorrowableDisplay, type AaveV4ClaimRewardsTx, type AaveV4ExchangeAmount, type AaveV4Hub, type AaveV4HubReserve, type AaveV4HubReserveSummary, type AaveV4MerklClaimableRewardRow, type AaveV4PositionActionPayload, type AaveV4SpokeLiquidationConfig, type AaveV4SpokeOnChainReserveStatus, type AaveV4UiMarketId, type AaveV4UserPositionDetail, type AaveV4UserPositionRow, type AaveV4UserPositionsByAsset, type AaveV4UserSupplyRow, type AaveV4WithdrawHealthGateResult, MIN_AAVE_V4_DEPOSIT_GAS_EXEC, type V4ReservesListRow, aaveAvailableLiquidityDisplay, aaveReadSupplyMetrics, aaveUnderlyingAddressForContext, aaveV4BorrowHealthGate, aaveV4Gql, aaveV4KeyForNodeAssetRow, aaveV4ProtocolModule, aaveV4RepayHealthGate, aaveV4UiMarketIdForHubName, aaveV4UserHasAvailableBorrowCollateralForContextOnSpoke, aaveV4WithdrawHealthGate, aggregateV4SupplyDisplay, borrowableAssetsFromHubReserves, buildAaveV4BorrowTableRowsFromHub, buildEvmMultisignBodyAaveV4DepositBatch, buildEvmMultisignBodyAaveV4MerklClaimRewards, buildEvmMultisignBodyAaveV4SpokeBorrow, buildEvmMultisignBodyAaveV4SpokeRepay, buildEvmMultisignBodyAaveV4SpokeWithdraw, buildEvmMultisignBodyEulerV2MerklDistributorClaim, buildEvmMultisignBodyEulerV2ReulUnlock, ensureAaveV4ChainTokenCache, fetchAaveV4Chains, fetchAaveV4ClaimRewardsCalldata, fetchAaveV4HubReserves, fetchAaveV4HubsForChain, fetchAaveV4MerklClaimRewardIdsForChain, fetchAaveV4MerklClaimableRewardsForChain, fetchAaveV4NativeWrappedToken, fetchAaveV4ReservesForUnderlying, fetchAaveV4SpokeReserveIdForUnderlying, fetchAaveV4SpokeReserveStatusForUnderlying, fetchAaveV4SupportedUnderlyingAddressSet, fetchAaveV4UserBorrowsDebtByUnderlyingForHub, fetchAaveV4UserPositionById, fetchAaveV4UserPositionsByAssetOnChain, fetchAaveV4UserPositionsForChain, fetchAaveV4UserSuppliesForPosition, findAaveV4HubReserveForChainUnderlying, findHubReserveForUnderlying, formatAavePercentDisplay, formatAaveV4AmountHumanFromApiString, formatAaveV4DecimalString, formatAaveV4ExchangeLabel, formatAaveV4HealthFactor, formatAaveV4PercentDisplay, formatAaveV4PositionHealthFactor, formatAaveV4PositionPercent, formatAaveV4ReserveLiquidityFromSummary, formatAaveV4RiskDisplay, formatAaveV4RiskNotionalString, formatAaveV4TokenAmount, isAaveV4DepositEvmSignRequest, isValidAaveChainId, loadAaveV4SupportedChainIds, loadAaveV4SupportedChainIdsFromV4Api, parseBigDecimalHf, pickAaveV4ReserveRowForSpoke, previewAaveV4BorrowResultingHf, previewAaveV4RepayResultingHf, previewAaveV4WithdrawResultingHf, resolveAaveV4DepositGasUnitsFromSignRequest, resolveAaveV4HubForUiMarket };
973
+ export { AAVE_V4_GRAPHQL_URL, AAVE_V4_PROTOCOL_ID, AAVE_V4_SPOKE_BORROW_DEFAULT_GAS_UNITS, AAVE_V4_SPOKE_REPAY_DEFAULT_GAS_UNITS, AAVE_V4_SPOKE_SUPPLY_DEFAULT_GAS_UNITS, AAVE_V4_SPOKE_WITHDRAW_DEFAULT_GAS_UNITS, type AaveBorrowInfoLike, type AaveDecimalValueLike, type AavePercentValueLike, type AaveSupplyInfoLike, type AaveV4BorrowTableRow, type AaveV4BorrowableDisplay, type AaveV4ClaimRewardsTx, type AaveV4ExchangeAmount, type AaveV4Hub, type AaveV4HubReserve, type AaveV4HubReserveSummary, type AaveV4MarketSummaryRow, type AaveV4MerklClaimableRewardRow, type AaveV4PositionActionPayload, type AaveV4SpokeLiquidationConfig, type AaveV4SpokeOnChainReserveStatus, type AaveV4UiMarketId, type AaveV4UserPositionDetail, type AaveV4UserPositionRow, type AaveV4UserPositionsByAsset, type AaveV4UserSupplyRow, type AaveV4WithdrawHealthGateResult, MIN_AAVE_V4_DEPOSIT_GAS_EXEC, type V4ReservesListRow, aaveAvailableLiquidityDisplay, aaveReadSupplyMetrics, aaveUnderlyingAddressForContext, aaveV4BorrowHealthGate, aaveV4FetchMarketSummary, aaveV4FetchMarketsSummary, aaveV4Gql, aaveV4KeyForNodeAssetRow, aaveV4MarketRowFromHubReserve, aaveV4ProtocolModule, aaveV4RepayHealthGate, aaveV4UiMarketIdForHubName, aaveV4UserHasAvailableBorrowCollateralForContextOnSpoke, aaveV4WithdrawHealthGate, aggregateV4SupplyDisplay, borrowableAssetsFromHubReserves, buildAaveV4BorrowTableRowsFromHub, buildEvmMultisignBodyAaveV4DepositBatch, buildEvmMultisignBodyAaveV4MerklClaimRewards, buildEvmMultisignBodyAaveV4SpokeBorrow, buildEvmMultisignBodyAaveV4SpokeRepay, buildEvmMultisignBodyAaveV4SpokeWithdraw, buildEvmMultisignBodyEulerV2MerklDistributorClaim, buildEvmMultisignBodyEulerV2ReulUnlock, ensureAaveV4ChainTokenCache, fetchAaveV4Chains, fetchAaveV4ClaimRewardsCalldata, fetchAaveV4HubReserves, fetchAaveV4HubsForChain, fetchAaveV4MerklClaimRewardIdsForChain, fetchAaveV4MerklClaimableRewardsForChain, fetchAaveV4NativeWrappedToken, fetchAaveV4ReservesForUnderlying, fetchAaveV4SpokeReserveIdForUnderlying, fetchAaveV4SpokeReserveStatusForUnderlying, fetchAaveV4SupportedUnderlyingAddressSet, fetchAaveV4UserBorrowsDebtByUnderlyingForHub, fetchAaveV4UserPositionById, fetchAaveV4UserPositionsByAssetOnChain, fetchAaveV4UserPositionsForChain, fetchAaveV4UserSuppliesForPosition, filterActiveAaveV4HubReserves, findAaveV4HubReserveForChainUnderlying, findHubReserveForUnderlying, formatAavePercentDisplay, formatAaveV4AmountHumanFromApiString, formatAaveV4ApyPercentLabel, formatAaveV4DecimalString, formatAaveV4ExchangeLabel, formatAaveV4HealthFactor, formatAaveV4PercentDisplay, formatAaveV4PositionHealthFactor, formatAaveV4PositionPercent, formatAaveV4ReserveLiquidityFromSummary, formatAaveV4RiskDisplay, formatAaveV4RiskNotionalString, formatAaveV4TokenAmount, isAaveV4DepositEvmSignRequest, isAaveV4HubReserveActive, isValidAaveChainId, loadAaveV4SupportedChainIds, loadAaveV4SupportedChainIdsFromV4Api, parseAaveV4ApyPercent, parseBigDecimalHf, pickAaveV4ReserveRowForSpoke, previewAaveV4BorrowResultingHf, previewAaveV4RepayResultingHf, previewAaveV4WithdrawResultingHf, resolveAaveV4DepositGasUnitsFromSignRequest, resolveAaveV4HubForUiMarket };
@@ -2377,6 +2377,169 @@ function aaveReadSupplyMetrics(reserve, symbolForDisplay) {
2377
2377
  availableLiquidity: liq === "\u2014" ? "\u2014" : sym ? `${liq} ${sym}` : liq
2378
2378
  };
2379
2379
  }
2380
+ function matchesAssetFilter(opts) {
2381
+ const f = (opts.filter ?? "").trim();
2382
+ if (!f) return true;
2383
+ const addr = (opts.address ?? "").trim();
2384
+ if (isAddress(f) && isAddress(addr)) {
2385
+ return getAddress(addr) === getAddress(f);
2386
+ }
2387
+ const sym = (opts.symbol ?? "").trim();
2388
+ if (!sym) return false;
2389
+ return sym.toLowerCase() === f.toLowerCase();
2390
+ }
2391
+
2392
+ // src/protocols/evm/aave-v4/reads.ts
2393
+ function parseAaveV4ApyPercent(apy) {
2394
+ const n = parseFloat((apy?.normalized ?? "").trim());
2395
+ if (Number.isFinite(n) && n >= 0) return n;
2396
+ const v = parseFloat((apy?.value ?? "").trim());
2397
+ if (!Number.isFinite(v) || v < 0) return null;
2398
+ return v > 0 && v <= 1 ? v * 100 : v;
2399
+ }
2400
+ function formatAaveV4ApyPercentLabel(apy) {
2401
+ const n = parseAaveV4ApyPercent(apy);
2402
+ if (n == null) return "\u2014";
2403
+ return `${n.toFixed(2)}%`;
2404
+ }
2405
+ function utilizationPercentLabel(suppliedValue, borrowedValue) {
2406
+ const s = parseFloat((suppliedValue ?? "").trim());
2407
+ const b = parseFloat((borrowedValue ?? "").trim());
2408
+ if (!Number.isFinite(s) || !Number.isFinite(b) || s <= 0) return null;
2409
+ return `${(b / s * 100).toFixed(1)}%`;
2410
+ }
2411
+ function checksumOrNull(raw) {
2412
+ const t = (raw ?? "").trim();
2413
+ if (!t || !isAddress(t)) return null;
2414
+ return getAddress(t);
2415
+ }
2416
+ function aaveV4MarketRowFromHubReserve(args) {
2417
+ const underlying = checksumOrNull(args.reserve.asset?.underlying?.address);
2418
+ if (!underlying) return null;
2419
+ const info = args.reserve.asset?.underlying?.info;
2420
+ const summary = args.reserve.summary;
2421
+ const suppliedValue = summary?.supplied?.amount?.value;
2422
+ const borrowedValue = summary?.borrowed?.amount?.value;
2423
+ return {
2424
+ chainId: args.chainId,
2425
+ hubName: (args.hub.name ?? "").trim() || "\u2014",
2426
+ marketId: aaveV4UiMarketIdForHubName(args.hub.name),
2427
+ hubAddress: getAddress(args.hub.address),
2428
+ symbol: (info?.symbol ?? "").trim() || "\u2014",
2429
+ name: (info?.name ?? "").trim() || "\u2014",
2430
+ underlying,
2431
+ spoke: checksumOrNull(args.reserve.spoke?.address),
2432
+ canSupply: Boolean(args.reserve.canSupply),
2433
+ canBorrow: Boolean(args.reserve.canBorrow && args.reserve.settings?.borrowable),
2434
+ canUseAsCollateral: Boolean(args.reserve.canUseAsCollateral && args.reserve.settings?.collateral),
2435
+ supplyApyPercent: formatAaveV4ApyPercentLabel(summary?.supplyApy),
2436
+ borrowApyPercent: formatAaveV4ApyPercentLabel(summary?.borrowApy),
2437
+ supplied: formatAaveV4AmountHumanFromApiString(suppliedValue),
2438
+ borrowed: formatAaveV4AmountHumanFromApiString(borrowedValue),
2439
+ availableLiquidity: formatAaveV4ReserveLiquidityFromSummary({
2440
+ suppliedValue,
2441
+ borrowedValue
2442
+ }),
2443
+ utilizationPercent: utilizationPercentLabel(suppliedValue, borrowedValue),
2444
+ collateralFactorPercent: formatAaveV4PercentDisplay(
2445
+ args.reserve.settings?.collateralFactor?.normalized,
2446
+ args.reserve.settings?.collateralFactor?.value
2447
+ )
2448
+ };
2449
+ }
2450
+ function sortBySupplyApyDesc(a, b) {
2451
+ const pa = parseFloat(a.supplyApyPercent);
2452
+ const pb = parseFloat(b.supplyApyPercent);
2453
+ const na = Number.isFinite(pa) ? pa : -1;
2454
+ const nb = Number.isFinite(pb) ? pb : -1;
2455
+ if (nb !== na) return nb - na;
2456
+ const sym = a.symbol.localeCompare(b.symbol, void 0, { sensitivity: "base" });
2457
+ if (sym !== 0) return sym;
2458
+ return (a.spoke ?? "").localeCompare(b.spoke ?? "");
2459
+ }
2460
+ function reserveAmountRaw(raw) {
2461
+ const n = parseFloat((raw ?? "").trim());
2462
+ return Number.isFinite(n) ? n : 0;
2463
+ }
2464
+ function isAaveV4HubReserveActive(reserve) {
2465
+ const supplied = reserveAmountRaw(reserve.summary?.supplied?.amount?.value);
2466
+ const borrowed = reserveAmountRaw(reserve.summary?.borrowed?.amount?.value);
2467
+ return supplied > 0 || borrowed > 0;
2468
+ }
2469
+ function filterActiveAaveV4HubReserves(reserves) {
2470
+ return reserves.filter(isAaveV4HubReserveActive);
2471
+ }
2472
+ function parseUiMarketId(raw) {
2473
+ const t = (raw ?? "").trim().toLowerCase();
2474
+ if (t === "main" || t === "core" || t === "bluechip") return t;
2475
+ return void 0;
2476
+ }
2477
+ async function collectHubMarketRows(args) {
2478
+ const markets = [];
2479
+ for (const hub of args.hubs) {
2480
+ const reserves = filterActiveAaveV4HubReserves(
2481
+ await fetchAaveV4HubReserves({
2482
+ chainId: args.chainId,
2483
+ hubAddress: getAddress(hub.address)
2484
+ })
2485
+ );
2486
+ for (const reserve of reserves) {
2487
+ const row = aaveV4MarketRowFromHubReserve({ chainId: args.chainId, hub, reserve });
2488
+ if (row) markets.push(row);
2489
+ }
2490
+ }
2491
+ return markets;
2492
+ }
2493
+ async function aaveV4FetchMarketsSummary(args) {
2494
+ const hubs = await fetchAaveV4HubsForChain(args.chainId);
2495
+ if (!hubs.length) {
2496
+ return {
2497
+ chainId: args.chainId,
2498
+ markets: [],
2499
+ notes: `Aave v4 lists no hubs on chain ${args.chainId}. Check get_defi_protocol_supported_chains.`
2500
+ };
2501
+ }
2502
+ const wantMarket = parseUiMarketId(args.marketId);
2503
+ let selected = hubs;
2504
+ let marketNote = "";
2505
+ if (wantMarket) {
2506
+ const preferred = resolveAaveV4HubForUiMarket(hubs, wantMarket, args.chainId);
2507
+ if (preferred) {
2508
+ selected = [preferred];
2509
+ marketNote = ` Filtered to ${preferred.name} (${wantMarket}).`;
2510
+ } else {
2511
+ marketNote = ` No hub matched marketId ${wantMarket}; listing all hubs.`;
2512
+ }
2513
+ }
2514
+ let markets = await collectHubMarketRows({ chainId: args.chainId, hubs: selected });
2515
+ const rawUnderlying = (args.underlying ?? "").trim();
2516
+ if (rawUnderlying) {
2517
+ markets = markets.filter(
2518
+ (m) => matchesAssetFilter({ address: m.underlying, symbol: m.symbol, filter: rawUnderlying })
2519
+ );
2520
+ }
2521
+ markets.sort(sortBySupplyApyDesc);
2522
+ const notes = "Supply/borrow APY from Aave v4 GraphQL (api.v4.aave.com). These are APY (compounded), not APR. Each live spoke is a row (unused zero-liquidity listings omitted). Copy underlying + marketId for build_*_multisign. Do not web-search Aave rates." + marketNote;
2523
+ return { chainId: args.chainId, markets, notes };
2524
+ }
2525
+ async function aaveV4FetchMarketSummary(args) {
2526
+ const addr = (args.underlying ?? "").trim();
2527
+ if (!addr) {
2528
+ throw new Error("underlying is required (ERC-20 address or ticker such as USDT).");
2529
+ }
2530
+ const out = await aaveV4FetchMarketsSummary({
2531
+ chainId: args.chainId,
2532
+ marketId: args.marketId,
2533
+ underlying: isAddress(addr) ? getAddress(addr) : addr
2534
+ });
2535
+ if (!out.markets.length) {
2536
+ return {
2537
+ ...out,
2538
+ notes: out.notes + ` No Aave v4 reserve listed ${isAddress(addr) ? getAddress(addr) : addr} on chain ${args.chainId}` + (args.marketId ? ` for marketId ${args.marketId}` : "") + "."
2539
+ };
2540
+ }
2541
+ return out;
2542
+ }
2380
2543
 
2381
2544
  // src/protocols/evm/aave-v4/index.ts
2382
2545
  var AAVE_V4_PROTOCOL_ID = "aave-v4";
@@ -2398,6 +2561,6 @@ var aaveV4ProtocolModule = {
2398
2561
  };
2399
2562
  registerProtocolModule(aaveV4ProtocolModule);
2400
2563
 
2401
- export { AAVE_V4_GRAPHQL_URL, AAVE_V4_PROTOCOL_ID, AAVE_V4_SPOKE_BORROW_DEFAULT_GAS_UNITS, AAVE_V4_SPOKE_REPAY_DEFAULT_GAS_UNITS, AAVE_V4_SPOKE_SUPPLY_DEFAULT_GAS_UNITS, AAVE_V4_SPOKE_WITHDRAW_DEFAULT_GAS_UNITS, MIN_AAVE_V4_DEPOSIT_GAS_EXEC, aaveAvailableLiquidityDisplay, aaveReadSupplyMetrics, aaveUnderlyingAddressForContext, aaveV4BorrowHealthGate, aaveV4Gql, aaveV4KeyForNodeAssetRow, aaveV4ProtocolModule, aaveV4RepayHealthGate, aaveV4UiMarketIdForHubName, aaveV4UserHasAvailableBorrowCollateralForContextOnSpoke, aaveV4WithdrawHealthGate, aggregateV4SupplyDisplay, borrowableAssetsFromHubReserves, buildAaveV4BorrowTableRowsFromHub, buildEvmMultisignBodyAaveV4DepositBatch, buildEvmMultisignBodyAaveV4MerklClaimRewards, buildEvmMultisignBodyAaveV4SpokeBorrow, buildEvmMultisignBodyAaveV4SpokeRepay, buildEvmMultisignBodyAaveV4SpokeWithdraw, buildEvmMultisignBodyEulerV2MerklDistributorClaim, buildEvmMultisignBodyEulerV2ReulUnlock, ensureAaveV4ChainTokenCache, fetchAaveV4Chains, fetchAaveV4ClaimRewardsCalldata, fetchAaveV4HubReserves, fetchAaveV4HubsForChain, fetchAaveV4MerklClaimRewardIdsForChain, fetchAaveV4MerklClaimableRewardsForChain, fetchAaveV4NativeWrappedToken, fetchAaveV4ReservesForUnderlying, fetchAaveV4SpokeReserveIdForUnderlying, fetchAaveV4SpokeReserveStatusForUnderlying, fetchAaveV4SupportedUnderlyingAddressSet, fetchAaveV4UserBorrowsDebtByUnderlyingForHub, fetchAaveV4UserPositionById, fetchAaveV4UserPositionsByAssetOnChain, fetchAaveV4UserPositionsForChain, fetchAaveV4UserSuppliesForPosition, findAaveV4HubReserveForChainUnderlying, findHubReserveForUnderlying, formatAavePercentDisplay, formatAaveV4AmountHumanFromApiString, formatAaveV4DecimalString, formatAaveV4ExchangeLabel, formatAaveV4HealthFactor, formatAaveV4PercentDisplay, formatAaveV4PositionHealthFactor, formatAaveV4PositionPercent, formatAaveV4ReserveLiquidityFromSummary, formatAaveV4RiskDisplay, formatAaveV4RiskNotionalString, formatAaveV4TokenAmount, isAaveV4DepositEvmSignRequest, isValidAaveChainId, loadAaveV4SupportedChainIds, loadAaveV4SupportedChainIdsFromV4Api, parseBigDecimalHf, pickAaveV4ReserveRowForSpoke, previewAaveV4BorrowResultingHf, previewAaveV4RepayResultingHf, previewAaveV4WithdrawResultingHf, resolveAaveV4DepositGasUnitsFromSignRequest, resolveAaveV4HubForUiMarket };
2564
+ export { AAVE_V4_GRAPHQL_URL, AAVE_V4_PROTOCOL_ID, AAVE_V4_SPOKE_BORROW_DEFAULT_GAS_UNITS, AAVE_V4_SPOKE_REPAY_DEFAULT_GAS_UNITS, AAVE_V4_SPOKE_SUPPLY_DEFAULT_GAS_UNITS, AAVE_V4_SPOKE_WITHDRAW_DEFAULT_GAS_UNITS, MIN_AAVE_V4_DEPOSIT_GAS_EXEC, aaveAvailableLiquidityDisplay, aaveReadSupplyMetrics, aaveUnderlyingAddressForContext, aaveV4BorrowHealthGate, aaveV4FetchMarketSummary, aaveV4FetchMarketsSummary, aaveV4Gql, aaveV4KeyForNodeAssetRow, aaveV4MarketRowFromHubReserve, aaveV4ProtocolModule, aaveV4RepayHealthGate, aaveV4UiMarketIdForHubName, aaveV4UserHasAvailableBorrowCollateralForContextOnSpoke, aaveV4WithdrawHealthGate, aggregateV4SupplyDisplay, borrowableAssetsFromHubReserves, buildAaveV4BorrowTableRowsFromHub, buildEvmMultisignBodyAaveV4DepositBatch, buildEvmMultisignBodyAaveV4MerklClaimRewards, buildEvmMultisignBodyAaveV4SpokeBorrow, buildEvmMultisignBodyAaveV4SpokeRepay, buildEvmMultisignBodyAaveV4SpokeWithdraw, buildEvmMultisignBodyEulerV2MerklDistributorClaim, buildEvmMultisignBodyEulerV2ReulUnlock, ensureAaveV4ChainTokenCache, fetchAaveV4Chains, fetchAaveV4ClaimRewardsCalldata, fetchAaveV4HubReserves, fetchAaveV4HubsForChain, fetchAaveV4MerklClaimRewardIdsForChain, fetchAaveV4MerklClaimableRewardsForChain, fetchAaveV4NativeWrappedToken, fetchAaveV4ReservesForUnderlying, fetchAaveV4SpokeReserveIdForUnderlying, fetchAaveV4SpokeReserveStatusForUnderlying, fetchAaveV4SupportedUnderlyingAddressSet, fetchAaveV4UserBorrowsDebtByUnderlyingForHub, fetchAaveV4UserPositionById, fetchAaveV4UserPositionsByAssetOnChain, fetchAaveV4UserPositionsForChain, fetchAaveV4UserSuppliesForPosition, filterActiveAaveV4HubReserves, findAaveV4HubReserveForChainUnderlying, findHubReserveForUnderlying, formatAavePercentDisplay, formatAaveV4AmountHumanFromApiString, formatAaveV4ApyPercentLabel, formatAaveV4DecimalString, formatAaveV4ExchangeLabel, formatAaveV4HealthFactor, formatAaveV4PercentDisplay, formatAaveV4PositionHealthFactor, formatAaveV4PositionPercent, formatAaveV4ReserveLiquidityFromSummary, formatAaveV4RiskDisplay, formatAaveV4RiskNotionalString, formatAaveV4TokenAmount, isAaveV4DepositEvmSignRequest, isAaveV4HubReserveActive, isValidAaveChainId, loadAaveV4SupportedChainIds, loadAaveV4SupportedChainIdsFromV4Api, parseAaveV4ApyPercent, parseBigDecimalHf, pickAaveV4ReserveRowForSpoke, previewAaveV4BorrowResultingHf, previewAaveV4RepayResultingHf, previewAaveV4WithdrawResultingHf, resolveAaveV4DepositGasUnitsFromSignRequest, resolveAaveV4HubForUiMarket };
2402
2565
  //# sourceMappingURL=index.js.map
2403
2566
  //# sourceMappingURL=index.js.map