pub struct KobeClient { /* private fields */ }Expand description
Main client for interacting with Jito APIs
Implementations§
Source§impl KobeClient
impl KobeClient
Sourcepub fn mainnet() -> Self
pub fn mainnet() -> Self
Create a client with mainnet defaults
Examples found in repository?
4async fn main() {
5 // Create a client with mainnet defaults
6 let client = KobeClient::mainnet();
7
8 println!("=== Jito API Client - Basic Example ===\n");
9
10 // 1. Get current epoch
11 println!("1. Getting current epoch...");
12 let current_epoch = client.get_current_epoch().await.unwrap();
13 println!(" Current epoch: {}\n", current_epoch);
14
15 // 2. Get staker rewards
16 println!("2. Getting staker rewards (limit 5)...");
17 let rewards = client.get_staker_rewards(Some(5)).await.unwrap();
18 println!(" Found {} staker rewards:", rewards.rewards.len());
19 for (i, reward) in rewards.rewards.iter().enumerate() {
20 println!(
21 " {}. Stake Account: {}",
22 i + 1,
23 &reward.stake_account[..8]
24 );
25 println!(" MEV Rewards: {} lamports", reward.mev_rewards);
26 println!(" Epoch: {}", reward.epoch);
27 println!(" Claimed: {}", reward.mev_claimed);
28 }
29 println!();
30
31 // 3. Get validator information
32 println!("3. Getting validators running Jito...");
33 let jito_validators = client.get_jito_validators().await.unwrap();
34 println!(" Found {} validators running Jito", jito_validators.len());
35
36 // Show top 5 by stake
37 let top_5_by_stake = jito_validators.iter().take(5);
38 for (i, validator) in top_5_by_stake.enumerate() {
39 println!(
40 " {}. Vote Account: {}",
41 i + 1,
42 &validator.vote_account[..8]
43 );
44 println!(" Active Stake: {} lamports", validator.active_stake);
45 println!(" MEV Commission: {} bps", validator.mev_commission_bps);
46 }
47 println!();
48
49 // 4. Get network MEV statistics
50 println!("4. Getting MEV network statistics...");
51 let mev_stats = client.get_mev_rewards(None).await.unwrap();
52 println!(" Epoch: {}", mev_stats.epoch);
53 println!(
54 " Total Network MEV: {} lamports",
55 mev_stats.total_network_mev_lamports
56 );
57 println!(
58 " Jito Stake Weight: {} lamports",
59 mev_stats.jito_stake_weight_lamports
60 );
61 println!(
62 " MEV per lamport: {:.10}",
63 mev_stats.mev_reward_per_lamport
64 );
65 println!();
66
67 // 5. Get validator rewards
68 println!("5. Getting validator rewards...");
69 let validator_rewards = client.get_validator_rewards(None, Some(3)).await.unwrap();
70 println!(" Top 3 validators by rewards:");
71 for (i, validator) in validator_rewards.validators.iter().enumerate() {
72 println!(
73 " {}. Vote Account: {}",
74 i + 1,
75 &validator.vote_account[..8]
76 );
77 println!(" MEV Rewards: {} lamports", validator.mev_rewards);
78 if let Some(pf_rewards) = validator.priority_fee_rewards {
79 println!(" Priority Fee Rewards: {} lamports", pf_rewards);
80 }
81 }
82 println!();
83
84 // 6. Get historical validator data
85 println!("6. Getting historical data for a validator...");
86 if let Some(first_validator) = jito_validators.first() {
87 let history = client
88 .get_validator_history(&first_validator.vote_account)
89 .await
90 .unwrap();
91 println!(" Validator: {}", &first_validator.vote_account[..8]);
92 println!(" Historical data (last 3 epochs):");
93 for (i, entry) in history.iter().take(3).enumerate() {
94 println!(
95 " {}. Epoch {}: {} lamports",
96 i + 1,
97 entry.epoch,
98 entry.mev_rewards
99 );
100 }
101 }
102 println!();
103
104 // 7. Get MEV commission averages
105 println!("7. Getting MEV commission averages...");
106 let commission_avg = client.get_mev_commission_average_over_time().await.unwrap();
107 println!(
108 " Aggregated MEV Rewards: {} lamports",
109 commission_avg.aggregated_mev_rewards
110 );
111 if let Some(latest_apy) = commission_avg.apy.first() {
112 println!(" Latest APY: {:.2}%", latest_apy.data * 100.0);
113 }
114 if let Some(latest_tvl) = commission_avg.tvl.first() {
115 println!(" Latest TVL: {} lamports", latest_tvl.data);
116 }
117 println!();
118
119 // 8. Check specific validator
120 println!("8. Checking specific validator status...");
121 let test_vote_account = "GdRKUZKdiXMEATjddQW6q4W8bPgXRBYJKayfeqdQcEPa";
122 let is_running_jito = client
123 .is_validator_running_jito(test_vote_account)
124 .await
125 .unwrap();
126 println!(" Vote Account: {}", &test_vote_account[..8]);
127 println!(" Running Jito: {}", is_running_jito);
128
129 if let Some(commission) = client
130 .get_validator_mev_commission(test_vote_account)
131 .await
132 .unwrap()
133 {
134 println!(" MEV Commission: {} bps", commission);
135 }
136 println!();
137
138 // 9. Calculate total MEV for epoch range
139 println!("9. Calculating total MEV rewards...");
140 let start_epoch = current_epoch.saturating_sub(5);
141 let end_epoch = current_epoch.saturating_sub(1);
142 let total_mev = client
143 .calculate_total_mev_rewards(start_epoch, end_epoch)
144 .await
145 .unwrap();
146 println!(
147 " Total MEV from epoch {} to {}: {} lamports",
148 start_epoch, end_epoch, total_mev
149 );
150 println!();
151
152 println!("=== Example completed successfully! ===");
153}Sourcepub async fn get_staker_rewards(
&self,
limit: Option<u32>,
) -> Result<StakerRewardsResponse, KobeApiError>
pub async fn get_staker_rewards( &self, limit: Option<u32>, ) -> Result<StakerRewardsResponse, KobeApiError>
Get staker rewards
Retrieves individual claimable MEV and priority fee rewards from the tip distribution merkle trees.
§Arguments
limit- Optional limit on the number of results (default: API default)
§Example
let client = KobeClient::mainnet();
let rewards = client.get_staker_rewards(Some(10)).await?;Examples found in repository?
4async fn main() {
5 // Create a client with mainnet defaults
6 let client = KobeClient::mainnet();
7
8 println!("=== Jito API Client - Basic Example ===\n");
9
10 // 1. Get current epoch
11 println!("1. Getting current epoch...");
12 let current_epoch = client.get_current_epoch().await.unwrap();
13 println!(" Current epoch: {}\n", current_epoch);
14
15 // 2. Get staker rewards
16 println!("2. Getting staker rewards (limit 5)...");
17 let rewards = client.get_staker_rewards(Some(5)).await.unwrap();
18 println!(" Found {} staker rewards:", rewards.rewards.len());
19 for (i, reward) in rewards.rewards.iter().enumerate() {
20 println!(
21 " {}. Stake Account: {}",
22 i + 1,
23 &reward.stake_account[..8]
24 );
25 println!(" MEV Rewards: {} lamports", reward.mev_rewards);
26 println!(" Epoch: {}", reward.epoch);
27 println!(" Claimed: {}", reward.mev_claimed);
28 }
29 println!();
30
31 // 3. Get validator information
32 println!("3. Getting validators running Jito...");
33 let jito_validators = client.get_jito_validators().await.unwrap();
34 println!(" Found {} validators running Jito", jito_validators.len());
35
36 // Show top 5 by stake
37 let top_5_by_stake = jito_validators.iter().take(5);
38 for (i, validator) in top_5_by_stake.enumerate() {
39 println!(
40 " {}. Vote Account: {}",
41 i + 1,
42 &validator.vote_account[..8]
43 );
44 println!(" Active Stake: {} lamports", validator.active_stake);
45 println!(" MEV Commission: {} bps", validator.mev_commission_bps);
46 }
47 println!();
48
49 // 4. Get network MEV statistics
50 println!("4. Getting MEV network statistics...");
51 let mev_stats = client.get_mev_rewards(None).await.unwrap();
52 println!(" Epoch: {}", mev_stats.epoch);
53 println!(
54 " Total Network MEV: {} lamports",
55 mev_stats.total_network_mev_lamports
56 );
57 println!(
58 " Jito Stake Weight: {} lamports",
59 mev_stats.jito_stake_weight_lamports
60 );
61 println!(
62 " MEV per lamport: {:.10}",
63 mev_stats.mev_reward_per_lamport
64 );
65 println!();
66
67 // 5. Get validator rewards
68 println!("5. Getting validator rewards...");
69 let validator_rewards = client.get_validator_rewards(None, Some(3)).await.unwrap();
70 println!(" Top 3 validators by rewards:");
71 for (i, validator) in validator_rewards.validators.iter().enumerate() {
72 println!(
73 " {}. Vote Account: {}",
74 i + 1,
75 &validator.vote_account[..8]
76 );
77 println!(" MEV Rewards: {} lamports", validator.mev_rewards);
78 if let Some(pf_rewards) = validator.priority_fee_rewards {
79 println!(" Priority Fee Rewards: {} lamports", pf_rewards);
80 }
81 }
82 println!();
83
84 // 6. Get historical validator data
85 println!("6. Getting historical data for a validator...");
86 if let Some(first_validator) = jito_validators.first() {
87 let history = client
88 .get_validator_history(&first_validator.vote_account)
89 .await
90 .unwrap();
91 println!(" Validator: {}", &first_validator.vote_account[..8]);
92 println!(" Historical data (last 3 epochs):");
93 for (i, entry) in history.iter().take(3).enumerate() {
94 println!(
95 " {}. Epoch {}: {} lamports",
96 i + 1,
97 entry.epoch,
98 entry.mev_rewards
99 );
100 }
101 }
102 println!();
103
104 // 7. Get MEV commission averages
105 println!("7. Getting MEV commission averages...");
106 let commission_avg = client.get_mev_commission_average_over_time().await.unwrap();
107 println!(
108 " Aggregated MEV Rewards: {} lamports",
109 commission_avg.aggregated_mev_rewards
110 );
111 if let Some(latest_apy) = commission_avg.apy.first() {
112 println!(" Latest APY: {:.2}%", latest_apy.data * 100.0);
113 }
114 if let Some(latest_tvl) = commission_avg.tvl.first() {
115 println!(" Latest TVL: {} lamports", latest_tvl.data);
116 }
117 println!();
118
119 // 8. Check specific validator
120 println!("8. Checking specific validator status...");
121 let test_vote_account = "GdRKUZKdiXMEATjddQW6q4W8bPgXRBYJKayfeqdQcEPa";
122 let is_running_jito = client
123 .is_validator_running_jito(test_vote_account)
124 .await
125 .unwrap();
126 println!(" Vote Account: {}", &test_vote_account[..8]);
127 println!(" Running Jito: {}", is_running_jito);
128
129 if let Some(commission) = client
130 .get_validator_mev_commission(test_vote_account)
131 .await
132 .unwrap()
133 {
134 println!(" MEV Commission: {} bps", commission);
135 }
136 println!();
137
138 // 9. Calculate total MEV for epoch range
139 println!("9. Calculating total MEV rewards...");
140 let start_epoch = current_epoch.saturating_sub(5);
141 let end_epoch = current_epoch.saturating_sub(1);
142 let total_mev = client
143 .calculate_total_mev_rewards(start_epoch, end_epoch)
144 .await
145 .unwrap();
146 println!(
147 " Total MEV from epoch {} to {}: {} lamports",
148 start_epoch, end_epoch, total_mev
149 );
150 println!();
151
152 println!("=== Example completed successfully! ===");
153}Sourcepub async fn get_staker_rewards_with_params(
&self,
params: &QueryParams,
) -> Result<StakerRewardsResponse, KobeApiError>
pub async fn get_staker_rewards_with_params( &self, params: &QueryParams, ) -> Result<StakerRewardsResponse, KobeApiError>
Get staker rewards with full query parameters
Sourcepub async fn get_validator_rewards(
&self,
epoch: Option<u64>,
limit: Option<u32>,
) -> Result<ValidatorRewardsResponse, KobeApiError>
pub async fn get_validator_rewards( &self, epoch: Option<u64>, limit: Option<u32>, ) -> Result<ValidatorRewardsResponse, KobeApiError>
Get validator rewards for a specific epoch
Retrieves aggregated MEV and priority fee rewards data per validator.
§Arguments
epoch- Epoch number (optional, defaults to latest)limit- Optional limit on the number of results
Examples found in repository?
4async fn main() {
5 // Create a client with mainnet defaults
6 let client = KobeClient::mainnet();
7
8 println!("=== Jito API Client - Basic Example ===\n");
9
10 // 1. Get current epoch
11 println!("1. Getting current epoch...");
12 let current_epoch = client.get_current_epoch().await.unwrap();
13 println!(" Current epoch: {}\n", current_epoch);
14
15 // 2. Get staker rewards
16 println!("2. Getting staker rewards (limit 5)...");
17 let rewards = client.get_staker_rewards(Some(5)).await.unwrap();
18 println!(" Found {} staker rewards:", rewards.rewards.len());
19 for (i, reward) in rewards.rewards.iter().enumerate() {
20 println!(
21 " {}. Stake Account: {}",
22 i + 1,
23 &reward.stake_account[..8]
24 );
25 println!(" MEV Rewards: {} lamports", reward.mev_rewards);
26 println!(" Epoch: {}", reward.epoch);
27 println!(" Claimed: {}", reward.mev_claimed);
28 }
29 println!();
30
31 // 3. Get validator information
32 println!("3. Getting validators running Jito...");
33 let jito_validators = client.get_jito_validators().await.unwrap();
34 println!(" Found {} validators running Jito", jito_validators.len());
35
36 // Show top 5 by stake
37 let top_5_by_stake = jito_validators.iter().take(5);
38 for (i, validator) in top_5_by_stake.enumerate() {
39 println!(
40 " {}. Vote Account: {}",
41 i + 1,
42 &validator.vote_account[..8]
43 );
44 println!(" Active Stake: {} lamports", validator.active_stake);
45 println!(" MEV Commission: {} bps", validator.mev_commission_bps);
46 }
47 println!();
48
49 // 4. Get network MEV statistics
50 println!("4. Getting MEV network statistics...");
51 let mev_stats = client.get_mev_rewards(None).await.unwrap();
52 println!(" Epoch: {}", mev_stats.epoch);
53 println!(
54 " Total Network MEV: {} lamports",
55 mev_stats.total_network_mev_lamports
56 );
57 println!(
58 " Jito Stake Weight: {} lamports",
59 mev_stats.jito_stake_weight_lamports
60 );
61 println!(
62 " MEV per lamport: {:.10}",
63 mev_stats.mev_reward_per_lamport
64 );
65 println!();
66
67 // 5. Get validator rewards
68 println!("5. Getting validator rewards...");
69 let validator_rewards = client.get_validator_rewards(None, Some(3)).await.unwrap();
70 println!(" Top 3 validators by rewards:");
71 for (i, validator) in validator_rewards.validators.iter().enumerate() {
72 println!(
73 " {}. Vote Account: {}",
74 i + 1,
75 &validator.vote_account[..8]
76 );
77 println!(" MEV Rewards: {} lamports", validator.mev_rewards);
78 if let Some(pf_rewards) = validator.priority_fee_rewards {
79 println!(" Priority Fee Rewards: {} lamports", pf_rewards);
80 }
81 }
82 println!();
83
84 // 6. Get historical validator data
85 println!("6. Getting historical data for a validator...");
86 if let Some(first_validator) = jito_validators.first() {
87 let history = client
88 .get_validator_history(&first_validator.vote_account)
89 .await
90 .unwrap();
91 println!(" Validator: {}", &first_validator.vote_account[..8]);
92 println!(" Historical data (last 3 epochs):");
93 for (i, entry) in history.iter().take(3).enumerate() {
94 println!(
95 " {}. Epoch {}: {} lamports",
96 i + 1,
97 entry.epoch,
98 entry.mev_rewards
99 );
100 }
101 }
102 println!();
103
104 // 7. Get MEV commission averages
105 println!("7. Getting MEV commission averages...");
106 let commission_avg = client.get_mev_commission_average_over_time().await.unwrap();
107 println!(
108 " Aggregated MEV Rewards: {} lamports",
109 commission_avg.aggregated_mev_rewards
110 );
111 if let Some(latest_apy) = commission_avg.apy.first() {
112 println!(" Latest APY: {:.2}%", latest_apy.data * 100.0);
113 }
114 if let Some(latest_tvl) = commission_avg.tvl.first() {
115 println!(" Latest TVL: {} lamports", latest_tvl.data);
116 }
117 println!();
118
119 // 8. Check specific validator
120 println!("8. Checking specific validator status...");
121 let test_vote_account = "GdRKUZKdiXMEATjddQW6q4W8bPgXRBYJKayfeqdQcEPa";
122 let is_running_jito = client
123 .is_validator_running_jito(test_vote_account)
124 .await
125 .unwrap();
126 println!(" Vote Account: {}", &test_vote_account[..8]);
127 println!(" Running Jito: {}", is_running_jito);
128
129 if let Some(commission) = client
130 .get_validator_mev_commission(test_vote_account)
131 .await
132 .unwrap()
133 {
134 println!(" MEV Commission: {} bps", commission);
135 }
136 println!();
137
138 // 9. Calculate total MEV for epoch range
139 println!("9. Calculating total MEV rewards...");
140 let start_epoch = current_epoch.saturating_sub(5);
141 let end_epoch = current_epoch.saturating_sub(1);
142 let total_mev = client
143 .calculate_total_mev_rewards(start_epoch, end_epoch)
144 .await
145 .unwrap();
146 println!(
147 " Total MEV from epoch {} to {}: {} lamports",
148 start_epoch, end_epoch, total_mev
149 );
150 println!();
151
152 println!("=== Example completed successfully! ===");
153}Sourcepub async fn get_validators(
&self,
epoch: Option<u64>,
) -> Result<ValidatorsResponse, KobeApiError>
pub async fn get_validators( &self, epoch: Option<u64>, ) -> Result<ValidatorsResponse, KobeApiError>
Get all validators for a given epoch
Returns validator state for a given epoch (defaults to latest).
§Arguments
epoch- Optional epoch number (defaults to latest)
Sourcepub async fn get_jitosol_validators(
&self,
epoch: Option<u64>,
) -> Result<ValidatorsResponse, KobeApiError>
pub async fn get_jitosol_validators( &self, epoch: Option<u64>, ) -> Result<ValidatorsResponse, KobeApiError>
Get JitoSOL stake pool validators for a given epoch
Returns only validators that are actively part of the JitoSOL validator set.
Sourcepub async fn get_validator_history(
&self,
vote_account: &str,
) -> Result<Vec<ValidatorHistory>, KobeApiError>
pub async fn get_validator_history( &self, vote_account: &str, ) -> Result<Vec<ValidatorHistory>, KobeApiError>
Get historical data for a single validator
Returns historical reward data for a validator, sorted by epoch (descending).
§Arguments
vote_account- The validator’s vote account public key
Examples found in repository?
4async fn main() {
5 // Create a client with mainnet defaults
6 let client = KobeClient::mainnet();
7
8 println!("=== Jito API Client - Basic Example ===\n");
9
10 // 1. Get current epoch
11 println!("1. Getting current epoch...");
12 let current_epoch = client.get_current_epoch().await.unwrap();
13 println!(" Current epoch: {}\n", current_epoch);
14
15 // 2. Get staker rewards
16 println!("2. Getting staker rewards (limit 5)...");
17 let rewards = client.get_staker_rewards(Some(5)).await.unwrap();
18 println!(" Found {} staker rewards:", rewards.rewards.len());
19 for (i, reward) in rewards.rewards.iter().enumerate() {
20 println!(
21 " {}. Stake Account: {}",
22 i + 1,
23 &reward.stake_account[..8]
24 );
25 println!(" MEV Rewards: {} lamports", reward.mev_rewards);
26 println!(" Epoch: {}", reward.epoch);
27 println!(" Claimed: {}", reward.mev_claimed);
28 }
29 println!();
30
31 // 3. Get validator information
32 println!("3. Getting validators running Jito...");
33 let jito_validators = client.get_jito_validators().await.unwrap();
34 println!(" Found {} validators running Jito", jito_validators.len());
35
36 // Show top 5 by stake
37 let top_5_by_stake = jito_validators.iter().take(5);
38 for (i, validator) in top_5_by_stake.enumerate() {
39 println!(
40 " {}. Vote Account: {}",
41 i + 1,
42 &validator.vote_account[..8]
43 );
44 println!(" Active Stake: {} lamports", validator.active_stake);
45 println!(" MEV Commission: {} bps", validator.mev_commission_bps);
46 }
47 println!();
48
49 // 4. Get network MEV statistics
50 println!("4. Getting MEV network statistics...");
51 let mev_stats = client.get_mev_rewards(None).await.unwrap();
52 println!(" Epoch: {}", mev_stats.epoch);
53 println!(
54 " Total Network MEV: {} lamports",
55 mev_stats.total_network_mev_lamports
56 );
57 println!(
58 " Jito Stake Weight: {} lamports",
59 mev_stats.jito_stake_weight_lamports
60 );
61 println!(
62 " MEV per lamport: {:.10}",
63 mev_stats.mev_reward_per_lamport
64 );
65 println!();
66
67 // 5. Get validator rewards
68 println!("5. Getting validator rewards...");
69 let validator_rewards = client.get_validator_rewards(None, Some(3)).await.unwrap();
70 println!(" Top 3 validators by rewards:");
71 for (i, validator) in validator_rewards.validators.iter().enumerate() {
72 println!(
73 " {}. Vote Account: {}",
74 i + 1,
75 &validator.vote_account[..8]
76 );
77 println!(" MEV Rewards: {} lamports", validator.mev_rewards);
78 if let Some(pf_rewards) = validator.priority_fee_rewards {
79 println!(" Priority Fee Rewards: {} lamports", pf_rewards);
80 }
81 }
82 println!();
83
84 // 6. Get historical validator data
85 println!("6. Getting historical data for a validator...");
86 if let Some(first_validator) = jito_validators.first() {
87 let history = client
88 .get_validator_history(&first_validator.vote_account)
89 .await
90 .unwrap();
91 println!(" Validator: {}", &first_validator.vote_account[..8]);
92 println!(" Historical data (last 3 epochs):");
93 for (i, entry) in history.iter().take(3).enumerate() {
94 println!(
95 " {}. Epoch {}: {} lamports",
96 i + 1,
97 entry.epoch,
98 entry.mev_rewards
99 );
100 }
101 }
102 println!();
103
104 // 7. Get MEV commission averages
105 println!("7. Getting MEV commission averages...");
106 let commission_avg = client.get_mev_commission_average_over_time().await.unwrap();
107 println!(
108 " Aggregated MEV Rewards: {} lamports",
109 commission_avg.aggregated_mev_rewards
110 );
111 if let Some(latest_apy) = commission_avg.apy.first() {
112 println!(" Latest APY: {:.2}%", latest_apy.data * 100.0);
113 }
114 if let Some(latest_tvl) = commission_avg.tvl.first() {
115 println!(" Latest TVL: {} lamports", latest_tvl.data);
116 }
117 println!();
118
119 // 8. Check specific validator
120 println!("8. Checking specific validator status...");
121 let test_vote_account = "GdRKUZKdiXMEATjddQW6q4W8bPgXRBYJKayfeqdQcEPa";
122 let is_running_jito = client
123 .is_validator_running_jito(test_vote_account)
124 .await
125 .unwrap();
126 println!(" Vote Account: {}", &test_vote_account[..8]);
127 println!(" Running Jito: {}", is_running_jito);
128
129 if let Some(commission) = client
130 .get_validator_mev_commission(test_vote_account)
131 .await
132 .unwrap()
133 {
134 println!(" MEV Commission: {} bps", commission);
135 }
136 println!();
137
138 // 9. Calculate total MEV for epoch range
139 println!("9. Calculating total MEV rewards...");
140 let start_epoch = current_epoch.saturating_sub(5);
141 let end_epoch = current_epoch.saturating_sub(1);
142 let total_mev = client
143 .calculate_total_mev_rewards(start_epoch, end_epoch)
144 .await
145 .unwrap();
146 println!(
147 " Total MEV from epoch {} to {}: {} lamports",
148 start_epoch, end_epoch, total_mev
149 );
150 println!();
151
152 println!("=== Example completed successfully! ===");
153}Sourcepub async fn get_mev_rewards(
&self,
epoch: Option<u64>,
) -> Result<MevRewards, KobeApiError>
pub async fn get_mev_rewards( &self, epoch: Option<u64>, ) -> Result<MevRewards, KobeApiError>
Get MEV rewards network statistics for an epoch
Returns network-level statistics including total MEV, stake weight, and reward per lamport.
§Arguments
epoch- Optional epoch number (defaults to latest)
Examples found in repository?
4async fn main() {
5 // Create a client with mainnet defaults
6 let client = KobeClient::mainnet();
7
8 println!("=== Jito API Client - Basic Example ===\n");
9
10 // 1. Get current epoch
11 println!("1. Getting current epoch...");
12 let current_epoch = client.get_current_epoch().await.unwrap();
13 println!(" Current epoch: {}\n", current_epoch);
14
15 // 2. Get staker rewards
16 println!("2. Getting staker rewards (limit 5)...");
17 let rewards = client.get_staker_rewards(Some(5)).await.unwrap();
18 println!(" Found {} staker rewards:", rewards.rewards.len());
19 for (i, reward) in rewards.rewards.iter().enumerate() {
20 println!(
21 " {}. Stake Account: {}",
22 i + 1,
23 &reward.stake_account[..8]
24 );
25 println!(" MEV Rewards: {} lamports", reward.mev_rewards);
26 println!(" Epoch: {}", reward.epoch);
27 println!(" Claimed: {}", reward.mev_claimed);
28 }
29 println!();
30
31 // 3. Get validator information
32 println!("3. Getting validators running Jito...");
33 let jito_validators = client.get_jito_validators().await.unwrap();
34 println!(" Found {} validators running Jito", jito_validators.len());
35
36 // Show top 5 by stake
37 let top_5_by_stake = jito_validators.iter().take(5);
38 for (i, validator) in top_5_by_stake.enumerate() {
39 println!(
40 " {}. Vote Account: {}",
41 i + 1,
42 &validator.vote_account[..8]
43 );
44 println!(" Active Stake: {} lamports", validator.active_stake);
45 println!(" MEV Commission: {} bps", validator.mev_commission_bps);
46 }
47 println!();
48
49 // 4. Get network MEV statistics
50 println!("4. Getting MEV network statistics...");
51 let mev_stats = client.get_mev_rewards(None).await.unwrap();
52 println!(" Epoch: {}", mev_stats.epoch);
53 println!(
54 " Total Network MEV: {} lamports",
55 mev_stats.total_network_mev_lamports
56 );
57 println!(
58 " Jito Stake Weight: {} lamports",
59 mev_stats.jito_stake_weight_lamports
60 );
61 println!(
62 " MEV per lamport: {:.10}",
63 mev_stats.mev_reward_per_lamport
64 );
65 println!();
66
67 // 5. Get validator rewards
68 println!("5. Getting validator rewards...");
69 let validator_rewards = client.get_validator_rewards(None, Some(3)).await.unwrap();
70 println!(" Top 3 validators by rewards:");
71 for (i, validator) in validator_rewards.validators.iter().enumerate() {
72 println!(
73 " {}. Vote Account: {}",
74 i + 1,
75 &validator.vote_account[..8]
76 );
77 println!(" MEV Rewards: {} lamports", validator.mev_rewards);
78 if let Some(pf_rewards) = validator.priority_fee_rewards {
79 println!(" Priority Fee Rewards: {} lamports", pf_rewards);
80 }
81 }
82 println!();
83
84 // 6. Get historical validator data
85 println!("6. Getting historical data for a validator...");
86 if let Some(first_validator) = jito_validators.first() {
87 let history = client
88 .get_validator_history(&first_validator.vote_account)
89 .await
90 .unwrap();
91 println!(" Validator: {}", &first_validator.vote_account[..8]);
92 println!(" Historical data (last 3 epochs):");
93 for (i, entry) in history.iter().take(3).enumerate() {
94 println!(
95 " {}. Epoch {}: {} lamports",
96 i + 1,
97 entry.epoch,
98 entry.mev_rewards
99 );
100 }
101 }
102 println!();
103
104 // 7. Get MEV commission averages
105 println!("7. Getting MEV commission averages...");
106 let commission_avg = client.get_mev_commission_average_over_time().await.unwrap();
107 println!(
108 " Aggregated MEV Rewards: {} lamports",
109 commission_avg.aggregated_mev_rewards
110 );
111 if let Some(latest_apy) = commission_avg.apy.first() {
112 println!(" Latest APY: {:.2}%", latest_apy.data * 100.0);
113 }
114 if let Some(latest_tvl) = commission_avg.tvl.first() {
115 println!(" Latest TVL: {} lamports", latest_tvl.data);
116 }
117 println!();
118
119 // 8. Check specific validator
120 println!("8. Checking specific validator status...");
121 let test_vote_account = "GdRKUZKdiXMEATjddQW6q4W8bPgXRBYJKayfeqdQcEPa";
122 let is_running_jito = client
123 .is_validator_running_jito(test_vote_account)
124 .await
125 .unwrap();
126 println!(" Vote Account: {}", &test_vote_account[..8]);
127 println!(" Running Jito: {}", is_running_jito);
128
129 if let Some(commission) = client
130 .get_validator_mev_commission(test_vote_account)
131 .await
132 .unwrap()
133 {
134 println!(" MEV Commission: {} bps", commission);
135 }
136 println!();
137
138 // 9. Calculate total MEV for epoch range
139 println!("9. Calculating total MEV rewards...");
140 let start_epoch = current_epoch.saturating_sub(5);
141 let end_epoch = current_epoch.saturating_sub(1);
142 let total_mev = client
143 .calculate_total_mev_rewards(start_epoch, end_epoch)
144 .await
145 .unwrap();
146 println!(
147 " Total MEV from epoch {} to {}: {} lamports",
148 start_epoch, end_epoch, total_mev
149 );
150 println!();
151
152 println!("=== Example completed successfully! ===");
153}Sourcepub async fn get_daily_mev_tips(
&self,
) -> Result<Vec<DailyMevTips>, KobeApiError>
pub async fn get_daily_mev_tips( &self, ) -> Result<Vec<DailyMevTips>, KobeApiError>
Get daily MEV tips
Returns aggregated MEV tips per calendar day.
Sourcepub async fn get_jito_stake_over_time(
&self,
) -> Result<JitoStakeOverTime, KobeApiError>
pub async fn get_jito_stake_over_time( &self, ) -> Result<JitoStakeOverTime, KobeApiError>
Get Jito stake over time
Returns a map of epoch to percentage of all Solana stake delegated to Jito-running validators.
Sourcepub async fn get_mev_commission_average_over_time(
&self,
) -> Result<MevCommissionAverageOverTime, KobeApiError>
pub async fn get_mev_commission_average_over_time( &self, ) -> Result<MevCommissionAverageOverTime, KobeApiError>
Get MEV commission average over time
Returns stake-weighted average MEV commission along with other metrics.
Examples found in repository?
4async fn main() {
5 // Create a client with mainnet defaults
6 let client = KobeClient::mainnet();
7
8 println!("=== Jito API Client - Basic Example ===\n");
9
10 // 1. Get current epoch
11 println!("1. Getting current epoch...");
12 let current_epoch = client.get_current_epoch().await.unwrap();
13 println!(" Current epoch: {}\n", current_epoch);
14
15 // 2. Get staker rewards
16 println!("2. Getting staker rewards (limit 5)...");
17 let rewards = client.get_staker_rewards(Some(5)).await.unwrap();
18 println!(" Found {} staker rewards:", rewards.rewards.len());
19 for (i, reward) in rewards.rewards.iter().enumerate() {
20 println!(
21 " {}. Stake Account: {}",
22 i + 1,
23 &reward.stake_account[..8]
24 );
25 println!(" MEV Rewards: {} lamports", reward.mev_rewards);
26 println!(" Epoch: {}", reward.epoch);
27 println!(" Claimed: {}", reward.mev_claimed);
28 }
29 println!();
30
31 // 3. Get validator information
32 println!("3. Getting validators running Jito...");
33 let jito_validators = client.get_jito_validators().await.unwrap();
34 println!(" Found {} validators running Jito", jito_validators.len());
35
36 // Show top 5 by stake
37 let top_5_by_stake = jito_validators.iter().take(5);
38 for (i, validator) in top_5_by_stake.enumerate() {
39 println!(
40 " {}. Vote Account: {}",
41 i + 1,
42 &validator.vote_account[..8]
43 );
44 println!(" Active Stake: {} lamports", validator.active_stake);
45 println!(" MEV Commission: {} bps", validator.mev_commission_bps);
46 }
47 println!();
48
49 // 4. Get network MEV statistics
50 println!("4. Getting MEV network statistics...");
51 let mev_stats = client.get_mev_rewards(None).await.unwrap();
52 println!(" Epoch: {}", mev_stats.epoch);
53 println!(
54 " Total Network MEV: {} lamports",
55 mev_stats.total_network_mev_lamports
56 );
57 println!(
58 " Jito Stake Weight: {} lamports",
59 mev_stats.jito_stake_weight_lamports
60 );
61 println!(
62 " MEV per lamport: {:.10}",
63 mev_stats.mev_reward_per_lamport
64 );
65 println!();
66
67 // 5. Get validator rewards
68 println!("5. Getting validator rewards...");
69 let validator_rewards = client.get_validator_rewards(None, Some(3)).await.unwrap();
70 println!(" Top 3 validators by rewards:");
71 for (i, validator) in validator_rewards.validators.iter().enumerate() {
72 println!(
73 " {}. Vote Account: {}",
74 i + 1,
75 &validator.vote_account[..8]
76 );
77 println!(" MEV Rewards: {} lamports", validator.mev_rewards);
78 if let Some(pf_rewards) = validator.priority_fee_rewards {
79 println!(" Priority Fee Rewards: {} lamports", pf_rewards);
80 }
81 }
82 println!();
83
84 // 6. Get historical validator data
85 println!("6. Getting historical data for a validator...");
86 if let Some(first_validator) = jito_validators.first() {
87 let history = client
88 .get_validator_history(&first_validator.vote_account)
89 .await
90 .unwrap();
91 println!(" Validator: {}", &first_validator.vote_account[..8]);
92 println!(" Historical data (last 3 epochs):");
93 for (i, entry) in history.iter().take(3).enumerate() {
94 println!(
95 " {}. Epoch {}: {} lamports",
96 i + 1,
97 entry.epoch,
98 entry.mev_rewards
99 );
100 }
101 }
102 println!();
103
104 // 7. Get MEV commission averages
105 println!("7. Getting MEV commission averages...");
106 let commission_avg = client.get_mev_commission_average_over_time().await.unwrap();
107 println!(
108 " Aggregated MEV Rewards: {} lamports",
109 commission_avg.aggregated_mev_rewards
110 );
111 if let Some(latest_apy) = commission_avg.apy.first() {
112 println!(" Latest APY: {:.2}%", latest_apy.data * 100.0);
113 }
114 if let Some(latest_tvl) = commission_avg.tvl.first() {
115 println!(" Latest TVL: {} lamports", latest_tvl.data);
116 }
117 println!();
118
119 // 8. Check specific validator
120 println!("8. Checking specific validator status...");
121 let test_vote_account = "GdRKUZKdiXMEATjddQW6q4W8bPgXRBYJKayfeqdQcEPa";
122 let is_running_jito = client
123 .is_validator_running_jito(test_vote_account)
124 .await
125 .unwrap();
126 println!(" Vote Account: {}", &test_vote_account[..8]);
127 println!(" Running Jito: {}", is_running_jito);
128
129 if let Some(commission) = client
130 .get_validator_mev_commission(test_vote_account)
131 .await
132 .unwrap()
133 {
134 println!(" MEV Commission: {} bps", commission);
135 }
136 println!();
137
138 // 9. Calculate total MEV for epoch range
139 println!("9. Calculating total MEV rewards...");
140 let start_epoch = current_epoch.saturating_sub(5);
141 let end_epoch = current_epoch.saturating_sub(1);
142 let total_mev = client
143 .calculate_total_mev_rewards(start_epoch, end_epoch)
144 .await
145 .unwrap();
146 println!(
147 " Total MEV from epoch {} to {}: {} lamports",
148 start_epoch, end_epoch, total_mev
149 );
150 println!();
151
152 println!("=== Example completed successfully! ===");
153}Sourcepub async fn get_jitosol_sol_ratio(
&self,
start: DateTime<Utc>,
end: DateTime<Utc>,
) -> Result<JitoSolRatio, KobeApiError>
pub async fn get_jitosol_sol_ratio( &self, start: DateTime<Utc>, end: DateTime<Utc>, ) -> Result<JitoSolRatio, KobeApiError>
Get JitoSOL to SOL exchange ratio over time
§Arguments
start- Start datetime for the rangeend- End datetime for the range
Sourcepub async fn get_stake_pool_stats(
&self,
epoch: Option<u64>,
) -> Result<StakePoolStats, KobeApiError>
pub async fn get_stake_pool_stats( &self, epoch: Option<u64>, ) -> Result<StakePoolStats, KobeApiError>
Get stake pool statistics for an epoch
§Arguments
epoch- Optional epoch number (defaults to latest)
Sourcepub async fn get_current_epoch(&self) -> Result<u64, KobeApiError>
pub async fn get_current_epoch(&self) -> Result<u64, KobeApiError>
Get the current epoch from the latest MEV rewards data
Examples found in repository?
4async fn main() {
5 // Create a client with mainnet defaults
6 let client = KobeClient::mainnet();
7
8 println!("=== Jito API Client - Basic Example ===\n");
9
10 // 1. Get current epoch
11 println!("1. Getting current epoch...");
12 let current_epoch = client.get_current_epoch().await.unwrap();
13 println!(" Current epoch: {}\n", current_epoch);
14
15 // 2. Get staker rewards
16 println!("2. Getting staker rewards (limit 5)...");
17 let rewards = client.get_staker_rewards(Some(5)).await.unwrap();
18 println!(" Found {} staker rewards:", rewards.rewards.len());
19 for (i, reward) in rewards.rewards.iter().enumerate() {
20 println!(
21 " {}. Stake Account: {}",
22 i + 1,
23 &reward.stake_account[..8]
24 );
25 println!(" MEV Rewards: {} lamports", reward.mev_rewards);
26 println!(" Epoch: {}", reward.epoch);
27 println!(" Claimed: {}", reward.mev_claimed);
28 }
29 println!();
30
31 // 3. Get validator information
32 println!("3. Getting validators running Jito...");
33 let jito_validators = client.get_jito_validators().await.unwrap();
34 println!(" Found {} validators running Jito", jito_validators.len());
35
36 // Show top 5 by stake
37 let top_5_by_stake = jito_validators.iter().take(5);
38 for (i, validator) in top_5_by_stake.enumerate() {
39 println!(
40 " {}. Vote Account: {}",
41 i + 1,
42 &validator.vote_account[..8]
43 );
44 println!(" Active Stake: {} lamports", validator.active_stake);
45 println!(" MEV Commission: {} bps", validator.mev_commission_bps);
46 }
47 println!();
48
49 // 4. Get network MEV statistics
50 println!("4. Getting MEV network statistics...");
51 let mev_stats = client.get_mev_rewards(None).await.unwrap();
52 println!(" Epoch: {}", mev_stats.epoch);
53 println!(
54 " Total Network MEV: {} lamports",
55 mev_stats.total_network_mev_lamports
56 );
57 println!(
58 " Jito Stake Weight: {} lamports",
59 mev_stats.jito_stake_weight_lamports
60 );
61 println!(
62 " MEV per lamport: {:.10}",
63 mev_stats.mev_reward_per_lamport
64 );
65 println!();
66
67 // 5. Get validator rewards
68 println!("5. Getting validator rewards...");
69 let validator_rewards = client.get_validator_rewards(None, Some(3)).await.unwrap();
70 println!(" Top 3 validators by rewards:");
71 for (i, validator) in validator_rewards.validators.iter().enumerate() {
72 println!(
73 " {}. Vote Account: {}",
74 i + 1,
75 &validator.vote_account[..8]
76 );
77 println!(" MEV Rewards: {} lamports", validator.mev_rewards);
78 if let Some(pf_rewards) = validator.priority_fee_rewards {
79 println!(" Priority Fee Rewards: {} lamports", pf_rewards);
80 }
81 }
82 println!();
83
84 // 6. Get historical validator data
85 println!("6. Getting historical data for a validator...");
86 if let Some(first_validator) = jito_validators.first() {
87 let history = client
88 .get_validator_history(&first_validator.vote_account)
89 .await
90 .unwrap();
91 println!(" Validator: {}", &first_validator.vote_account[..8]);
92 println!(" Historical data (last 3 epochs):");
93 for (i, entry) in history.iter().take(3).enumerate() {
94 println!(
95 " {}. Epoch {}: {} lamports",
96 i + 1,
97 entry.epoch,
98 entry.mev_rewards
99 );
100 }
101 }
102 println!();
103
104 // 7. Get MEV commission averages
105 println!("7. Getting MEV commission averages...");
106 let commission_avg = client.get_mev_commission_average_over_time().await.unwrap();
107 println!(
108 " Aggregated MEV Rewards: {} lamports",
109 commission_avg.aggregated_mev_rewards
110 );
111 if let Some(latest_apy) = commission_avg.apy.first() {
112 println!(" Latest APY: {:.2}%", latest_apy.data * 100.0);
113 }
114 if let Some(latest_tvl) = commission_avg.tvl.first() {
115 println!(" Latest TVL: {} lamports", latest_tvl.data);
116 }
117 println!();
118
119 // 8. Check specific validator
120 println!("8. Checking specific validator status...");
121 let test_vote_account = "GdRKUZKdiXMEATjddQW6q4W8bPgXRBYJKayfeqdQcEPa";
122 let is_running_jito = client
123 .is_validator_running_jito(test_vote_account)
124 .await
125 .unwrap();
126 println!(" Vote Account: {}", &test_vote_account[..8]);
127 println!(" Running Jito: {}", is_running_jito);
128
129 if let Some(commission) = client
130 .get_validator_mev_commission(test_vote_account)
131 .await
132 .unwrap()
133 {
134 println!(" MEV Commission: {} bps", commission);
135 }
136 println!();
137
138 // 9. Calculate total MEV for epoch range
139 println!("9. Calculating total MEV rewards...");
140 let start_epoch = current_epoch.saturating_sub(5);
141 let end_epoch = current_epoch.saturating_sub(1);
142 let total_mev = client
143 .calculate_total_mev_rewards(start_epoch, end_epoch)
144 .await
145 .unwrap();
146 println!(
147 " Total MEV from epoch {} to {}: {} lamports",
148 start_epoch, end_epoch, total_mev
149 );
150 println!();
151
152 println!("=== Example completed successfully! ===");
153}Sourcepub async fn get_jito_validators(
&self,
) -> Result<Vec<ValidatorInfo>, KobeApiError>
pub async fn get_jito_validators( &self, ) -> Result<Vec<ValidatorInfo>, KobeApiError>
Get all validators currently running Jito
Examples found in repository?
4async fn main() {
5 // Create a client with mainnet defaults
6 let client = KobeClient::mainnet();
7
8 println!("=== Jito API Client - Basic Example ===\n");
9
10 // 1. Get current epoch
11 println!("1. Getting current epoch...");
12 let current_epoch = client.get_current_epoch().await.unwrap();
13 println!(" Current epoch: {}\n", current_epoch);
14
15 // 2. Get staker rewards
16 println!("2. Getting staker rewards (limit 5)...");
17 let rewards = client.get_staker_rewards(Some(5)).await.unwrap();
18 println!(" Found {} staker rewards:", rewards.rewards.len());
19 for (i, reward) in rewards.rewards.iter().enumerate() {
20 println!(
21 " {}. Stake Account: {}",
22 i + 1,
23 &reward.stake_account[..8]
24 );
25 println!(" MEV Rewards: {} lamports", reward.mev_rewards);
26 println!(" Epoch: {}", reward.epoch);
27 println!(" Claimed: {}", reward.mev_claimed);
28 }
29 println!();
30
31 // 3. Get validator information
32 println!("3. Getting validators running Jito...");
33 let jito_validators = client.get_jito_validators().await.unwrap();
34 println!(" Found {} validators running Jito", jito_validators.len());
35
36 // Show top 5 by stake
37 let top_5_by_stake = jito_validators.iter().take(5);
38 for (i, validator) in top_5_by_stake.enumerate() {
39 println!(
40 " {}. Vote Account: {}",
41 i + 1,
42 &validator.vote_account[..8]
43 );
44 println!(" Active Stake: {} lamports", validator.active_stake);
45 println!(" MEV Commission: {} bps", validator.mev_commission_bps);
46 }
47 println!();
48
49 // 4. Get network MEV statistics
50 println!("4. Getting MEV network statistics...");
51 let mev_stats = client.get_mev_rewards(None).await.unwrap();
52 println!(" Epoch: {}", mev_stats.epoch);
53 println!(
54 " Total Network MEV: {} lamports",
55 mev_stats.total_network_mev_lamports
56 );
57 println!(
58 " Jito Stake Weight: {} lamports",
59 mev_stats.jito_stake_weight_lamports
60 );
61 println!(
62 " MEV per lamport: {:.10}",
63 mev_stats.mev_reward_per_lamport
64 );
65 println!();
66
67 // 5. Get validator rewards
68 println!("5. Getting validator rewards...");
69 let validator_rewards = client.get_validator_rewards(None, Some(3)).await.unwrap();
70 println!(" Top 3 validators by rewards:");
71 for (i, validator) in validator_rewards.validators.iter().enumerate() {
72 println!(
73 " {}. Vote Account: {}",
74 i + 1,
75 &validator.vote_account[..8]
76 );
77 println!(" MEV Rewards: {} lamports", validator.mev_rewards);
78 if let Some(pf_rewards) = validator.priority_fee_rewards {
79 println!(" Priority Fee Rewards: {} lamports", pf_rewards);
80 }
81 }
82 println!();
83
84 // 6. Get historical validator data
85 println!("6. Getting historical data for a validator...");
86 if let Some(first_validator) = jito_validators.first() {
87 let history = client
88 .get_validator_history(&first_validator.vote_account)
89 .await
90 .unwrap();
91 println!(" Validator: {}", &first_validator.vote_account[..8]);
92 println!(" Historical data (last 3 epochs):");
93 for (i, entry) in history.iter().take(3).enumerate() {
94 println!(
95 " {}. Epoch {}: {} lamports",
96 i + 1,
97 entry.epoch,
98 entry.mev_rewards
99 );
100 }
101 }
102 println!();
103
104 // 7. Get MEV commission averages
105 println!("7. Getting MEV commission averages...");
106 let commission_avg = client.get_mev_commission_average_over_time().await.unwrap();
107 println!(
108 " Aggregated MEV Rewards: {} lamports",
109 commission_avg.aggregated_mev_rewards
110 );
111 if let Some(latest_apy) = commission_avg.apy.first() {
112 println!(" Latest APY: {:.2}%", latest_apy.data * 100.0);
113 }
114 if let Some(latest_tvl) = commission_avg.tvl.first() {
115 println!(" Latest TVL: {} lamports", latest_tvl.data);
116 }
117 println!();
118
119 // 8. Check specific validator
120 println!("8. Checking specific validator status...");
121 let test_vote_account = "GdRKUZKdiXMEATjddQW6q4W8bPgXRBYJKayfeqdQcEPa";
122 let is_running_jito = client
123 .is_validator_running_jito(test_vote_account)
124 .await
125 .unwrap();
126 println!(" Vote Account: {}", &test_vote_account[..8]);
127 println!(" Running Jito: {}", is_running_jito);
128
129 if let Some(commission) = client
130 .get_validator_mev_commission(test_vote_account)
131 .await
132 .unwrap()
133 {
134 println!(" MEV Commission: {} bps", commission);
135 }
136 println!();
137
138 // 9. Calculate total MEV for epoch range
139 println!("9. Calculating total MEV rewards...");
140 let start_epoch = current_epoch.saturating_sub(5);
141 let end_epoch = current_epoch.saturating_sub(1);
142 let total_mev = client
143 .calculate_total_mev_rewards(start_epoch, end_epoch)
144 .await
145 .unwrap();
146 println!(
147 " Total MEV from epoch {} to {}: {} lamports",
148 start_epoch, end_epoch, total_mev
149 );
150 println!();
151
152 println!("=== Example completed successfully! ===");
153}Sourcepub async fn get_validators_by_mev_rewards(
&self,
epoch: Option<u64>,
limit: usize,
) -> Result<Vec<ValidatorInfo>, KobeApiError>
pub async fn get_validators_by_mev_rewards( &self, epoch: Option<u64>, limit: usize, ) -> Result<Vec<ValidatorInfo>, KobeApiError>
Get validators sorted by MEV rewards
Sourcepub async fn get_validators_by_stake(
&self,
epoch: Option<u64>,
limit: usize,
) -> Result<Vec<ValidatorInfo>, KobeApiError>
pub async fn get_validators_by_stake( &self, epoch: Option<u64>, limit: usize, ) -> Result<Vec<ValidatorInfo>, KobeApiError>
Get validators sorted by active stake
Sourcepub async fn is_validator_running_jito(
&self,
vote_account: &str,
) -> Result<bool, KobeApiError>
pub async fn is_validator_running_jito( &self, vote_account: &str, ) -> Result<bool, KobeApiError>
Check if a validator is running Jito
Examples found in repository?
4async fn main() {
5 // Create a client with mainnet defaults
6 let client = KobeClient::mainnet();
7
8 println!("=== Jito API Client - Basic Example ===\n");
9
10 // 1. Get current epoch
11 println!("1. Getting current epoch...");
12 let current_epoch = client.get_current_epoch().await.unwrap();
13 println!(" Current epoch: {}\n", current_epoch);
14
15 // 2. Get staker rewards
16 println!("2. Getting staker rewards (limit 5)...");
17 let rewards = client.get_staker_rewards(Some(5)).await.unwrap();
18 println!(" Found {} staker rewards:", rewards.rewards.len());
19 for (i, reward) in rewards.rewards.iter().enumerate() {
20 println!(
21 " {}. Stake Account: {}",
22 i + 1,
23 &reward.stake_account[..8]
24 );
25 println!(" MEV Rewards: {} lamports", reward.mev_rewards);
26 println!(" Epoch: {}", reward.epoch);
27 println!(" Claimed: {}", reward.mev_claimed);
28 }
29 println!();
30
31 // 3. Get validator information
32 println!("3. Getting validators running Jito...");
33 let jito_validators = client.get_jito_validators().await.unwrap();
34 println!(" Found {} validators running Jito", jito_validators.len());
35
36 // Show top 5 by stake
37 let top_5_by_stake = jito_validators.iter().take(5);
38 for (i, validator) in top_5_by_stake.enumerate() {
39 println!(
40 " {}. Vote Account: {}",
41 i + 1,
42 &validator.vote_account[..8]
43 );
44 println!(" Active Stake: {} lamports", validator.active_stake);
45 println!(" MEV Commission: {} bps", validator.mev_commission_bps);
46 }
47 println!();
48
49 // 4. Get network MEV statistics
50 println!("4. Getting MEV network statistics...");
51 let mev_stats = client.get_mev_rewards(None).await.unwrap();
52 println!(" Epoch: {}", mev_stats.epoch);
53 println!(
54 " Total Network MEV: {} lamports",
55 mev_stats.total_network_mev_lamports
56 );
57 println!(
58 " Jito Stake Weight: {} lamports",
59 mev_stats.jito_stake_weight_lamports
60 );
61 println!(
62 " MEV per lamport: {:.10}",
63 mev_stats.mev_reward_per_lamport
64 );
65 println!();
66
67 // 5. Get validator rewards
68 println!("5. Getting validator rewards...");
69 let validator_rewards = client.get_validator_rewards(None, Some(3)).await.unwrap();
70 println!(" Top 3 validators by rewards:");
71 for (i, validator) in validator_rewards.validators.iter().enumerate() {
72 println!(
73 " {}. Vote Account: {}",
74 i + 1,
75 &validator.vote_account[..8]
76 );
77 println!(" MEV Rewards: {} lamports", validator.mev_rewards);
78 if let Some(pf_rewards) = validator.priority_fee_rewards {
79 println!(" Priority Fee Rewards: {} lamports", pf_rewards);
80 }
81 }
82 println!();
83
84 // 6. Get historical validator data
85 println!("6. Getting historical data for a validator...");
86 if let Some(first_validator) = jito_validators.first() {
87 let history = client
88 .get_validator_history(&first_validator.vote_account)
89 .await
90 .unwrap();
91 println!(" Validator: {}", &first_validator.vote_account[..8]);
92 println!(" Historical data (last 3 epochs):");
93 for (i, entry) in history.iter().take(3).enumerate() {
94 println!(
95 " {}. Epoch {}: {} lamports",
96 i + 1,
97 entry.epoch,
98 entry.mev_rewards
99 );
100 }
101 }
102 println!();
103
104 // 7. Get MEV commission averages
105 println!("7. Getting MEV commission averages...");
106 let commission_avg = client.get_mev_commission_average_over_time().await.unwrap();
107 println!(
108 " Aggregated MEV Rewards: {} lamports",
109 commission_avg.aggregated_mev_rewards
110 );
111 if let Some(latest_apy) = commission_avg.apy.first() {
112 println!(" Latest APY: {:.2}%", latest_apy.data * 100.0);
113 }
114 if let Some(latest_tvl) = commission_avg.tvl.first() {
115 println!(" Latest TVL: {} lamports", latest_tvl.data);
116 }
117 println!();
118
119 // 8. Check specific validator
120 println!("8. Checking specific validator status...");
121 let test_vote_account = "GdRKUZKdiXMEATjddQW6q4W8bPgXRBYJKayfeqdQcEPa";
122 let is_running_jito = client
123 .is_validator_running_jito(test_vote_account)
124 .await
125 .unwrap();
126 println!(" Vote Account: {}", &test_vote_account[..8]);
127 println!(" Running Jito: {}", is_running_jito);
128
129 if let Some(commission) = client
130 .get_validator_mev_commission(test_vote_account)
131 .await
132 .unwrap()
133 {
134 println!(" MEV Commission: {} bps", commission);
135 }
136 println!();
137
138 // 9. Calculate total MEV for epoch range
139 println!("9. Calculating total MEV rewards...");
140 let start_epoch = current_epoch.saturating_sub(5);
141 let end_epoch = current_epoch.saturating_sub(1);
142 let total_mev = client
143 .calculate_total_mev_rewards(start_epoch, end_epoch)
144 .await
145 .unwrap();
146 println!(
147 " Total MEV from epoch {} to {}: {} lamports",
148 start_epoch, end_epoch, total_mev
149 );
150 println!();
151
152 println!("=== Example completed successfully! ===");
153}Sourcepub async fn get_validator_mev_commission(
&self,
vote_account: &str,
) -> Result<Option<u16>, KobeApiError>
pub async fn get_validator_mev_commission( &self, vote_account: &str, ) -> Result<Option<u16>, KobeApiError>
Get validator MEV commission
Examples found in repository?
4async fn main() {
5 // Create a client with mainnet defaults
6 let client = KobeClient::mainnet();
7
8 println!("=== Jito API Client - Basic Example ===\n");
9
10 // 1. Get current epoch
11 println!("1. Getting current epoch...");
12 let current_epoch = client.get_current_epoch().await.unwrap();
13 println!(" Current epoch: {}\n", current_epoch);
14
15 // 2. Get staker rewards
16 println!("2. Getting staker rewards (limit 5)...");
17 let rewards = client.get_staker_rewards(Some(5)).await.unwrap();
18 println!(" Found {} staker rewards:", rewards.rewards.len());
19 for (i, reward) in rewards.rewards.iter().enumerate() {
20 println!(
21 " {}. Stake Account: {}",
22 i + 1,
23 &reward.stake_account[..8]
24 );
25 println!(" MEV Rewards: {} lamports", reward.mev_rewards);
26 println!(" Epoch: {}", reward.epoch);
27 println!(" Claimed: {}", reward.mev_claimed);
28 }
29 println!();
30
31 // 3. Get validator information
32 println!("3. Getting validators running Jito...");
33 let jito_validators = client.get_jito_validators().await.unwrap();
34 println!(" Found {} validators running Jito", jito_validators.len());
35
36 // Show top 5 by stake
37 let top_5_by_stake = jito_validators.iter().take(5);
38 for (i, validator) in top_5_by_stake.enumerate() {
39 println!(
40 " {}. Vote Account: {}",
41 i + 1,
42 &validator.vote_account[..8]
43 );
44 println!(" Active Stake: {} lamports", validator.active_stake);
45 println!(" MEV Commission: {} bps", validator.mev_commission_bps);
46 }
47 println!();
48
49 // 4. Get network MEV statistics
50 println!("4. Getting MEV network statistics...");
51 let mev_stats = client.get_mev_rewards(None).await.unwrap();
52 println!(" Epoch: {}", mev_stats.epoch);
53 println!(
54 " Total Network MEV: {} lamports",
55 mev_stats.total_network_mev_lamports
56 );
57 println!(
58 " Jito Stake Weight: {} lamports",
59 mev_stats.jito_stake_weight_lamports
60 );
61 println!(
62 " MEV per lamport: {:.10}",
63 mev_stats.mev_reward_per_lamport
64 );
65 println!();
66
67 // 5. Get validator rewards
68 println!("5. Getting validator rewards...");
69 let validator_rewards = client.get_validator_rewards(None, Some(3)).await.unwrap();
70 println!(" Top 3 validators by rewards:");
71 for (i, validator) in validator_rewards.validators.iter().enumerate() {
72 println!(
73 " {}. Vote Account: {}",
74 i + 1,
75 &validator.vote_account[..8]
76 );
77 println!(" MEV Rewards: {} lamports", validator.mev_rewards);
78 if let Some(pf_rewards) = validator.priority_fee_rewards {
79 println!(" Priority Fee Rewards: {} lamports", pf_rewards);
80 }
81 }
82 println!();
83
84 // 6. Get historical validator data
85 println!("6. Getting historical data for a validator...");
86 if let Some(first_validator) = jito_validators.first() {
87 let history = client
88 .get_validator_history(&first_validator.vote_account)
89 .await
90 .unwrap();
91 println!(" Validator: {}", &first_validator.vote_account[..8]);
92 println!(" Historical data (last 3 epochs):");
93 for (i, entry) in history.iter().take(3).enumerate() {
94 println!(
95 " {}. Epoch {}: {} lamports",
96 i + 1,
97 entry.epoch,
98 entry.mev_rewards
99 );
100 }
101 }
102 println!();
103
104 // 7. Get MEV commission averages
105 println!("7. Getting MEV commission averages...");
106 let commission_avg = client.get_mev_commission_average_over_time().await.unwrap();
107 println!(
108 " Aggregated MEV Rewards: {} lamports",
109 commission_avg.aggregated_mev_rewards
110 );
111 if let Some(latest_apy) = commission_avg.apy.first() {
112 println!(" Latest APY: {:.2}%", latest_apy.data * 100.0);
113 }
114 if let Some(latest_tvl) = commission_avg.tvl.first() {
115 println!(" Latest TVL: {} lamports", latest_tvl.data);
116 }
117 println!();
118
119 // 8. Check specific validator
120 println!("8. Checking specific validator status...");
121 let test_vote_account = "GdRKUZKdiXMEATjddQW6q4W8bPgXRBYJKayfeqdQcEPa";
122 let is_running_jito = client
123 .is_validator_running_jito(test_vote_account)
124 .await
125 .unwrap();
126 println!(" Vote Account: {}", &test_vote_account[..8]);
127 println!(" Running Jito: {}", is_running_jito);
128
129 if let Some(commission) = client
130 .get_validator_mev_commission(test_vote_account)
131 .await
132 .unwrap()
133 {
134 println!(" MEV Commission: {} bps", commission);
135 }
136 println!();
137
138 // 9. Calculate total MEV for epoch range
139 println!("9. Calculating total MEV rewards...");
140 let start_epoch = current_epoch.saturating_sub(5);
141 let end_epoch = current_epoch.saturating_sub(1);
142 let total_mev = client
143 .calculate_total_mev_rewards(start_epoch, end_epoch)
144 .await
145 .unwrap();
146 println!(
147 " Total MEV from epoch {} to {}: {} lamports",
148 start_epoch, end_epoch, total_mev
149 );
150 println!();
151
152 println!("=== Example completed successfully! ===");
153}Sourcepub async fn calculate_total_mev_rewards(
&self,
start_epoch: u64,
end_epoch: u64,
) -> Result<u64, KobeApiError>
pub async fn calculate_total_mev_rewards( &self, start_epoch: u64, end_epoch: u64, ) -> Result<u64, KobeApiError>
Calculate total MEV rewards for a time period
Examples found in repository?
4async fn main() {
5 // Create a client with mainnet defaults
6 let client = KobeClient::mainnet();
7
8 println!("=== Jito API Client - Basic Example ===\n");
9
10 // 1. Get current epoch
11 println!("1. Getting current epoch...");
12 let current_epoch = client.get_current_epoch().await.unwrap();
13 println!(" Current epoch: {}\n", current_epoch);
14
15 // 2. Get staker rewards
16 println!("2. Getting staker rewards (limit 5)...");
17 let rewards = client.get_staker_rewards(Some(5)).await.unwrap();
18 println!(" Found {} staker rewards:", rewards.rewards.len());
19 for (i, reward) in rewards.rewards.iter().enumerate() {
20 println!(
21 " {}. Stake Account: {}",
22 i + 1,
23 &reward.stake_account[..8]
24 );
25 println!(" MEV Rewards: {} lamports", reward.mev_rewards);
26 println!(" Epoch: {}", reward.epoch);
27 println!(" Claimed: {}", reward.mev_claimed);
28 }
29 println!();
30
31 // 3. Get validator information
32 println!("3. Getting validators running Jito...");
33 let jito_validators = client.get_jito_validators().await.unwrap();
34 println!(" Found {} validators running Jito", jito_validators.len());
35
36 // Show top 5 by stake
37 let top_5_by_stake = jito_validators.iter().take(5);
38 for (i, validator) in top_5_by_stake.enumerate() {
39 println!(
40 " {}. Vote Account: {}",
41 i + 1,
42 &validator.vote_account[..8]
43 );
44 println!(" Active Stake: {} lamports", validator.active_stake);
45 println!(" MEV Commission: {} bps", validator.mev_commission_bps);
46 }
47 println!();
48
49 // 4. Get network MEV statistics
50 println!("4. Getting MEV network statistics...");
51 let mev_stats = client.get_mev_rewards(None).await.unwrap();
52 println!(" Epoch: {}", mev_stats.epoch);
53 println!(
54 " Total Network MEV: {} lamports",
55 mev_stats.total_network_mev_lamports
56 );
57 println!(
58 " Jito Stake Weight: {} lamports",
59 mev_stats.jito_stake_weight_lamports
60 );
61 println!(
62 " MEV per lamport: {:.10}",
63 mev_stats.mev_reward_per_lamport
64 );
65 println!();
66
67 // 5. Get validator rewards
68 println!("5. Getting validator rewards...");
69 let validator_rewards = client.get_validator_rewards(None, Some(3)).await.unwrap();
70 println!(" Top 3 validators by rewards:");
71 for (i, validator) in validator_rewards.validators.iter().enumerate() {
72 println!(
73 " {}. Vote Account: {}",
74 i + 1,
75 &validator.vote_account[..8]
76 );
77 println!(" MEV Rewards: {} lamports", validator.mev_rewards);
78 if let Some(pf_rewards) = validator.priority_fee_rewards {
79 println!(" Priority Fee Rewards: {} lamports", pf_rewards);
80 }
81 }
82 println!();
83
84 // 6. Get historical validator data
85 println!("6. Getting historical data for a validator...");
86 if let Some(first_validator) = jito_validators.first() {
87 let history = client
88 .get_validator_history(&first_validator.vote_account)
89 .await
90 .unwrap();
91 println!(" Validator: {}", &first_validator.vote_account[..8]);
92 println!(" Historical data (last 3 epochs):");
93 for (i, entry) in history.iter().take(3).enumerate() {
94 println!(
95 " {}. Epoch {}: {} lamports",
96 i + 1,
97 entry.epoch,
98 entry.mev_rewards
99 );
100 }
101 }
102 println!();
103
104 // 7. Get MEV commission averages
105 println!("7. Getting MEV commission averages...");
106 let commission_avg = client.get_mev_commission_average_over_time().await.unwrap();
107 println!(
108 " Aggregated MEV Rewards: {} lamports",
109 commission_avg.aggregated_mev_rewards
110 );
111 if let Some(latest_apy) = commission_avg.apy.first() {
112 println!(" Latest APY: {:.2}%", latest_apy.data * 100.0);
113 }
114 if let Some(latest_tvl) = commission_avg.tvl.first() {
115 println!(" Latest TVL: {} lamports", latest_tvl.data);
116 }
117 println!();
118
119 // 8. Check specific validator
120 println!("8. Checking specific validator status...");
121 let test_vote_account = "GdRKUZKdiXMEATjddQW6q4W8bPgXRBYJKayfeqdQcEPa";
122 let is_running_jito = client
123 .is_validator_running_jito(test_vote_account)
124 .await
125 .unwrap();
126 println!(" Vote Account: {}", &test_vote_account[..8]);
127 println!(" Running Jito: {}", is_running_jito);
128
129 if let Some(commission) = client
130 .get_validator_mev_commission(test_vote_account)
131 .await
132 .unwrap()
133 {
134 println!(" MEV Commission: {} bps", commission);
135 }
136 println!();
137
138 // 9. Calculate total MEV for epoch range
139 println!("9. Calculating total MEV rewards...");
140 let start_epoch = current_epoch.saturating_sub(5);
141 let end_epoch = current_epoch.saturating_sub(1);
142 let total_mev = client
143 .calculate_total_mev_rewards(start_epoch, end_epoch)
144 .await
145 .unwrap();
146 println!(
147 " Total MEV from epoch {} to {}: {} lamports",
148 start_epoch, end_epoch, total_mev
149 );
150 println!();
151
152 println!("=== Example completed successfully! ===");
153}Trait Implementations§
Source§impl Clone for KobeClient
impl Clone for KobeClient
Source§fn clone(&self) -> KobeClient
fn clone(&self) -> KobeClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more