solagent_rig_pumpfun/
lib.rs1
2use serde::{Deserialize, Serialize};
3use solagent_core::{
4 rig::{
5 completion::ToolDefinition,
6 tool::Tool,
7 },
8 SolanaAgentKit,
9};
10use solagent_parameters::parameters;
11use solagent_plugin_pumpfun::{launch_token_pumpfun, PumpFunTokenOptions, PumpfunTokenResponse};
12use std::sync::Arc;
13
14#[derive(Deserialize)]
15pub struct LaunchPumpfunTokenArgs {
16 token_name: String,
17 token_symbol: String,
18 description: String,
19 image_url: String,
20 options: Option<PumpFunTokenOptions>,
21}
22
23#[derive(Deserialize, Serialize)]
24pub struct LaunchPumpfunTokenOutput {
25 pub res: PumpfunTokenResponse,
26}
27
28#[derive(Debug, thiserror::Error)]
29#[error("LaunchPumpfunToken error")]
30pub struct LaunchPumpfunTokenError;
31
32pub struct LaunchPumpfunToken {
33 agent: Arc<SolanaAgentKit>,
34}
35
36impl LaunchPumpfunToken {
37 pub fn new(agent: Arc<SolanaAgentKit>) -> Self {
38 LaunchPumpfunToken { agent }
39 }
40}
41
42impl Tool for LaunchPumpfunToken {
43 const NAME: &'static str = "launch_token_pumpfun";
44
45 type Error = LaunchPumpfunTokenError;
46 type Args = LaunchPumpfunTokenArgs;
47 type Output = LaunchPumpfunTokenOutput;
48
49 async fn definition(&self, _prompt: String) -> ToolDefinition {
50 ToolDefinition {
51 name: "launch_token_pumpfun".to_string(),
52 description: r#"
53 Launch a new token on Pump.fun with customizable metadata and initial liquidity.
54 do not use this tool for any other purpose, or for creating SPL tokens.
55 If the user asks you to chose the parameters, you should generate valid values.
56 For generating the image, you can use the solana_create_image tool.
57
58 examples: [
59 [
60 {
61 input: {
62 token_name: "Sample Token",
63 token_symbol: "SMPL",
64 description: "A sample token for demonstration",
65 image_url: "https://example.com/token.png",
66 options: {
67 twitter: "@sampletoken",
68 telegram: "t.me/sampletoken",
69 website: "https://sampletoken.com",
70 initial_liquidity_sol: 0.1,
71 slippage_bps: 10,
72 priority_fee: 0.0001,
73 }
74 },
75 output: {
76 status: "success",
77 signature: "2ZE7Rz...",
78 mint: "7nxQB...",
79 metadataUri: "https://arweave.net/...",
80 message: "Successfully launched token on Pump.fun",
81 },
82
83 explanation: "Launch a new token with custom metadata and 0.1 SOL initial liquidity",
84 },
85 ],
86 ]
87 "#
88 .to_string(),
89 parameters: parameters!(
90 token_name: String,
91 token_symbol: String,
92 description: String,
93 image_url: String,
94 options: Option<PumpFunTokenOptions>,
95 ),
96 }
97 }
98
99 async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
100 let res = launch_token_pumpfun(
101 &self.agent,
102 &args.token_name,
103 &args.token_symbol,
104 &args.description,
105 &args.image_url,
106 args.options,
107 )
108 .await
109 .expect("launch_token_pumpfun");
110
111 Ok(LaunchPumpfunTokenOutput { res })
112 }
113}