@t2000/engine 0.5.8 → 0.5.9
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/index.d.ts +1 -1
- package/dist/index.js +5 -76
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -788,12 +788,12 @@ declare const balanceCheckTool: Tool<{}, {
|
|
|
788
788
|
declare const savingsInfoTool: Tool<{}, SavingsResult>;
|
|
789
789
|
|
|
790
790
|
declare const healthCheckTool: Tool<{}, {
|
|
791
|
+
status: string;
|
|
791
792
|
healthFactor: number;
|
|
792
793
|
supplied: number;
|
|
793
794
|
borrowed: number;
|
|
794
795
|
maxBorrow: number;
|
|
795
796
|
liquidationThreshold: number;
|
|
796
|
-
status: string;
|
|
797
797
|
}>;
|
|
798
798
|
|
|
799
799
|
declare const ratesInfoTool: Tool<{}, _t2000_sdk.RatesResult>;
|
package/dist/index.js
CHANGED
|
@@ -555,21 +555,11 @@ var balanceCheckTool = buildTool({
|
|
|
555
555
|
});
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
savings = sp.savings;
|
|
564
|
-
debt = sp.borrows;
|
|
565
|
-
pendingRewardsUsd = sp.pendingRewards;
|
|
566
|
-
} else {
|
|
567
|
-
const posEntries = transformPositions(positions);
|
|
568
|
-
const rewardEntries = transformRewards(rewards);
|
|
569
|
-
savings = posEntries.filter((p) => p.type === "supply").reduce((sum, p) => sum + p.valueUsd, 0);
|
|
570
|
-
debt = posEntries.filter((p) => p.type === "borrow").reduce((sum, p) => sum + p.valueUsd, 0);
|
|
571
|
-
pendingRewardsUsd = rewardEntries.reduce((sum, r) => sum + r.valueUsd, 0);
|
|
572
|
-
}
|
|
558
|
+
const posEntries = transformPositions(positions);
|
|
559
|
+
const rewardEntries = transformRewards(rewards);
|
|
560
|
+
const savings = posEntries.filter((p) => p.type === "supply").reduce((sum, p) => sum + p.valueUsd, 0);
|
|
561
|
+
const debt = posEntries.filter((p) => p.type === "borrow").reduce((sum, p) => sum + p.valueUsd, 0);
|
|
562
|
+
const pendingRewardsUsd = rewardEntries.reduce((sum, r) => sum + r.valueUsd, 0);
|
|
573
563
|
const bal = {
|
|
574
564
|
available: availableUsd,
|
|
575
565
|
savings,
|
|
@@ -693,47 +683,6 @@ async function fetchProtocolStats(manager, opts) {
|
|
|
693
683
|
}
|
|
694
684
|
|
|
695
685
|
// src/tools/savings.ts
|
|
696
|
-
function buildSavingsFromServer(sp) {
|
|
697
|
-
const positions = [
|
|
698
|
-
...sp.supplies.map((s) => ({
|
|
699
|
-
protocol: s.protocol,
|
|
700
|
-
type: "supply",
|
|
701
|
-
symbol: s.asset,
|
|
702
|
-
amount: s.amount,
|
|
703
|
-
valueUsd: s.amountUsd,
|
|
704
|
-
apy: s.apy,
|
|
705
|
-
liquidationThreshold: 0
|
|
706
|
-
})),
|
|
707
|
-
...sp.borrows_detail.map((b) => ({
|
|
708
|
-
protocol: b.protocol,
|
|
709
|
-
type: "borrow",
|
|
710
|
-
symbol: b.asset,
|
|
711
|
-
amount: b.amount,
|
|
712
|
-
valueUsd: b.amountUsd,
|
|
713
|
-
apy: b.apy,
|
|
714
|
-
liquidationThreshold: 0
|
|
715
|
-
}))
|
|
716
|
-
];
|
|
717
|
-
const supplied = sp.savings;
|
|
718
|
-
const weightedApy = supplied > 0 ? sp.savingsRate : 0;
|
|
719
|
-
const dailyEarning = supplied * weightedApy / 365;
|
|
720
|
-
return {
|
|
721
|
-
positions,
|
|
722
|
-
earnings: {
|
|
723
|
-
totalYieldEarned: 0,
|
|
724
|
-
currentApy: weightedApy,
|
|
725
|
-
dailyEarning,
|
|
726
|
-
supplied
|
|
727
|
-
},
|
|
728
|
-
fundStatus: {
|
|
729
|
-
supplied,
|
|
730
|
-
apy: weightedApy,
|
|
731
|
-
earnedToday: dailyEarning,
|
|
732
|
-
earnedAllTime: 0,
|
|
733
|
-
projectedMonthly: dailyEarning * 30
|
|
734
|
-
}
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
686
|
var savingsInfoTool = buildTool({
|
|
738
687
|
name: "savings_info",
|
|
739
688
|
description: "Get detailed savings positions and earnings: current deposits by protocol, APY, total yield earned, daily earning rate, and projected monthly returns.",
|
|
@@ -741,9 +690,6 @@ var savingsInfoTool = buildTool({
|
|
|
741
690
|
jsonSchema: { type: "object", properties: {}, required: [] },
|
|
742
691
|
isReadOnly: true,
|
|
743
692
|
async call(_input, context) {
|
|
744
|
-
if (context.serverPositions) {
|
|
745
|
-
return { data: buildSavingsFromServer(context.serverPositions) };
|
|
746
|
-
}
|
|
747
693
|
if (hasNaviMcp(context)) {
|
|
748
694
|
const savings = await fetchSavings(
|
|
749
695
|
getMcpManager(context),
|
|
@@ -799,23 +745,6 @@ var healthCheckTool = buildTool({
|
|
|
799
745
|
jsonSchema: { type: "object", properties: {}, required: [] },
|
|
800
746
|
isReadOnly: true,
|
|
801
747
|
async call(_input, context) {
|
|
802
|
-
if (context.serverPositions) {
|
|
803
|
-
const sp = context.serverPositions;
|
|
804
|
-
const hfVal = sp.healthFactor ?? (sp.borrows > 0 ? Infinity : Infinity);
|
|
805
|
-
const status2 = hfStatus(hfVal);
|
|
806
|
-
const displayHf = Number.isFinite(hfVal) ? hfVal.toFixed(2) : "\u221E";
|
|
807
|
-
return {
|
|
808
|
-
data: {
|
|
809
|
-
healthFactor: hfVal,
|
|
810
|
-
supplied: sp.savings,
|
|
811
|
-
borrowed: sp.borrows,
|
|
812
|
-
maxBorrow: sp.maxBorrow,
|
|
813
|
-
liquidationThreshold: 0,
|
|
814
|
-
status: status2
|
|
815
|
-
},
|
|
816
|
-
displayText: `Health Factor: ${displayHf} (${status2})`
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
748
|
if (hasNaviMcp(context)) {
|
|
820
749
|
const hf2 = await fetchHealthFactor(
|
|
821
750
|
getMcpManager(context),
|