Skip to content

Commit

Permalink
Handle 403 errors for 1inch requests (#96)
Browse files Browse the repository at this point in the history
From the original issue #95:

> The 1Inch API requires you to tell them which address wants to do the
trade. Due to legal requirements they do not serve some addresses. In
those cases the API call will return a 403 error.
Currently these get forwarded to the driver in a way that causes alerts
like this although they are to be expected and don't indicate an error
in the 1Inch API.

All the 403 errors are considered `NotFound` to reduce false alerts.

Fixes #95
  • Loading branch information
squadgazzz authored Dec 20, 2024
1 parent 51f7e8a commit ec9a318
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/infra/dex/oneinch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ impl From<util::http::RoundtripError<dto::Error>> for Error {
// based on empirical observations of what the API has returned in the
// past.
match err.status_code {
400 => Self::NotFound,
// 403 is returned when the 1inch quote API is forbidden due to legal reason for
// a specific address or an artificial address was used in the request.
400 | 403 => Self::NotFound,
_ => Self::Api {
code: err.status_code,
description: err.description,
Expand Down

0 comments on commit ec9a318

Please sign in to comment.