From 453637568b12733bfb3610d91fdf62c7a2c4a0b7 Mon Sep 17 00:00:00 2001 From: Lucas Meier Date: Thu, 25 Jul 2024 09:54:37 -0700 Subject: [PATCH] Bug: correctly handle denoms with `/` in pcli tx lp The parsing looked for the first occurrence of the slash for nX@nY/fee but if X or Y contains a slash, this will be incorrect. This fixes this somewhat, by looking for the last slash, and only considering that a fee if it ends with bps. This will not correctly handle a denom containing both a slash and ending with bps, but beyond that we'll need to change the format probably. --- crates/core/component/dex/src/lp/order.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/core/component/dex/src/lp/order.rs b/crates/core/component/dex/src/lp/order.rs index bc2c1bd7ae..ff15e7f6c5 100644 --- a/crates/core/component/dex/src/lp/order.rs +++ b/crates/core/component/dex/src/lp/order.rs @@ -31,9 +31,10 @@ pub struct SellOrder { /// This doesn't parse the values yet, because we need to inspect their units. fn parse_parts(input: &str) -> Result<(&str, &str, u32)> { - let (trade_part, fee_part) = match input.split_once('/') { - Some((trade_part, fee_part)) => (trade_part, fee_part), - None => (input, "0bps"), + let (trade_part, fee_part) = match input.rsplit_once('/') { + // In case we have a denom with a slash, and no fee + Some((trade_part, fee_part)) if fee_part.ends_with("bps") => (trade_part, fee_part), + _ => (input, "0bps"), }; let Some((val1, val2)) = trade_part.split_once('@') else {