Skip to content

Commit

Permalink
Update price estimate categories
Browse files Browse the repository at this point in the history
  • Loading branch information
bram-vdberg committed Jan 29, 2025
1 parent d7e00c9 commit 67a43a6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crates/shared/src/price_estimation/instrumented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ impl<T> InstrumentedPriceEstimator<T> {
}
}

/// Determines the result of a price estimate as either "success" or
/// "failure".
/// Determines the result of a price estimate, returning either "success" or the
/// error reason
fn estimate_result<B>(&self, estimate: Result<&B, &PriceEstimationError>) -> &str {
// Count as a successful request if the answer is ok (no error) or if the error
// is No Liquidity
if estimate.is_ok() || matches!(estimate, Err(PriceEstimationError::NoLiquidity)) {
"success"
} else {
"failure"
match estimate {
Ok(_) => "success",
Err(PriceEstimationError::NoLiquidity) => "success",
Err(PriceEstimationError::UnsupportedToken { .. }) => "unsupported_token",
Err(PriceEstimationError::UnsupportedOrderType(_)) => "unsupported_order_type",
Err(PriceEstimationError::RateLimited) => "rate_limited",
Err(PriceEstimationError::EstimatorInternal(_)) => "estimator_internal_error",
Err(PriceEstimationError::ProtocolInternal(_)) => "protocol_internal_error",
}
}
}
Expand Down

0 comments on commit 67a43a6

Please sign in to comment.