Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(makerbot): allow more than one prices url in makerbot #2027

Merged
merged 8 commits into from
Feb 13, 2024

Conversation

shamardy
Copy link
Collaborator

@shamardy shamardy commented Dec 8, 2023

fixes #2016

@@ -113,7 +112,7 @@ impl From<std::string::String> for OrderProcessingError {
#[derive(Deserialize)]
pub struct StartSimpleMakerBotRequest {
cfg: SimpleMakerBotRegistry,
price_url: Option<String>,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please leave the singular price_url for backwards compatibility in the short term? e.g. translate it into a list with single item?
During netid migration it would be optimal to avoid any maker config issues until transition is complete.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No error is thrown if using the old param, looks like it uses the defaults. I'll can mark it as deprecated in docs, could we also add a log message in the bot update loop when it is used to warn users of the deprecation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we also add a log message in the bot update loop when it is used to warn users of the deprecation?

Mmm, I guess to do that I have to keep price_url in addition to price_urls to check if it's used or not. If used, what would you like the behaviour to be of the 2 below options:
1 - Translate it into a list with single item and log a warning message.
2 - Use default list and log warning message.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A third option is to revert price_urls to price_url and make it accept either a list or a string, but it won't be very good in my opinion since we need to inform users about the change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A third option is to revert price_urls to price_url and make it accept either a list or a string, but it won't be very good in my opinion since we need to inform users about the change.

I would support both at the same time with an enum.

e.g.,:

enum PriceSourceType {
    #[serde(rename = "price_url")]
    Singular(String),
    #[serde(rename = "price_urls")]
    Multiple(Vec<String>),
}

impl PriceSourceType {
    /// Always use this to get the data
    fn get_urls(&self) -> Vec<String> {
        match self {
            // TODO: deprecate price_url soon and inform the users
            PriceSourceType::Singular(t) => vec![t.clone()],
            PriceSourceType::Multiple(t) => t.clone(),
        }
    }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@smk762
Copy link

smk762 commented Dec 9, 2023

Thanks for the quick PR!
For the docs update, can you confirm the price_urls priority is sequential? e.g. the nth url wont be used unless all prior urls failed?

@shamardy
Copy link
Collaborator Author

For the docs update, can you confirm the price_urls priority is sequential? e.g. the nth url wont be used unless all prior urls failed?

Yep, it's sequential. I will also add a rotation logic (if the first one on the list fails we move it to the back of the list for subsequent requests).

@shamardy
Copy link
Collaborator Author

I will also add a rotation logic (if the first one on the list fails we move it to the back of the list for subsequent requests).

Done

onur-ozkan
onur-ozkan previously approved these changes Jan 11, 2024
Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@borngraced borngraced left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! just couple notes

Copy link
Member

@borngraced borngraced left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very minor

let cfg = running_state.trading_bot_cfg.clone();
let price_urls = &mut running_state.price_urls;
let rates_registry = match fetch_price_tickers(price_urls).await {
Ok(model) => model,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 let cfg = running_state.trading_bot_cfg.clone();
    let rates_registry = match fetch_price_tickers(&mut running_state.price_urls).await {
        Ok(model) => model,
        Err(err) => {
            let nb_orders = cancel_pending_orders(ctx, &cfg).await;
            error!("error fetching price: {err:?} - cancel {nb_orders} orders");
            return;
        },
    };

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@borngraced borngraced left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@smk762 smk762 self-requested a review February 13, 2024 09:35
Copy link

@smk762 smk762 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

  • Confirmed backwards compatibility if using price_url
  • Confirmed price url list progression if a failing url is detected.
  • Confirmed error message in logs when progressing to next url after one fails.

@shamardy shamardy merged commit 4ac9b5a into dev Feb 13, 2024
23 of 30 checks passed
@shamardy shamardy deleted the fix-bot-multi-price-url branch February 13, 2024 10:24
dimxy added a commit to dimxy/komodo-defi-framework that referenced this pull request Feb 18, 2024
* evm-hd-wallet: (27 commits)
  Fix todo comments
  Fix HDAddressOps::Address trait bounds
  fix(indexeddb): fix IDB cursor.continue_() call after drop (KomodoPlatform#2028)
  security bump for `h2` (KomodoPlatform#2062)
  fix(makerbot): allow more than one prices url in makerbot (KomodoPlatform#2027)
  fix(wasm worker env): refactor direct usage of `window` (KomodoPlatform#1953)
  feat(nft): nft abi in withdraw_nft RPC, clear_nft_db RPC (KomodoPlatform#2039)
  refactor(utxo): refactor utxo output script creation (KomodoPlatform#1960)
  feat(ETH): balance event streaming for ETH (KomodoPlatform#2041)
  chore(release): bump mm2 version to 2.1.0-beta (KomodoPlatform#2044)
  feat(trezor): add segwit support for withdraw with trezor (KomodoPlatform#1984)
  chore(config): remove vscode launchjson (KomodoPlatform#2040)
  feat(trading-proto-upgrade): wasm DB, kickstart, refund states, v2 RPCs (KomodoPlatform#2015)
  feat(UTXO): balance event streaming for Electrum clients (KomodoPlatform#2013)
  feat(tx): add new sign_raw_transaction rpc for UTXO and EVM coins (KomodoPlatform#1930)
  fix(p2p): handle encode_and_sign errors (KomodoPlatform#2038)
  chore(release): add changelog entries for v2.0.0-beta (KomodoPlatform#2037)
  chore(network): write network information to stdout (KomodoPlatform#2034)
  fix(price_endpoints): add cached url (KomodoPlatform#2032)
  deps(network): sync with upstream yamux (KomodoPlatform#2030)
  ...
dimxy added a commit to dimxy/komodo-defi-framework that referenced this pull request Feb 25, 2024
* dev:
  feat(zcoin): ARRR WASM implementation (KomodoPlatform#1957)
  feat(trading-proto-upgrade): locked amounts, kmd burn and other impl (KomodoPlatform#2046)
  fix(indexeddb): set stop on success cursor condition (KomodoPlatform#2067)
  feat(config): add `max_concurrent_connections` to mm2 config (KomodoPlatform#2063)
  feat(stats_swaps): add gui/mm_version in stats db (KomodoPlatform#2061)
  fix(indexeddb): fix IDB cursor.continue_() call after drop (KomodoPlatform#2028)
  security bump for `h2` (KomodoPlatform#2062)
  fix(makerbot): allow more than one prices url in makerbot (KomodoPlatform#2027)
  fix(wasm worker env): refactor direct usage of `window` (KomodoPlatform#1953)
  feat(nft): nft abi in withdraw_nft RPC, clear_nft_db RPC (KomodoPlatform#2039)
  refactor(utxo): refactor utxo output script creation (KomodoPlatform#1960)
  feat(ETH): balance event streaming for ETH (KomodoPlatform#2041)
  chore(release): bump mm2 version to 2.1.0-beta (KomodoPlatform#2044)
  feat(trezor): add segwit support for withdraw with trezor (KomodoPlatform#1984)
@smk762 smk762 removed the docs label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants