Skip to content

Commit

Permalink
suggestions from omar: provide a default value for price_sources by m…
Browse files Browse the repository at this point in the history
…aking it an opiton field
  • Loading branch information
mariocynicys committed Apr 13, 2024
1 parent 729be0f commit 9577388
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 4 additions & 4 deletions mm2src/mm2_main/src/lp_ordermatch/simple_market_maker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ impl PriceSources {
#[derive(Deserialize)]
pub struct StartSimpleMakerBotRequest {
cfg: SimpleMakerBotRegistry,
// TODO: We can't `flatten` the price_sources while implementing `default` because of this issue:
// https://github.com/serde-rs/serde/issues/1626 - so let's only flatten for now and provide no default.
// TODO: This is marked as an `Option` for now so we can be able to provide a default value for it since
// `flatten` & `default` don't work together: https://github.com/serde-rs/serde/issues/1626.
#[serde(flatten)]
price_sources: PriceSources,
price_sources: Option<PriceSources>,
bot_refresh_rate: Option<f64>,
}

Expand Down Expand Up @@ -752,7 +752,7 @@ pub async fn start_simple_market_maker_bot(ctx: MmArc, req: StartSimpleMakerBotR
*state = RunningState {
trading_bot_cfg: req.cfg,
bot_refresh_rate: refresh_rate,
price_urls: req.price_sources.get_urls(),
price_urls: req.price_sources.unwrap_or_default().get_urls(),
}
.into();
drop(state);
Expand Down
1 change: 0 additions & 1 deletion mm2src/mm2_main/tests/mm2_tests/lp_bot_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ fn test_start_and_stop_simple_market_maker_bot() {
"mmrpc": "2.0",
"method": "start_simple_market_maker_bot",
"params": {
"price_url": "https://prices.komodian.info/api/v2/tickers",
"cfg": {
"KMD-BEP20/BUSD-BEP20": {
"base": "KMD-BEP20",
Expand Down

0 comments on commit 9577388

Please sign in to comment.