ferrox-actions 0.1.0

Action system for the Ferrox AI framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
pub mod client;

use crate::{
    action::{ActionBuilder, ActionGroup, FunctionAction},
    AgentState,
};
use client::BirdeyeClient;
use serde::Deserialize;
use std::sync::Arc;

// Parameter structs for each action
#[derive(Debug, Deserialize)]
pub struct TokenPriceParams {
    address: String,
}

#[derive(Debug, Deserialize)]
pub struct TokenPriceHistoryParams {
    address: String,
    resolution: String,
    limit: Option<i32>,
}

#[derive(Debug, Deserialize)]
pub struct MultiTokenPriceParams {
    addresses: String, // Comma-separated list of addresses
}

#[derive(Debug, Deserialize)]
pub struct TokenOhlcvParams {
    address: String,
    resolution: String, // "1" | "3" | "5" | "15" | "30" | "60" | "120" | "240" | "360" | "480" | "720" | "1D" | "3D" | "1W" | "1M"
}

#[derive(Debug, Deserialize)]
pub struct PairOhlcvParams {
    pair_address: String,
    resolution: String,
}

#[derive(Debug, Deserialize)]
pub struct TokenTradesParams {
    address: String,
    limit: Option<i32>,
    offset: Option<i32>,
}

#[derive(Debug, Deserialize)]
pub struct PairTradesParams {
    pair_address: String,
    limit: Option<i32>,
    offset: Option<i32>,
}

#[derive(Debug, Deserialize)]
pub struct TokenOverviewParams {
    address: String,
}

#[derive(Debug, Deserialize)]
pub struct TokenListParams {
    limit: Option<i32>,
    offset: Option<i32>,
}

#[derive(Debug, Deserialize)]
pub struct TokenSecurityParams {
    address: String,
}

#[derive(Debug, Deserialize)]
pub struct TokenMarketListParams {
    address: String,
}

#[derive(Debug, Deserialize)]
pub struct TokenNewListingParams {
    limit: Option<i32>,
    offset: Option<i32>,
}

#[derive(Debug, Deserialize)]
pub struct TokenTopTradersParams {
    address: String,
    limit: Option<i32>,
}

#[derive(Debug, Deserialize)]
pub struct TokenTrendingParams {
    limit: Option<i32>,
}

#[derive(Debug, Deserialize)]
pub struct GainersLosersParams {}

#[derive(Debug, Deserialize)]
pub struct TraderTxsByTimeParams {
    address: String,
    time_from: i64,
    time_to: i64,
    limit: Option<i32>,
}

#[derive(Debug, Deserialize)]
pub struct SupportedChainsParams {}

#[derive(Debug, Deserialize)]
pub struct WalletPortfolioParams {
    wallet_address: String,
    chain_id: String,
}

#[derive(Debug, Deserialize)]
pub struct WalletPortfolioMultichainParams {
    wallet_address: String,
}

#[derive(Debug, Deserialize)]
pub struct WalletTransactionHistoryParams {
    wallet_address: String,
    chain_id: String,
    limit: Option<i32>,
    offset: Option<i32>,
}

#[derive(Debug, Deserialize)]
pub struct WalletTransactionHistoryMultichainParams {
    wallet_address: String,
    limit: Option<i32>,
    offset: Option<i32>,
}

#[derive(Debug, Deserialize)]
pub struct SimulateTransactionParams {
    chain_id: String,
    tx_data: String,
}

// Action group that contains all Birdeye actions
pub struct BirdeyeActionGroup<S: Send + Sync + Clone + 'static> {
    actions: Vec<Arc<FunctionAction<S>>>,
}

impl<S: Send + Sync + Clone + 'static> ActionGroup<S> for BirdeyeActionGroup<S> {
    fn actions(&self) -> &[Arc<FunctionAction<S>>] {
        &self.actions
    }
}

