-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
282f78d
commit 4c0ef26
Showing
6 changed files
with
200 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"tokenProgram": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", | ||
"tokenType": "", | ||
"risks": [ | ||
{ | ||
"name": "Large Amount of LP Unlocked", | ||
"value": "100.00%", | ||
"description": "A large amount of LP tokens are unlocked, allowing the owner to remove liquidity at any point.", | ||
"score": 10999, | ||
"level": "danger" | ||
}, | ||
{ | ||
"name": "High holder correlation", | ||
"value": "(19)", | ||
"description": "The top users hold similar supply amounts", | ||
"score": 2900, | ||
"level": "warn" | ||
}, | ||
{ | ||
"name": "Low amount of LP Providers", | ||
"value": "", | ||
"description": "Only a few users are providing liquidity", | ||
"score": 400, | ||
"level": "warn" | ||
}, | ||
{ | ||
"name": "Mutable metadata", | ||
"value": "", | ||
"description": "Token metadata can be changed by the owner", | ||
"score": 100, | ||
"level": "warn" | ||
} | ||
], | ||
"score": 14399 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use crate::{config::Config, model::RugCheckRes}; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum RugCheckerError { | ||
#[error("Connection error: {0}")] | ||
RugCheckError(String), | ||
} | ||
|
||
pub struct RugChecker<'a> { | ||
pub config: &'a Config, | ||
} | ||
|
||
impl<'a> RugChecker<'a> { | ||
pub fn new(config: &'a Config) -> Self { | ||
Self { config } | ||
} | ||
|
||
pub async fn isvalid_rug_check(&self, token_mint: &str) -> Result<bool, RugCheckerError> { | ||
let client = reqwest::Client::new(); | ||
let url = format!( | ||
"{}/tokens/{}/report/summary", | ||
self.config.rug_checker_url, token_mint | ||
); | ||
let res = client | ||
.get(url) | ||
.header("Content-Type", "application/json") | ||
.send() | ||
.await; | ||
|
||
match res { | ||
Ok(data) => { | ||
let status = data.status(); | ||
let response_txt = data.text().await; | ||
println!("Status: {}", status); | ||
|
||
match response_txt { | ||
Ok(txt) => { | ||
println!("Response: {}", txt); | ||
let res_data = serde_json::from_str::<RugCheckRes>(&txt).unwrap(); | ||
let mut is_valid = true; | ||
res_data.risks.iter().for_each(|risk| { | ||
println!("Rug: {:?}", risk); | ||
if risk.name.to_lowercase() == "single holder ownership" { | ||
let value = risk.value.replace("%", ""); | ||
let numberic_value = value.parse::<f64>().unwrap(); | ||
if numberic_value > self.config.rug_check_config.signal_holder_ownership { | ||
is_valid = false; | ||
} | ||
} | ||
}); | ||
if !is_valid { | ||
return Ok(false); | ||
} | ||
|
||
let res_data = res_data.clone(); | ||
let valid = !res_data.risks.iter().any(|r| { | ||
self | ||
.config | ||
.rug_check_config | ||
.not_allowed_risk | ||
.contains(&r.name) | ||
}); | ||
return Ok(valid); | ||
} | ||
Err(e) => { | ||
return Err(RugCheckerError::RugCheckError(e.to_string())); | ||
} | ||
} | ||
} | ||
Err(e) => { | ||
return Err(RugCheckerError::RugCheckError(e.to_string())); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters