Skip to content

Commit

Permalink
Merge pull request #293 from lfglabs-dev/fix/nimbora-strategies
Browse files Browse the repository at this point in the history
fix: nimbora strategies
  • Loading branch information
Th0rgal authored Oct 21, 2024
2 parents ea86308 + 941dcbf commit 09d2f0b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/endpoints/discover/defi/get_alt_protocol_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,31 @@ pub async fn handler(State(state): State<Arc<AppState>>) -> impl IntoResponse {

// Update APRs with Nimbora data if available
if let Ok(Value::Array(nimbora_strategies)) = nimbora_data {
for (_protocol, strategies) in new_map.iter_mut() {
for (strategy_name, strategy_data) in strategies.iter_mut() {
for (protocol, strategies) in new_map.iter_mut() {
if protocol != "Nimbora" {
continue;
}
for (strategy_name, _strategy_data) in strategies.clone().iter() {
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(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 / 100.0)
.unwrap_or(serde_json::Number::from(0)),
);
if let Some(strategy) =
strategies.get_mut(strategy_name)
{
strategy["apr"] = Value::Number(
serde_json::Number::from_f64(apr_value / 100.0)
.unwrap_or(serde_json::Number::from(0)),
);
}
}
}
}
} else {
strategies.remove(strategy_name);
}
}
}
Expand Down

0 comments on commit 09d2f0b

Please sign in to comment.