@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
|
@@ -362,11 +362,18 @@ var cometInterfaceAbi = viem.parseAbi([
|
|
|
362
362
|
"function isBorrowCollateralized(address account) view returns (bool)",
|
|
363
363
|
"function isLiquidatable(address account) view returns (bool)",
|
|
364
364
|
"function getAssetInfo(uint8 i) view returns ((uint8 offset, address asset, address priceFeed, uint64 scale, uint64 borrowCollateralFactor, uint64 liquidateCollateralFactor, uint64 liquidationFactor, uint128 supplyCap))",
|
|
365
|
-
"function getAssetInfoByAddress(address asset) view returns ((uint8 offset, address asset, address priceFeed, uint64 scale, uint64 borrowCollateralFactor, uint64 liquidateCollateralFactor, uint64 liquidationFactor, uint128 supplyCap))"
|
|
365
|
+
"function getAssetInfoByAddress(address asset) view returns ((uint8 offset, address asset, address priceFeed, uint64 scale, uint64 borrowCollateralFactor, uint64 liquidateCollateralFactor, uint64 liquidationFactor, uint128 supplyCap))",
|
|
366
|
+
"function baseTrackingSupplySpeed() view returns (uint256)",
|
|
367
|
+
"function baseTrackingBorrowSpeed() view returns (uint256)",
|
|
368
|
+
"function baseIndexScale() view returns (uint64)",
|
|
369
|
+
"function trackingIndexScale() view returns (uint256)",
|
|
370
|
+
"function totalSupply() view returns (uint256)",
|
|
371
|
+
"function totalBorrow() view returns (uint256)"
|
|
366
372
|
]);
|
|
367
373
|
var cometRewardsAbi = viem.parseAbi([
|
|
368
374
|
"function getRewardOwed(address comet, address account) view returns ((address token, uint256 owed))",
|
|
369
|
-
"function claim(address comet, address src, bool shouldAccrue)"
|
|
375
|
+
"function claim(address comet, address src, bool shouldAccrue)",
|
|
376
|
+
"function rewardConfig(address comet) view returns ((address token, uint64 rescaleFactor, bool shouldUpscale))"
|
|
370
377
|
]);
|
|
371
378
|
var cometBulkerAbi = viem.parseAbi([
|
|
372
379
|
"function invoke(bytes32[] actions, bytes[] data) payable"
|
|
@@ -470,6 +477,22 @@ function compoundV3UtilizationToDecimal(utilization) {
|
|
|
470
477
|
function compoundV3FactorToPercent(factor) {
|
|
471
478
|
return Number(factor) / 1e16;
|
|
472
479
|
}
|
|
480
|
+
var COMPOUND_V3_PRICE_SCALE = 1e8;
|
|
481
|
+
var COMPOUND_V3_TRACKING_INDEX_SCALE = 1e15;
|
|
482
|
+
function compoundV3TrackingSpeedToRewardAprPercent(args) {
|
|
483
|
+
if (args.trackingSpeed <= 0n || args.totalBase <= 0n || args.basePrice <= 0n || args.rewardPrice <= 0n) {
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
const scale = Number(args.trackingIndexScale > 0n ? args.trackingIndexScale : BigInt(COMPOUND_V3_TRACKING_INDEX_SCALE));
|
|
487
|
+
if (!Number.isFinite(scale) || scale <= 0) return null;
|
|
488
|
+
const tokensPerYear = Number(args.trackingSpeed) / scale * COMPOUND_V3_SECONDS_PER_YEAR;
|
|
489
|
+
const rewardUsdPerYear = tokensPerYear * (Number(args.rewardPrice) / COMPOUND_V3_PRICE_SCALE);
|
|
490
|
+
const totalUsd = Number(args.totalBase) / 10 ** args.baseDecimals * (Number(args.basePrice) / COMPOUND_V3_PRICE_SCALE);
|
|
491
|
+
if (!Number.isFinite(rewardUsdPerYear) || !Number.isFinite(totalUsd) || totalUsd <= 0) return null;
|
|
492
|
+
const pct = rewardUsdPerYear / totalUsd * 100;
|
|
493
|
+
if (!Number.isFinite(pct) || pct < 0) return null;
|
|
494
|
+
return pct;
|
|
495
|
+
}
|
|
473
496
|
|
|
474
497
|
// src/protocols/evm/compound-v3/subgraph.ts
|
|
475
498
|
var COMPOUND_V3_SUBGRAPH_BY_CHAIN = {
|
|
@@ -528,7 +551,7 @@ async function enrichMarketOnChain(client, market) {
|
|
|
528
551
|
client.readContract({ address: comet, abi: cometInterfaceAbi, functionName: "numAssets" }),
|
|
529
552
|
client.readContract({ address: comet, abi: cometInterfaceAbi, functionName: "decimals" })
|
|
530
553
|
]);
|
|
531
|
-
const [supplyRate, borrowRate, baseMeta, baseFeed] = await Promise.all([
|
|
554
|
+
const [supplyRate, borrowRate, baseMeta, baseFeed, supplySpeed, borrowSpeed, totalSupply, totalBorrow, trackingScale] = await Promise.all([
|
|
532
555
|
client.readContract({
|
|
533
556
|
address: comet,
|
|
534
557
|
abi: cometInterfaceAbi,
|
|
@@ -542,7 +565,12 @@ async function enrichMarketOnChain(client, market) {
|
|
|
542
565
|
args: [utilization]
|
|
543
566
|
}),
|
|
544
567
|
readTokenMeta(client, viem.getAddress(baseToken)),
|
|
545
|
-
client.readContract({ address: comet, abi: cometInterfaceAbi, functionName: "baseTokenPriceFeed" })
|
|
568
|
+
client.readContract({ address: comet, abi: cometInterfaceAbi, functionName: "baseTokenPriceFeed" }),
|
|
569
|
+
client.readContract({ address: comet, abi: cometInterfaceAbi, functionName: "baseTrackingSupplySpeed" }).catch(() => 0n),
|
|
570
|
+
client.readContract({ address: comet, abi: cometInterfaceAbi, functionName: "baseTrackingBorrowSpeed" }).catch(() => 0n),
|
|
571
|
+
client.readContract({ address: comet, abi: cometInterfaceAbi, functionName: "totalSupply" }).catch(() => 0n),
|
|
572
|
+
client.readContract({ address: comet, abi: cometInterfaceAbi, functionName: "totalBorrow" }).catch(() => 0n),
|
|
573
|
+
client.readContract({ address: comet, abi: cometInterfaceAbi, functionName: "trackingIndexScale" }).catch(() => BigInt(COMPOUND_V3_TRACKING_INDEX_SCALE))
|
|
546
574
|
]);
|
|
547
575
|
const basePrice = await client.readContract({ address: comet, abi: cometInterfaceAbi, functionName: "getPrice", args: [baseFeed] }).catch(() => 0n);
|
|
548
576
|
const assets = [
|
|
@@ -577,6 +605,47 @@ async function enrichMarketOnChain(client, market) {
|
|
|
577
605
|
role: "collateral"
|
|
578
606
|
});
|
|
579
607
|
}
|
|
608
|
+
let rewardPrice = 0n;
|
|
609
|
+
try {
|
|
610
|
+
const cfg = await client.readContract({
|
|
611
|
+
address: viem.getAddress(market.rewards),
|
|
612
|
+
abi: cometRewardsAbi,
|
|
613
|
+
functionName: "rewardConfig",
|
|
614
|
+
args: [comet]
|
|
615
|
+
});
|
|
616
|
+
const rewardToken = viem.getAddress(cfg.token);
|
|
617
|
+
const listed = assets.find((a) => a.asset.toLowerCase() === rewardToken.toLowerCase());
|
|
618
|
+
if (listed && listed.priceRaw !== "0") {
|
|
619
|
+
rewardPrice = BigInt(listed.priceRaw);
|
|
620
|
+
} else {
|
|
621
|
+
const info = await client.readContract({
|
|
622
|
+
address: comet,
|
|
623
|
+
abi: cometInterfaceAbi,
|
|
624
|
+
functionName: "getAssetInfoByAddress",
|
|
625
|
+
args: [rewardToken]
|
|
626
|
+
});
|
|
627
|
+
rewardPrice = await client.readContract({ address: comet, abi: cometInterfaceAbi, functionName: "getPrice", args: [info.priceFeed] }).catch(() => 0n);
|
|
628
|
+
}
|
|
629
|
+
} catch {
|
|
630
|
+
rewardPrice = 0n;
|
|
631
|
+
}
|
|
632
|
+
const baseDecimals = Number(decimals) || baseMeta.decimals;
|
|
633
|
+
const supplyRewardApr = compoundV3TrackingSpeedToRewardAprPercent({
|
|
634
|
+
trackingSpeed: supplySpeed,
|
|
635
|
+
trackingIndexScale: trackingScale,
|
|
636
|
+
totalBase: totalSupply,
|
|
637
|
+
baseDecimals,
|
|
638
|
+
basePrice,
|
|
639
|
+
rewardPrice
|
|
640
|
+
});
|
|
641
|
+
const borrowRewardApr = compoundV3TrackingSpeedToRewardAprPercent({
|
|
642
|
+
trackingSpeed: borrowSpeed,
|
|
643
|
+
trackingIndexScale: trackingScale,
|
|
644
|
+
totalBase: totalBorrow,
|
|
645
|
+
baseDecimals,
|
|
646
|
+
basePrice,
|
|
647
|
+
rewardPrice
|
|
648
|
+
});
|
|
580
649
|
return {
|
|
581
650
|
chainId: market.chainId,
|
|
582
651
|
slug: market.slug,
|
|
@@ -588,6 +657,8 @@ async function enrichMarketOnChain(client, market) {
|
|
|
588
657
|
utilization: compoundV3UtilizationToDecimal(utilization),
|
|
589
658
|
supplyAprPercent: compoundV3AprToPercentLabel(compoundV3RatePerSecondToAprDecimal(supplyRate)),
|
|
590
659
|
borrowAprPercent: compoundV3AprToPercentLabel(compoundV3RatePerSecondToAprDecimal(borrowRate)),
|
|
660
|
+
supplyRewardAprPercent: supplyRewardApr == null ? null : compoundV3AprToPercentLabel(supplyRewardApr / 100),
|
|
661
|
+
borrowRewardAprPercent: borrowRewardApr == null ? null : compoundV3AprToPercentLabel(borrowRewardApr / 100),
|
|
591
662
|
assets
|
|
592
663
|
};
|
|
593
664
|
}
|
|
@@ -603,6 +674,8 @@ function registryMarketRow(market) {
|
|
|
603
674
|
utilization: null,
|
|
604
675
|
supplyAprPercent: null,
|
|
605
676
|
borrowAprPercent: null,
|
|
677
|
+
supplyRewardAprPercent: null,
|
|
678
|
+
borrowRewardAprPercent: null,
|
|
606
679
|
assets: market.baseToken ? [
|
|
607
680
|
{
|
|
608
681
|
asset: market.baseToken,
|
|
@@ -629,7 +702,7 @@ async function compoundV3FetchMarketsSummary(args) {
|
|
|
629
702
|
if (!args.rpcUrl?.trim()) {
|
|
630
703
|
return {
|
|
631
704
|
markets: registry.map(registryMarketRow),
|
|
632
|
-
notes: "Registry from official comet deployments. Pass rpcUrl (MCP server injects it) to enrich APRs and collaterals." + subgraphNote
|
|
705
|
+
notes: "Registry from official comet deployments. Pass rpcUrl (MCP server injects it) to enrich APRs, reward APRs, and collaterals." + subgraphNote
|
|
633
706
|
};
|
|
634
707
|
}
|
|
635
708
|
const client = publicClient(args.rpcUrl, args.chainId);
|
|
@@ -643,7 +716,7 @@ async function compoundV3FetchMarketsSummary(args) {
|
|
|
643
716
|
}
|
|
644
717
|
return {
|
|
645
718
|
markets,
|
|
646
|
-
notes: "Comet proxy addresses from official deployments;
|
|
719
|
+
notes: "Comet proxy addresses from official deployments; base supply/borrow APR and COMP incentive APR from on-chain CometInterface. Incentive APR is extra and variable; null when the reward token has no on-chain price feed." + subgraphNote
|
|
647
720
|
};
|
|
648
721
|
}
|
|
649
722
|
async function compoundV3FetchMarketSummary(args) {
|
|
@@ -1494,8 +1567,10 @@ exports.BULKER_ACTION_WITHDRAW_NATIVE_TOKEN = BULKER_ACTION_WITHDRAW_NATIVE_TOKE
|
|
|
1494
1567
|
exports.COMPOUND_V3_CHAIN_IDS = COMPOUND_V3_CHAIN_IDS;
|
|
1495
1568
|
exports.COMPOUND_V3_FACTOR_SCALE = COMPOUND_V3_FACTOR_SCALE;
|
|
1496
1569
|
exports.COMPOUND_V3_MARKETS = COMPOUND_V3_MARKETS;
|
|
1570
|
+
exports.COMPOUND_V3_PRICE_SCALE = COMPOUND_V3_PRICE_SCALE;
|
|
1497
1571
|
exports.COMPOUND_V3_PROTOCOL_ID = COMPOUND_V3_PROTOCOL_ID;
|
|
1498
1572
|
exports.COMPOUND_V3_SECONDS_PER_YEAR = COMPOUND_V3_SECONDS_PER_YEAR;
|
|
1573
|
+
exports.COMPOUND_V3_TRACKING_INDEX_SCALE = COMPOUND_V3_TRACKING_INDEX_SCALE;
|
|
1499
1574
|
exports.COMPOUND_V3_WRAPPED_NATIVE = COMPOUND_V3_WRAPPED_NATIVE;
|
|
1500
1575
|
exports.buildEvmMultisignBodyCompoundV3Bulker = buildEvmMultisignBodyCompoundV3Bulker;
|
|
1501
1576
|
exports.buildEvmMultisignBodyCompoundV3ClaimRewards = buildEvmMultisignBodyCompoundV3ClaimRewards;
|
|
@@ -1518,6 +1593,7 @@ exports.compoundV3KeyForNodeAssetRow = compoundV3KeyForNodeAssetRow;
|
|
|
1518
1593
|
exports.compoundV3ProtocolModule = compoundV3ProtocolModule;
|
|
1519
1594
|
exports.compoundV3RatePerSecondToAprDecimal = compoundV3RatePerSecondToAprDecimal;
|
|
1520
1595
|
exports.compoundV3SubgraphIdForChain = compoundV3SubgraphIdForChain;
|
|
1596
|
+
exports.compoundV3TrackingSpeedToRewardAprPercent = compoundV3TrackingSpeedToRewardAprPercent;
|
|
1521
1597
|
exports.compoundV3UtilizationToDecimal = compoundV3UtilizationToDecimal;
|
|
1522
1598
|
exports.compoundV3WrappedNative = compoundV3WrappedNative;
|
|
1523
1599
|
exports.createCompoundV3PublicClient = createCompoundV3PublicClient;
|