Skip to content

Commit

Permalink
Merge pull request #289 from lfglabs-dev/fix/defi-alt-protocols-apr
Browse files Browse the repository at this point in the history
  • Loading branch information
Th0rgal authored Oct 17, 2024
2 parents 8b28e12 + 2f9497a commit b5900e5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/endpoints/discover/defi/get_alt_protocol_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ pub async fn handler(State(state): State<Arc<AppState>>) -> impl IntoResponse {
for (_protocol, strategies) in new_map.iter_mut() {
for (strategy_name, strategy_data) in strategies.iter_mut() {
if let Some(nimbora_symbol) = strategy_map.get(strategy_name) {
if let Some(nimbora_strategy) = nimbora_strategies.iter().find(|s| {
s["symbol"].as_str().unwrap_or("") == nimbora_symbol
}) {
if let Some(nimbora_strategy) = nimbora_strategies
.iter()
.find(|s| s["symbol"].as_str().unwrap_or("") == nimbora_symbol)
{
if let Some(apr) = nimbora_strategy["apr"].as_str() {
if let Ok(apr_value) = apr.parse::<f64>() {
strategy_data["apr"] = Value::Number(
serde_json::Number::from_f64(apr_value)
serde_json::Number::from_f64(apr_value / 100.0)
.unwrap_or(serde_json::Number::from(0)),
);
}
Expand All @@ -86,4 +87,4 @@ pub async fn handler(State(state): State<Arc<AppState>>) -> impl IntoResponse {
};

get_error(format!("A - Try again later"))
}
}

0 comments on commit b5900e5

Please sign in to comment.