@continuumdao/ctm-mpc-defi 0.2.34 → 0.2.35
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/dist/agent/catalog.cjs +712 -44
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +1630 -244
- package/dist/agent/catalog.js +678 -45
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/aave-v4/SKILL.md +19 -4
- package/dist/agent/skills/aerodrome/SKILL.md +2 -2
- package/dist/agent/skills/compound-v3/SKILL.md +2 -2
- package/dist/agent/skills/curve-dao/SKILL.md +14 -0
- package/dist/agent/skills/ethena/SKILL.md +3 -1
- package/dist/agent/skills/euler-v2/SKILL.md +1 -1
- package/dist/agent/skills/gmx/SKILL.md +1 -1
- package/dist/agent/skills/hyperliquid/SKILL.md +7 -5
- package/dist/agent/skills/lido/SKILL.md +3 -0
- package/dist/agent/skills/maple-syrup/SKILL.md +35 -3
- package/dist/agent/skills/morpho/SKILL.md +1 -1
- package/dist/agent/skills/sky/SKILL.md +2 -0
- package/dist/agent/skills/yield-compare/SKILL.md +78 -0
- package/dist/index.cjs +129 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +129 -27
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/aave-v4/index.cjs +170 -0
- package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/aave-v4/index.d.ts +59 -1
- package/dist/protocols/evm/aave-v4/index.js +164 -1
- package/dist/protocols/evm/aave-v4/index.js.map +1 -1
- package/dist/protocols/evm/aerodrome/index.cjs +1308 -901
- package/dist/protocols/evm/aerodrome/index.cjs.map +1 -1
- package/dist/protocols/evm/aerodrome/index.d.ts +69 -2
- package/dist/protocols/evm/aerodrome/index.js +1217 -807
- package/dist/protocols/evm/aerodrome/index.js.map +1 -1
- package/dist/protocols/evm/compound-v3/index.cjs +82 -6
- package/dist/protocols/evm/compound-v3/index.cjs.map +1 -1
- package/dist/protocols/evm/compound-v3/index.d.ts +89 -1
- package/dist/protocols/evm/compound-v3/index.js +80 -7
- package/dist/protocols/evm/compound-v3/index.js.map +1 -1
- package/dist/protocols/evm/curve-dao/index.cjs +447 -18
- package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
- package/dist/protocols/evm/curve-dao/index.d.ts +108 -1
- package/dist/protocols/evm/curve-dao/index.js +440 -19
- package/dist/protocols/evm/curve-dao/index.js.map +1 -1
- package/dist/protocols/evm/ethena/index.cjs +89 -0
- package/dist/protocols/evm/ethena/index.cjs.map +1 -1
- package/dist/protocols/evm/ethena/index.d.ts +17 -1
- package/dist/protocols/evm/ethena/index.js +89 -2
- package/dist/protocols/evm/ethena/index.js.map +1 -1
- package/dist/protocols/evm/euler-v2/index.cjs +29 -0
- package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
- package/dist/protocols/evm/euler-v2/index.d.ts +21 -1
- package/dist/protocols/evm/euler-v2/index.js +29 -1
- package/dist/protocols/evm/euler-v2/index.js.map +1 -1
- package/dist/protocols/evm/gmx/index.cjs +83 -1
- package/dist/protocols/evm/gmx/index.cjs.map +1 -1
- package/dist/protocols/evm/gmx/index.d.ts +22 -2
- package/dist/protocols/evm/gmx/index.js +80 -2
- package/dist/protocols/evm/gmx/index.js.map +1 -1
- package/dist/protocols/evm/hyperliquid/index.cjs +67 -11
- package/dist/protocols/evm/hyperliquid/index.cjs.map +1 -1
- package/dist/protocols/evm/hyperliquid/index.d.ts +39 -2
- package/dist/protocols/evm/hyperliquid/index.js +64 -12
- package/dist/protocols/evm/hyperliquid/index.js.map +1 -1
- package/dist/protocols/evm/lido/index.cjs +13 -0
- package/dist/protocols/evm/lido/index.cjs.map +1 -1
- package/dist/protocols/evm/lido/index.d.ts +9 -1
- package/dist/protocols/evm/lido/index.js +13 -1
- package/dist/protocols/evm/lido/index.js.map +1 -1
- package/dist/protocols/evm/maple/index.cjs +129 -1
- package/dist/protocols/evm/maple/index.cjs.map +1 -1
- package/dist/protocols/evm/maple/index.d.ts +45 -1
- package/dist/protocols/evm/maple/index.js +124 -3
- package/dist/protocols/evm/maple/index.js.map +1 -1
- package/dist/protocols/evm/morpho/index.cjs +34 -7
- package/dist/protocols/evm/morpho/index.cjs.map +1 -1
- package/dist/protocols/evm/morpho/index.d.ts +23 -1
- package/dist/protocols/evm/morpho/index.js +34 -8
- package/dist/protocols/evm/morpho/index.js.map +1 -1
- package/dist/protocols/evm/sky/index.cjs +52 -0
- package/dist/protocols/evm/sky/index.cjs.map +1 -1
- package/dist/protocols/evm/sky/index.d.ts +16 -1
- package/dist/protocols/evm/sky/index.js +50 -1
- package/dist/protocols/evm/sky/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -2379,6 +2379,169 @@ function aaveReadSupplyMetrics(reserve, symbolForDisplay) {
|
|
|
2379
2379
|
availableLiquidity: liq === "\u2014" ? "\u2014" : sym ? `${liq} ${sym}` : liq
|
|
2380
2380
|
};
|
|
2381
2381
|
}
|
|
2382
|
+
function matchesAssetFilter(opts) {
|
|
2383
|
+
const f = (opts.filter ?? "").trim();
|
|
2384
|
+
if (!f) return true;
|
|
2385
|
+
const addr = (opts.address ?? "").trim();
|
|
2386
|
+
if (viem.isAddress(f) && viem.isAddress(addr)) {
|
|
2387
|
+
return viem.getAddress(addr) === viem.getAddress(f);
|
|
2388
|
+
}
|
|
2389
|
+
const sym = (opts.symbol ?? "").trim();
|
|
2390
|
+
if (!sym) return false;
|
|
2391
|
+
return sym.toLowerCase() === f.toLowerCase();
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
// src/protocols/evm/aave-v4/reads.ts
|
|
2395
|
+
function parseAaveV4ApyPercent(apy) {
|
|
2396
|
+
const n = parseFloat((apy?.normalized ?? "").trim());
|
|
2397
|
+
if (Number.isFinite(n) && n >= 0) return n;
|
|
2398
|
+
const v = parseFloat((apy?.value ?? "").trim());
|
|
2399
|
+
if (!Number.isFinite(v) || v < 0) return null;
|
|
2400
|
+
return v > 0 && v <= 1 ? v * 100 : v;
|
|
2401
|
+
}
|
|
2402
|
+
function formatAaveV4ApyPercentLabel(apy) {
|
|
2403
|
+
const n = parseAaveV4ApyPercent(apy);
|
|
2404
|
+
if (n == null) return "\u2014";
|
|
2405
|
+
return `${n.toFixed(2)}%`;
|
|
2406
|
+
}
|
|
2407
|
+
function utilizationPercentLabel(suppliedValue, borrowedValue) {
|
|
2408
|
+
const s = parseFloat((suppliedValue ?? "").trim());
|
|
2409
|
+
const b = parseFloat((borrowedValue ?? "").trim());
|
|
2410
|
+
if (!Number.isFinite(s) || !Number.isFinite(b) || s <= 0) return null;
|
|
2411
|
+
return `${(b / s * 100).toFixed(1)}%`;
|
|
2412
|
+
}
|
|
2413
|
+
function checksumOrNull(raw) {
|
|
2414
|
+
const t = (raw ?? "").trim();
|
|
2415
|
+
if (!t || !viem.isAddress(t)) return null;
|
|
2416
|
+
return viem.getAddress(t);
|
|
2417
|
+
}
|
|
2418
|
+
function aaveV4MarketRowFromHubReserve(args) {
|
|
2419
|
+
const underlying = checksumOrNull(args.reserve.asset?.underlying?.address);
|
|
2420
|
+
if (!underlying) return null;
|
|
2421
|
+
const info = args.reserve.asset?.underlying?.info;
|
|
2422
|
+
const summary = args.reserve.summary;
|
|
2423
|
+
const suppliedValue = summary?.supplied?.amount?.value;
|
|
2424
|
+
const borrowedValue = summary?.borrowed?.amount?.value;
|
|
2425
|
+
return {
|
|
2426
|
+
chainId: args.chainId,
|
|
2427
|
+
hubName: (args.hub.name ?? "").trim() || "\u2014",
|
|
2428
|
+
marketId: aaveV4UiMarketIdForHubName(args.hub.name),
|
|
2429
|
+
hubAddress: viem.getAddress(args.hub.address),
|
|
2430
|
+
symbol: (info?.symbol ?? "").trim() || "\u2014",
|
|
2431
|
+
name: (info?.name ?? "").trim() || "\u2014",
|
|
2432
|
+
underlying,
|
|
2433
|
+
spoke: checksumOrNull(args.reserve.spoke?.address),
|
|
2434
|
+
canSupply: Boolean(args.reserve.canSupply),
|
|
2435
|
+
canBorrow: Boolean(args.reserve.canBorrow && args.reserve.settings?.borrowable),
|
|
2436
|
+
canUseAsCollateral: Boolean(args.reserve.canUseAsCollateral && args.reserve.settings?.collateral),
|
|
2437
|
+
supplyApyPercent: formatAaveV4ApyPercentLabel(summary?.supplyApy),
|
|
2438
|
+
borrowApyPercent: formatAaveV4ApyPercentLabel(summary?.borrowApy),
|
|
2439
|
+
supplied: formatAaveV4AmountHumanFromApiString(suppliedValue),
|
|
2440
|
+
borrowed: formatAaveV4AmountHumanFromApiString(borrowedValue),
|
|
2441
|
+
availableLiquidity: formatAaveV4ReserveLiquidityFromSummary({
|
|
2442
|
+
suppliedValue,
|
|
2443
|
+
borrowedValue
|
|
2444
|
+
}),
|
|
2445
|
+
utilizationPercent: utilizationPercentLabel(suppliedValue, borrowedValue),
|
|
2446
|
+
collateralFactorPercent: formatAaveV4PercentDisplay(
|
|
2447
|
+
args.reserve.settings?.collateralFactor?.normalized,
|
|
2448
|
+
args.reserve.settings?.collateralFactor?.value
|
|
2449
|
+
)
|
|
2450
|
+
};
|
|
2451
|
+
}
|
|
2452
|
+
function sortBySupplyApyDesc(a, b) {
|
|
2453
|
+
const pa = parseFloat(a.supplyApyPercent);
|
|
2454
|
+
const pb = parseFloat(b.supplyApyPercent);
|
|
2455
|
+
const na = Number.isFinite(pa) ? pa : -1;
|
|
2456
|
+
const nb = Number.isFinite(pb) ? pb : -1;
|
|
2457
|
+
if (nb !== na) return nb - na;
|
|
2458
|
+
const sym = a.symbol.localeCompare(b.symbol, void 0, { sensitivity: "base" });
|
|
2459
|
+
if (sym !== 0) return sym;
|
|
2460
|
+
return (a.spoke ?? "").localeCompare(b.spoke ?? "");
|
|
2461
|
+
}
|
|
2462
|
+
function reserveAmountRaw(raw) {
|
|
2463
|
+
const n = parseFloat((raw ?? "").trim());
|
|
2464
|
+
return Number.isFinite(n) ? n : 0;
|
|
2465
|
+
}
|
|
2466
|
+
function isAaveV4HubReserveActive(reserve) {
|
|
2467
|
+
const supplied = reserveAmountRaw(reserve.summary?.supplied?.amount?.value);
|
|
2468
|
+
const borrowed = reserveAmountRaw(reserve.summary?.borrowed?.amount?.value);
|
|
2469
|
+
return supplied > 0 || borrowed > 0;
|
|
2470
|
+
}
|
|
2471
|
+
function filterActiveAaveV4HubReserves(reserves) {
|
|
2472
|
+
return reserves.filter(isAaveV4HubReserveActive);
|
|
2473
|
+
}
|
|
2474
|
+
function parseUiMarketId(raw) {
|
|
2475
|
+
const t = (raw ?? "").trim().toLowerCase();
|
|
2476
|
+
if (t === "main" || t === "core" || t === "bluechip") return t;
|
|
2477
|
+
return void 0;
|
|
2478
|
+
}
|
|
2479
|
+
async function collectHubMarketRows(args) {
|
|
2480
|
+
const markets = [];
|
|
2481
|
+
for (const hub of args.hubs) {
|
|
2482
|
+
const reserves = filterActiveAaveV4HubReserves(
|
|
2483
|
+
await fetchAaveV4HubReserves({
|
|
2484
|
+
chainId: args.chainId,
|
|
2485
|
+
hubAddress: viem.getAddress(hub.address)
|
|
2486
|
+
})
|
|
2487
|
+
);
|
|
2488
|
+
for (const reserve of reserves) {
|
|
2489
|
+
const row = aaveV4MarketRowFromHubReserve({ chainId: args.chainId, hub, reserve });
|
|
2490
|
+
if (row) markets.push(row);
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
return markets;
|
|
2494
|
+
}
|
|
2495
|
+
async function aaveV4FetchMarketsSummary(args) {
|
|
2496
|
+
const hubs = await fetchAaveV4HubsForChain(args.chainId);
|
|
2497
|
+
if (!hubs.length) {
|
|
2498
|
+
return {
|
|
2499
|
+
chainId: args.chainId,
|
|
2500
|
+
markets: [],
|
|
2501
|
+
notes: `Aave v4 lists no hubs on chain ${args.chainId}. Check get_defi_protocol_supported_chains.`
|
|
2502
|
+
};
|
|
2503
|
+
}
|
|
2504
|
+
const wantMarket = parseUiMarketId(args.marketId);
|
|
2505
|
+
let selected = hubs;
|
|
2506
|
+
let marketNote = "";
|
|
2507
|
+
if (wantMarket) {
|
|
2508
|
+
const preferred = resolveAaveV4HubForUiMarket(hubs, wantMarket, args.chainId);
|
|
2509
|
+
if (preferred) {
|
|
2510
|
+
selected = [preferred];
|
|
2511
|
+
marketNote = ` Filtered to ${preferred.name} (${wantMarket}).`;
|
|
2512
|
+
} else {
|
|
2513
|
+
marketNote = ` No hub matched marketId ${wantMarket}; listing all hubs.`;
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
let markets = await collectHubMarketRows({ chainId: args.chainId, hubs: selected });
|
|
2517
|
+
const rawUnderlying = (args.underlying ?? "").trim();
|
|
2518
|
+
if (rawUnderlying) {
|
|
2519
|
+
markets = markets.filter(
|
|
2520
|
+
(m) => matchesAssetFilter({ address: m.underlying, symbol: m.symbol, filter: rawUnderlying })
|
|
2521
|
+
);
|
|
2522
|
+
}
|
|
2523
|
+
markets.sort(sortBySupplyApyDesc);
|
|
2524
|
+
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;
|
|
2525
|
+
return { chainId: args.chainId, markets, notes };
|
|
2526
|
+
}
|
|
2527
|
+
async function aaveV4FetchMarketSummary(args) {
|
|
2528
|
+
const addr = (args.underlying ?? "").trim();
|
|
2529
|
+
if (!addr) {
|
|
2530
|
+
throw new Error("underlying is required (ERC-20 address or ticker such as USDT).");
|
|
2531
|
+
}
|
|
2532
|
+
const out = await aaveV4FetchMarketsSummary({
|
|
2533
|
+
chainId: args.chainId,
|
|
2534
|
+
marketId: args.marketId,
|
|
2535
|
+
underlying: viem.isAddress(addr) ? viem.getAddress(addr) : addr
|
|
2536
|
+
});
|
|
2537
|
+
if (!out.markets.length) {
|
|
2538
|
+
return {
|
|
2539
|
+
...out,
|
|
2540
|
+
notes: out.notes + ` No Aave v4 reserve listed ${viem.isAddress(addr) ? viem.getAddress(addr) : addr} on chain ${args.chainId}` + (args.marketId ? ` for marketId ${args.marketId}` : "") + "."
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
return out;
|
|
2544
|
+
}
|
|
2382
2545
|
|
|
2383
2546
|
// src/protocols/evm/aave-v4/index.ts
|
|
2384
2547
|
var AAVE_V4_PROTOCOL_ID = "aave-v4";
|
|
@@ -2411,8 +2574,11 @@ exports.aaveAvailableLiquidityDisplay = aaveAvailableLiquidityDisplay;
|
|
|
2411
2574
|
exports.aaveReadSupplyMetrics = aaveReadSupplyMetrics;
|
|
2412
2575
|
exports.aaveUnderlyingAddressForContext = aaveUnderlyingAddressForContext;
|
|
2413
2576
|
exports.aaveV4BorrowHealthGate = aaveV4BorrowHealthGate;
|
|
2577
|
+
exports.aaveV4FetchMarketSummary = aaveV4FetchMarketSummary;
|
|
2578
|
+
exports.aaveV4FetchMarketsSummary = aaveV4FetchMarketsSummary;
|
|
2414
2579
|
exports.aaveV4Gql = aaveV4Gql;
|
|
2415
2580
|
exports.aaveV4KeyForNodeAssetRow = aaveV4KeyForNodeAssetRow;
|
|
2581
|
+
exports.aaveV4MarketRowFromHubReserve = aaveV4MarketRowFromHubReserve;
|
|
2416
2582
|
exports.aaveV4ProtocolModule = aaveV4ProtocolModule;
|
|
2417
2583
|
exports.aaveV4RepayHealthGate = aaveV4RepayHealthGate;
|
|
2418
2584
|
exports.aaveV4UiMarketIdForHubName = aaveV4UiMarketIdForHubName;
|
|
@@ -2445,10 +2611,12 @@ exports.fetchAaveV4UserPositionById = fetchAaveV4UserPositionById;
|
|
|
2445
2611
|
exports.fetchAaveV4UserPositionsByAssetOnChain = fetchAaveV4UserPositionsByAssetOnChain;
|
|
2446
2612
|
exports.fetchAaveV4UserPositionsForChain = fetchAaveV4UserPositionsForChain;
|
|
2447
2613
|
exports.fetchAaveV4UserSuppliesForPosition = fetchAaveV4UserSuppliesForPosition;
|
|
2614
|
+
exports.filterActiveAaveV4HubReserves = filterActiveAaveV4HubReserves;
|
|
2448
2615
|
exports.findAaveV4HubReserveForChainUnderlying = findAaveV4HubReserveForChainUnderlying;
|
|
2449
2616
|
exports.findHubReserveForUnderlying = findHubReserveForUnderlying;
|
|
2450
2617
|
exports.formatAavePercentDisplay = formatAavePercentDisplay;
|
|
2451
2618
|
exports.formatAaveV4AmountHumanFromApiString = formatAaveV4AmountHumanFromApiString;
|
|
2619
|
+
exports.formatAaveV4ApyPercentLabel = formatAaveV4ApyPercentLabel;
|
|
2452
2620
|
exports.formatAaveV4DecimalString = formatAaveV4DecimalString;
|
|
2453
2621
|
exports.formatAaveV4ExchangeLabel = formatAaveV4ExchangeLabel;
|
|
2454
2622
|
exports.formatAaveV4HealthFactor = formatAaveV4HealthFactor;
|
|
@@ -2460,9 +2628,11 @@ exports.formatAaveV4RiskDisplay = formatAaveV4RiskDisplay;
|
|
|
2460
2628
|
exports.formatAaveV4RiskNotionalString = formatAaveV4RiskNotionalString;
|
|
2461
2629
|
exports.formatAaveV4TokenAmount = formatAaveV4TokenAmount;
|
|
2462
2630
|
exports.isAaveV4DepositEvmSignRequest = isAaveV4DepositEvmSignRequest;
|
|
2631
|
+
exports.isAaveV4HubReserveActive = isAaveV4HubReserveActive;
|
|
2463
2632
|
exports.isValidAaveChainId = isValidAaveChainId;
|
|
2464
2633
|
exports.loadAaveV4SupportedChainIds = loadAaveV4SupportedChainIds;
|
|
2465
2634
|
exports.loadAaveV4SupportedChainIdsFromV4Api = loadAaveV4SupportedChainIdsFromV4Api;
|
|
2635
|
+
exports.parseAaveV4ApyPercent = parseAaveV4ApyPercent;
|
|
2466
2636
|
exports.parseBigDecimalHf = parseBigDecimalHf;
|
|
2467
2637
|
exports.pickAaveV4ReserveRowForSpoke = pickAaveV4ReserveRowForSpoke;
|
|
2468
2638
|
exports.previewAaveV4BorrowResultingHf = previewAaveV4BorrowResultingHf;
|