1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct StakerRewardsResponse {
7 pub rewards: Vec<StakerReward>,
8 pub total: Option<u64>,
9}
10
11#[derive(Debug, Clone, Serialize, Deserialize)]
13pub struct StakerReward {
14 pub stake_account: String,
16
17 pub stake_authority: String,
19
20 pub withdraw_authority: String,
22
23 pub epoch: u64,
25
26 pub mev_rewards: u64,
28
29 pub priority_fee_rewards: Option<u64>,
31
32 pub mev_claimed: bool,
34
35 pub priority_fee_claimed: Option<bool>,
37
38 pub vote_account: String,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct ValidatorRewardsResponse {
45 pub validators: Vec<ValidatorReward>,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct ValidatorReward {
51 pub vote_account: String,
53
54 pub epoch: u64,
56
57 pub mev_commission_bps: u16,
59
60 pub mev_rewards: u64,
62
63 pub priority_fee_commission_bps: Option<u16>,
65
66 pub priority_fee_rewards: Option<u64>,
68
69 pub num_stakers: Option<u64>,
71
72 pub active_stake: Option<u64>,
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
82pub struct ValidatorsResponse {
83 pub validators: Vec<ValidatorInfo>,
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize)]
88pub struct ValidatorInfo {
89 pub active_stake: Option<u64>,
91
92 pub commission: Option<u8>,
94
95 pub consensus_mods_score: Option<i8>,
97
98 pub data_center_concentration_score: Option<i64>,
100
101 pub delinquent: Option<bool>,
103
104 pub epoch: Option<u64>,
106
107 pub epoch_credits: Option<u64>,
109
110 pub identity_account: Option<String>,
112
113 pub mev_commission_bps: Option<u16>,
115
116 pub mev_revenue_lamports: Option<u64>,
118
119 pub priority_fee_commission_bps: Option<u16>,
121
122 pub priority_fee_revenue_lamports: Option<u64>,
124
125 pub name: Option<String>,
127
128 pub published_information_score: Option<i64>,
130
131 pub root_distance_score: Option<i64>,
133
134 pub running_jito: bool,
136
137 pub running_bam: Option<bool>,
139
140 pub software_version: Option<String>,
142
143 pub software_version_score: Option<i64>,
145
146 pub skipped_slot_percent: Option<String>,
148
149 pub skipped_slot_score: Option<i64>,
151
152 pub skipped_slots: Option<u64>,
154
155 pub stake_concentration_score: Option<i64>,
157
158 pub stake_percent: Option<f64>,
160
161 pub target_pool_active_lamports: Option<u64>,
163
164 pub target_pool_transient_lamports: Option<u64>,
166
167 pub target_pool_staked: Option<bool>,
169
170 pub vote_account: String,
175
176 pub vote_credit_proportion: Option<f64>,
178
179 pub www_url: Option<String>,
181
182 pub inflation_rewards_lamports: Option<u64>,
184}
185
186#[derive(Debug, Clone, Serialize, Deserialize)]
188pub struct ValidatorHistory {
189 pub epoch: u64,
191
192 pub mev_commission_bps: u16,
194
195 pub mev_rewards: u64,
197
198 pub priority_fee_commission_bps: Option<u16>,
200
201 pub priority_fee_rewards: Option<u64>,
203}
204
205#[derive(Debug, Clone, Serialize, Deserialize)]
207pub struct MevRewards {
208 pub epoch: u64,
210
211 pub total_network_mev_lamports: u64,
213
214 pub jito_stake_weight_lamports: u64,
216
217 pub mev_reward_per_lamport: f64,
219}
220
221#[derive(Debug, Clone, Serialize, Deserialize)]
223pub struct DailyMevTips {
224 pub day: DateTime<Utc>,
226
227 pub count_mev_tips: u64,
229
230 pub jito_tips: f64,
232
233 pub tippers: u64,
235
236 pub validator_tips: f64,
238}
239
240#[derive(Debug, Clone, Serialize, Deserialize)]
242pub struct JitoStakeOverTime {
243 pub stake_ratio_over_time: std::collections::HashMap<String, f64>,
245}
246
247#[derive(Debug, Clone, Serialize, Deserialize)]
249pub struct MevCommissionAverageOverTime {
250 pub aggregated_mev_rewards: u64,
252
253 pub mev_rewards: Vec<TimeSeriesData<u64>>,
255
256 pub tvl: Vec<TimeSeriesData<u64>>,
258
259 pub apy: Vec<TimeSeriesData<f64>>,
261
262 pub num_validators: Vec<TimeSeriesData<u64>>,
264
265 pub supply: Vec<TimeSeriesData<f64>>,
267}
268
269#[derive(Debug, Clone, Serialize, Deserialize)]
271pub struct TimeSeriesData<T> {
272 pub data: T,
274
275 pub date: DateTime<Utc>,
277}
278
279#[derive(Debug, Clone, Serialize, Deserialize)]
281pub struct JitoSolRatio {
282 pub ratios: Vec<TimeSeriesData<f64>>,
284}
285
286#[derive(Debug, Clone, Serialize, Deserialize)]
288pub struct StakePoolStats {
289 pub epoch: u64,
291
292 pub total_lamports: u64,
294
295 pub jitosol_supply: f64,
297
298 pub exchange_ratio: f64,
300
301 pub apy: f64,
303
304 pub num_validators: u64,
306
307 pub total_mev_earned: u64,
309}
310
311#[derive(Debug, Clone, Serialize, Deserialize)]
317pub struct EpochRequest {
318 pub epoch: u64,
320}
321
322#[derive(Debug, Clone, Serialize, Deserialize)]
324pub struct RangeFilter {
325 pub start: DateTime<Utc>,
327
328 pub end: DateTime<Utc>,
330}
331
332#[derive(Debug, Clone, Serialize, Deserialize)]
334pub struct RangeRequest {
335 pub range_filter: RangeFilter,
337}
338
339#[derive(Debug, Clone, Serialize, Deserialize)]
345pub struct ValidatorHistoryAccount {
346 pub vote_account: String,
348
349 pub history: Vec<ValidatorHistoryEntry>,
351}
352
353#[derive(Debug, Clone, Serialize, Deserialize)]
355pub struct ValidatorHistoryEntry {
356 pub epoch: u64,
358
359 pub vote_credits: Option<u32>,
361
362 pub commission: Option<u8>,
364
365 pub mev_commission_bps: Option<u16>,
367
368 pub version: Option<String>,
370
371 pub client_type: Option<String>,
373
374 pub active_stake: Option<u64>,
376
377 pub stake_rank: Option<u32>,
379
380 pub is_superminority: Option<bool>,
382
383 pub ip_address: Option<String>,
385}
386
387#[derive(Debug, Clone, Serialize, Deserialize)]
389pub struct StewardConfig {
390 pub stake_pool: String,
392
393 pub authority: String,
395
396 pub scoring_params: ScoringParams,
398}
399
400#[derive(Debug, Clone, Serialize, Deserialize)]
402pub struct ScoringParams {
403 pub min_vote_credits: u32,
405
406 pub max_commission: u8,
408
409 pub performance_weight: f64,
411
412 pub commission_weight: f64,
414
415 pub stake_concentration_limit: f64,
417}
418
419#[derive(Debug, Clone, Default)]
425pub struct QueryParams {
426 pub limit: Option<u32>,
428
429 pub offset: Option<u32>,
431
432 pub epoch: Option<u64>,
434
435 pub sort_order: Option<String>,
437}
438
439impl QueryParams {
440 pub fn with_limit(limit: u32) -> Self {
442 Self {
443 limit: Some(limit),
444 ..Default::default()
445 }
446 }
447
448 pub fn with_epoch(epoch: u64) -> Self {
450 Self {
451 epoch: Some(epoch),
452 ..Default::default()
453 }
454 }
455
456 pub fn limit(mut self, limit: u32) -> Self {
458 self.limit = Some(limit);
459 self
460 }
461
462 pub fn offset(mut self, offset: u32) -> Self {
464 self.offset = Some(offset);
465 self
466 }
467
468 pub fn epoch(mut self, epoch: u64) -> Self {
470 self.epoch = Some(epoch);
471 self
472 }
473
474 pub fn to_query_string(&self) -> String {
476 let mut params = Vec::new();
477
478 if let Some(limit) = self.limit {
479 params.push(format!("limit={}", limit));
480 }
481 if let Some(offset) = self.offset {
482 params.push(format!("offset={}", offset));
483 }
484 if let Some(epoch) = self.epoch {
485 params.push(format!("epoch={}", epoch));
486 }
487 if let Some(ref sort_order) = self.sort_order {
488 params.push(format!("sort_order={}", sort_order));
489 }
490
491 if params.is_empty() {
492 String::new()
493 } else {
494 format!("?{}", params.join("&"))
495 }
496 }
497}
498
499#[derive(Debug, Clone, Serialize, Deserialize)]
505pub struct ApiErrorResponse {
506 pub error: String,
507 pub message: Option<String>,
508 pub status_code: Option<u16>,
509}