feat: get tps

This commit is contained in:
Arihant Bansal
2024-11-27 17:24:15 +05:30
parent c26f6093ec
commit f05a70f08c
4 changed files with 42 additions and 0 deletions

View File

@@ -239,6 +239,24 @@ export class SolanaFetchLendingDetailsTool extends Tool {
}
}
export class SolanaTPSCalculatorTool extends Tool {
name = "solana_get_tps";
description = "Get the current TPS of the Solana network";
constructor(private solanaKit: SolanaAgentKit) {
super();
}
async _call(_input: string): Promise<string> {
try {
const tps = await this.solanaKit.getTPS();
return `Solana (mainnet-beta) current transactions per second: ${tps}`;
} catch (error: any) {
return `Error fetching TPS: ${error.message}`;
}
}
}
// Updated createSolanaTools function
export function createSolanaTools(solanaKit: SolanaAgentKit) {
return [
@@ -253,5 +271,6 @@ export function createSolanaTools(solanaKit: SolanaAgentKit) {
new SolanaGetWalletAddressTool(solanaKit),
new SolanaLendAssetTool(solanaKit),
new SolanaFetchLendingDetailsTool(solanaKit),
new SolanaTPSCalculatorTool(solanaKit),
];
}