impl<S: Send + Sync + Clone + 'static> BirdeyeActionGroup<S> {
    pub fn new() -> Self {
        let mut actions = Vec::new();

        // Add token price action
        {
            async fn get_token_price<S: Send + Sync + Clone + 'static>(
                params: TokenPriceParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client.get_token_price(params.address).await
            }

            let action = ActionBuilder::<_, _, _, _>::new("get_token_price", get_token_price, None)
                .description("Get real-time price data for a token")
                .parameter("address", "Token address", "string", true)
                .build();

            actions.push(Arc::new(action));
        }

        // Add token price history action
        {
            async fn get_token_price_history<S: Send + Sync + Clone + 'static>(
                params: TokenPriceHistoryParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);

                let time_to = chrono::Utc::now().timestamp();
                let time_from = calculate_time_from(time_to, &params.resolution)?;

                client
                    .get_token_price_history(
                        params.address,
                        params.resolution,
                        Some(time_from),
                        Some(time_to),
                        params.limit,
                    )
                    .await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "get_token_price_history",
                get_token_price_history,
                None,
            )
            .description("Get historical price data for a token")
            .parameter("address", "Token address", "string", true)
            .parameter(
                "resolution",
                "Time resolution (1, 3, 5, 15, 30, 60, 120, 240, 360, 480, 720, 1D, 3D, 1W, 1M)",
                "string",
                true,
            )
            .parameter("limit", "Number of records to return", "integer", false)
            .build();

            actions.push(Arc::new(action));
        }

        // Continue with more actions...
        // Add multi token price action
        {
            async fn get_multi_token_price<S: Send + Sync + Clone + 'static>(
                params: MultiTokenPriceParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client.get_multi_token_price(params.addresses).await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "get_multi_token_price",
                get_multi_token_price,
                None,
            )
            .description("Get price data for multiple tokens")
            .parameter(
                "addresses",
                "Comma-separated list of token addresses",
                "string",
                true,
            )
            .build();

            actions.push(Arc::new(action));
        }

        // Add token trending action
        {
            async fn get_token_trending<S: Send + Sync + Clone + 'static>(
                params: TokenTrendingParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client.get_token_trending(params.limit).await
            }

            let action =
                ActionBuilder::<_, _, _, _>::new("get_token_trending", get_token_trending, None)
                    .description("Get trending tokens")
                    .parameter("limit", "Number of tokens to return", "integer", false)
                    .build();

            actions.push(Arc::new(action));
        }

        // Add token OHLCV action
        {
            async fn get_token_ohlcv<S: Send + Sync + Clone + 'static>(
                params: TokenOhlcvParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);

                let time_to = chrono::Utc::now().timestamp();
                let time_from = calculate_time_from(time_to, &params.resolution)?;

                client
                    .get_token_ohlcv(params.address, params.resolution, time_from, time_to)
                    .await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "get_token_ohlcv",
                get_token_ohlcv,
                None,
            )
            .description("Get OHLCV data for a token (only solana tokens). Do not use if it is an ethereum token")
            .parameter("address", "Token address", "string", true)
            .parameter(
                "resolution",
                "Time resolution (1, 3, 5, 15, 30, 60, 120, 240, 360, 480, 720, 1D, 3D, 1W, 1M)",
                "string",
                true,
            )
            .build();

            actions.push(Arc::new(action));
        }

        // Add pair OHLCV action
        {
            async fn get_pair_ohlcv<S: Send + Sync + Clone + 'static>(
                params: PairOhlcvParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);

                let time_to = chrono::Utc::now().timestamp();
                let time_from = calculate_time_from(time_to, &params.resolution)?;

                client
                    .get_pair_ohlcv(params.pair_address, params.resolution, time_from, time_to)
                    .await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "get_pair_ohlcv",
                get_pair_ohlcv,
                None,
            )
            .description("Get OHLCV data for a trading pair")
            .parameter("pair_address", "Pair address", "string", true)
            .parameter(
                "resolution",
                "Time resolution (1, 3, 5, 15, 30, 60, 120, 240, 360, 480, 720, 1D, 3D, 1W, 1M)",
                "string",
                true,
            )
            .build();

            actions.push(Arc::new(action));
        }

        // Add token trades action
        {
            async fn get_token_trades<S: Send + Sync + Clone + 'static>(
                params: TokenTradesParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client
                    .get_token_trades(params.address, params.limit, params.offset)
                    .await
            }

            let action =
                ActionBuilder::<_, _, _, _>::new("get_token_trades", get_token_trades, None)
                    .description("Get recent trades for a token")
                    .parameter("address", "Token address", "string", true)
                    .parameter("limit", "Number of trades to return", "integer", false)
                    .parameter("offset", "Number of trades to skip", "integer", false)
                    .build();

            actions.push(Arc::new(action));
        }

        // Add pair trades action
        {
            async fn get_pair_trades<S: Send + Sync + Clone + 'static>(
                params: PairTradesParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client
                    .get_pair_trades(params.pair_address, params.limit, params.offset)
                    .await
            }

            let action = ActionBuilder::<_, _, _, _>::new("get_pair_trades", get_pair_trades, None)
                .description("Get recent trades for a trading pair")
                .parameter("pair_address", "Pair address", "string", true)
                .parameter("limit", "Number of trades to return", "integer", false)
                .parameter("offset", "Number of trades to skip", "integer", false)
                .build();

            actions.push(Arc::new(action));
        }

        // Add token overview action
        {
            async fn get_token_overview<S: Send + Sync + Clone + 'static>(
                params: TokenOverviewParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client.get_token_overview(params.address).await
            }

            let action =
                ActionBuilder::<_, _, _, _>::new("get_token_overview", get_token_overview, None)
                    .description("Get comprehensive overview data for a token")
                    .parameter("address", "Token address", "string", true)
                    .build();

            actions.push(Arc::new(action));
        }

        // Add token list action
        {
            async fn get_token_list<S: Send + Sync + Clone + 'static>(
                params: TokenListParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client.get_token_list(params.limit, params.offset).await
            }

            let action = ActionBuilder::<_, _, _, _>::new("get_token_list", get_token_list, None)
                .description("Get list of tokens with market data")
                .parameter("limit", "Number of tokens to return", "integer", false)
                .parameter("offset", "Number of tokens to skip", "integer", false)
                .build();

            actions.push(Arc::new(action));
        }

        // Add token security action
        {
            async fn get_token_security<S: Send + Sync + Clone + 'static>(
                params: TokenSecurityParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client.get_token_security(params.address).await
            }

            let action =
                ActionBuilder::<_, _, _, _>::new("get_token_security", get_token_security, None)
                    .description("Get security information for a token")
                    .parameter("address", "Token address", "string", true)
                    .build();

            actions.push(Arc::new(action));
        }

        // Add token market list action
        {
            async fn get_token_market_list<S: Send + Sync + Clone + 'static>(
                params: TokenMarketListParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client.get_token_market_list(params.address).await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "get_token_market_list",
                get_token_market_list,
                None,
            )
            .description("Get list of markets where a token is traded")
            .parameter("address", "Token address", "string", true)
            .build();

            actions.push(Arc::new(action));
        }

        // Add token new listing action
        {
            async fn get_token_new_listing<S: Send + Sync + Clone + 'static>(
                params: TokenNewListingParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client
                    .get_token_new_listing(params.limit, params.offset)
                    .await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "get_token_new_listing",
                get_token_new_listing,
                None,
            )
            .description("Get list of newly listed tokens")
            .parameter("limit", "Number of tokens to return", "integer", false)
            .parameter("offset", "Number of tokens to skip", "integer", false)
            .build();

            actions.push(Arc::new(action));
        }

        // Add token top traders action
        {
            async fn get_token_top_traders<S: Send + Sync + Clone + 'static>(
                params: TokenTopTradersParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client
                    .get_token_top_traders(params.address, params.limit)
                    .await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "get_token_top_traders",
                get_token_top_traders,
                None,
            )
            .description("Get top traders for a token")
            .parameter("address", "Token address", "string", true)
            .parameter("limit", "Number of traders to return", "integer", false)
            .build();

            actions.push(Arc::new(action));
        }

        // Add gainers/losers action
        {
            async fn get_gainers_losers<S: Send + Sync + Clone + 'static>(
                _params: GainersLosersParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client.get_gainers_losers().await
            }

            let action =
                ActionBuilder::<_, _, _, _>::new("get_gainers_losers", get_gainers_losers, None)
                    .description("Get gainers and losers data")
                    .build();

            actions.push(Arc::new(action));
        }

        // Add trader transactions by time action
        {
            async fn get_trader_txs_by_time<S: Send + Sync + Clone + 'static>(
                params: TraderTxsByTimeParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client
                    .get_trader_txs_by_time(
                        params.address,
                        params.time_from,
                        params.time_to,
                        params.limit,
                    )
                    .await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "get_trader_txs_by_time",
                get_trader_txs_by_time,
                None,
            )
            .description("Get trader transactions within a time range")
            .parameter("address", "Token address", "string", true)
            .parameter("time_from", "Start timestamp (Unix)", "integer", true)
            .parameter("time_to", "End timestamp (Unix)", "integer", true)
            .parameter(
                "limit",
                "Number of transactions to return",
                "integer",
                false,
            )
            .build();

            actions.push(Arc::new(action));
        }

        // Add supported chains action
        {
            async fn list_supported_chains<S: Send + Sync + Clone + 'static>(
                _params: SupportedChainsParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client.list_supported_chains().await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "list_supported_chains",
                list_supported_chains,
                None,
            )
            .description("List supported blockchain networks")
            .build();

            actions.push(Arc::new(action));
        }

        // Add wallet portfolio action
        {
            async fn get_wallet_portfolio<S: Send + Sync + Clone + 'static>(
                params: WalletPortfolioParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client
                    .get_wallet_portfolio(params.wallet_address, params.chain_id)
                    .await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "get_wallet_portfolio",
                get_wallet_portfolio,
                None,
            )
            .description("Get wallet portfolio for a specific chain")
            .parameter("wallet_address", "Wallet address", "string", true)
            .parameter("chain_id", "Chain ID", "string", true)
            .build();

            actions.push(Arc::new(action));
        }

        // Add multichain wallet portfolio action
        {
            async fn get_wallet_portfolio_multichain<S: Send + Sync + Clone + 'static>(
                params: WalletPortfolioMultichainParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client
                    .get_wallet_portfolio_multichain(params.wallet_address)
                    .await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "get_wallet_portfolio_multichain",
                get_wallet_portfolio_multichain,
                None,
            )
            .description("Get wallet portfolio across all chains")
            .parameter("wallet_address", "Wallet address", "string", true)
            .build();

            actions.push(Arc::new(action));
        }

        // Add wallet transaction history action
        {
            async fn get_wallet_transaction_history<S: Send + Sync + Clone + 'static>(
                params: WalletTransactionHistoryParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client
                    .get_wallet_transaction_history(
                        params.wallet_address,
                        params.chain_id,
                        params.limit,
                        params.offset,
                    )
                    .await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "get_wallet_transaction_history",
                get_wallet_transaction_history,
                None,
            )
            .description("Get wallet transaction history for a specific chain")
            .parameter("wallet_address", "Wallet address", "string", true)
            .parameter("chain_id", "Chain ID", "string", true)
            .parameter(
                "limit",
                "Number of transactions to return",
                "integer",
                false,
            )
            .parameter("offset", "Number of transactions to skip", "integer", false)
            .build();

            actions.push(Arc::new(action));
        }

        // Add multichain wallet transaction history action
        {
            async fn get_wallet_transaction_history_multichain<S: Send + Sync + Clone + 'static>(
                params: WalletTransactionHistoryMultichainParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client
                    .get_wallet_transaction_history_multichain(
                        params.wallet_address,
                        params.limit,
                        params.offset,
                    )
                    .await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "get_wallet_transaction_history_multichain",
                get_wallet_transaction_history_multichain,
                None,
            )
            .description("Get wallet transaction history across all chains")
            .parameter("wallet_address", "Wallet address", "string", true)
            .parameter(
                "limit",
                "Number of transactions to return",
                "integer",
                false,
            )
            .parameter("offset", "Number of transactions to skip", "integer", false)
            .build();

            actions.push(Arc::new(action));
        }

        // Add transaction simulation action
        {
            async fn simulate_transaction<S: Send + Sync + Clone + 'static>(
                params: SimulateTransactionParams,
                _send_state: serde_json::Value,
                _state: AgentState<S>,
            ) -> Result<String, String> {
                let api_key = std::env::var("BIRDEYE_API_KEY")
                    .map_err(|_| "BIRDEYE_API_KEY environment variable not set".to_string())?;
                let client = BirdeyeClient::new(api_key);
                client
                    .simulate_transaction(params.chain_id, params.tx_data)
                    .await
            }

            let action = ActionBuilder::<_, _, _, _>::new(
                "simulate_transaction",
                simulate_transaction,
                None,
            )
            .description("Simulate a transaction")
            .parameter("chain_id", "Chain ID", "string", true)
            .parameter("tx_data", "Transaction data", "string", true)
            .build();

            actions.push(Arc::new(action));
        }

        Self { actions }
    }
}

// Add helper function to calculate time_from based on resolution
fn calculate_time_from(time_to: i64, resolution: &str) -> Result<i64, String> {
    let duration = match resolution {
        "1" | "3" | "5" | "15" | "30" | "60" => {
            let minutes: i64 = resolution
                .parse()
                .map_err(|_| "Invalid resolution format")?;
            chrono::Duration::minutes(minutes * 100) // Get 100 data points
        }
        "120" | "240" | "360" | "480" | "720" => {
            let minutes: i64 = resolution
                .parse()
                .map_err(|_| "Invalid resolution format")?;
            chrono::Duration::minutes(minutes * 50) // Get 50 data points
        }
        "1D" => chrono::Duration::days(100),
        "3D" => chrono::Duration::days(300),
        "1W" => chrono::Duration::weeks(100),
        "1M" => chrono::Duration::days(100 * 30),
        _ => return Err("Invalid resolution".to_string()),
    };

    Ok(time_to - duration.num_seconds())
}