Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consistent string representation of NativePriceEstimators (#2169)
# Description The current default argument of `native_price_estimators` is an invalid value. This can be seen by running the autopilot without any argument: ``` $ cargo run --bin autopilot [...] native_price_estimators: GenericPriceEstimator("GenericPriceEstimator(\"Baseline\")") [...] ``` This is because the default is generated with `default_values_t`, which "Requires std::fmt::Display that roundtrips correctly with the [Arg::value_parser](https://docs.rs/clap/latest/clap/struct.Arg.html#method.value_parser) or #[arg(value_enum)]" ([source](https://docs.rs/clap/latest/clap/_derive/index.html#arg-attributes)). This PR changes the string representation to work according to the docs remark. A negative of this change is that we technically can't distinguish between `NativePriceEstimator::GenericPriceEstimator("OneInchSpotPriceApi")` and `NativePriceEstimator::OneInchSpotPriceApi` just from looking at the string representation. # Changes - Updated string representation for `NativePriceEstimators`. ## How to test New unit test. Try to run the autopilot without arguments again: ``` [...] native_price_estimators: Baseline [...] ``` Also, note that `Display` is only used for printing the arguments on startup, so this shouldn't break anything else. To see this, try to remove the implementation for `Display` for `NativePriceEstimators`, use `default_values` to not need `Display`, and fix the few compiling argument to confirm that `Display` is unused otherwise.
- Loading branch information