Skip to content

Commit

Permalink
Adjust coingecko prices based on token decimals (#2899)
Browse files Browse the repository at this point in the history
# Description
Fixes: #2887

# Changes
Adjust returned native token prices when the quoted token has a
different amount of decimals than the native token to be inline with all
other native price estimator implementations.

Additionally I also removed the option to quote without denominating in
any token mainly to reduce complexity.

## How to test
Added an `ignored` unit test that checks that prices make sense.
Also compared prices returned for `wxdai` and `usdc` with prices logged
in our infra.
  • Loading branch information
MartinquaXD authored Aug 19, 2024
1 parent c8e4fef commit 349bd0a
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 68 deletions.
2 changes: 1 addition & 1 deletion crates/shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ prometheus = { workspace = true }
prometheus-metric-storage = { workspace = true }
rate-limit = { path = "../rate-limit" }
reqwest = { workspace = true, features = ["cookies", "gzip", "json"] }
rust_decimal = "1.35.0"
rust_decimal = { version = "1.35.0", features = ["maths"] }
secp256k1 = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion crates/shared/src/price_estimation/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ impl<'a> PriceEstimatorFactory<'a> {
self.args.coin_gecko_url.clone(),
self.args.coin_gecko_api_key.clone(),
self.network.chain_id,
weth,
weth.address(),
self.components.tokens.clone(),
)
.await?,
),
Expand Down
Loading

0 comments on commit 349bd0a

Please sign in to comment.