mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-24 23:26:44 +00:00
Merge branch 'main' into jup-sol
This commit is contained in:
@@ -516,6 +516,57 @@ export class SolanaCreateImageTool extends Tool {
|
||||
}
|
||||
}
|
||||
|
||||
export class SolanaLendAssetTool extends Tool {
|
||||
name = "solana_lend_asset";
|
||||
description = `Lend idle USDC for yield using Lulo. ( only USDC is supported )
|
||||
|
||||
Inputs (input is a json string):
|
||||
amount: number, eg 1, 0.01 (required)`;
|
||||
|
||||
constructor(private solanaKit: SolanaAgentKit) {
|
||||
super();
|
||||
}
|
||||
|
||||
async _call(input: string): Promise<string> {
|
||||
try {
|
||||
let amount = JSON.parse(input).amount || input;
|
||||
|
||||
const tx = await this.solanaKit.lendAssets(amount);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Asset lent successfully",
|
||||
transaction: tx,
|
||||
amount: amount,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "UNKNOWN_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class SolanaStakeTool extends Tool {
|
||||
name = "solana_stake";
|
||||
description = `This tool can be used to stake your SOL (Solana), also called as SOL staking or liquid staking.
|
||||
@@ -562,6 +613,8 @@ export function createSolanaTools(solanaKit: SolanaAgentKit) {
|
||||
new SolanaGetWalletAddressTool(solanaKit),
|
||||
new SolanaPumpfunTokenLaunchTool(solanaKit),
|
||||
new SolanaCreateImageTool(solanaKit),
|
||||
new SolanaLendAssetTool(solanaKit),
|
||||
new SolanaTPSCalculatorTool(solanaKit),
|
||||
new SolanaStakeTool(solanaKit),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user