Skip to content

Commit

Permalink
Add dependie
Browse files Browse the repository at this point in the history
  • Loading branch information
LevBeta committed Jun 10, 2024
1 parent e206819 commit 02df8e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 28 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ Marginfi liquidator

Ubuntu
```bash
sudo apt install build-essential libssl-dev pkg-config
sudo apt install build-essential libssl-dev pkg-config unzip
```

Follow this instructions
https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os;

### Creating a New Configuration File

To initiate the creation of a new configuration file for the liquidator, execute the following command in your terminal:
Expand Down
46 changes: 19 additions & 27 deletions src/jito/mod.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
use jito_protos::{
bundle::{bundle_result::Result as BundleResultType, rejected::Reason, Bundle},
searcher::{
searcher_service_client::SearcherServiceClient, NextScheduledLeaderRequest,
SubscribeBundleResultsRequest, GetTipAccountsRequest
searcher_service_client::SearcherServiceClient, GetTipAccountsRequest,
NextScheduledLeaderRequest, SubscribeBundleResultsRequest,
},
};
use std::str::FromStr;
use jito_searcher_client::{get_searcher_client_no_auth, send_bundle_with_confirmation};
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::{
commitment_config::CommitmentConfig, instruction::Instruction, pubkey::Pubkey, signature::{Keypair, Signer}, system_instruction::transfer, transaction::{Transaction, VersionedTransaction}
commitment_config::CommitmentConfig,
instruction::Instruction,
pubkey::Pubkey,
signature::{Keypair, Signer},
system_instruction::transfer,
transaction::{Transaction, VersionedTransaction},
};
use std::str::FromStr;
use tokio::time::sleep;
use tonic::transport::Channel;

pub struct JitoClient {
rpc: RpcClient,
searcher_client: SearcherServiceClient<Channel>,
keypair: Keypair,
tip_accounts: Vec<String>
tip_accounts: Vec<String>,
}

impl JitoClient {
Expand All @@ -32,7 +37,7 @@ impl JitoClient {
rpc,
searcher_client,
keypair,
tip_accounts: Vec::new()
tip_accounts: Vec::new(),
}
}

Expand All @@ -48,7 +53,8 @@ impl JitoClient {

let mut is_jito_leader = false;
while !is_jito_leader {
let next_leader = self.searcher_client
let next_leader = self
.searcher_client
.get_next_scheduled_leader(NextScheduledLeaderRequest {})
.await
.expect("Failed to get next scheduled leader")
Expand All @@ -63,7 +69,11 @@ impl JitoClient {
Transaction::new_signed_with_payer(
&[
ix,
transfer(&self.keypair.pubkey(), &Pubkey::from_str(&self.tip_accounts[0])?, lamports),
transfer(
&self.keypair.pubkey(),
&Pubkey::from_str(&self.tip_accounts[0])?,
lamports,
),
],
Some(&self.keypair.pubkey()),
&[&self.keypair],
Expand All @@ -90,28 +100,10 @@ impl JitoClient {
.await
.expect("Failed to get tip accounts")
.into_inner();

self.tip_accounts = tip_accounts.accounts;

Ok(())
}

}

#[cfg(test)]
mod tests {
use solana_sdk::signer::keypair;

use super::*;
#[tokio::test]
async fn test_leader() {
let keypair = Keypair::new();
let mut jito_client = JitoClient::new(
"https://rpc.ironforge.network/mainnet?apiKey=01HTYZW4C7W74CTK8N8XN2GMR5".to_string(),
keypair,
"https://mainnet.block-engine.jito.wtf".to_string(),
)
.await;
jito_client.get_tip_accounts().await;
}
}

0 comments on commit 02df8e5

Please sign in to comment.