Skip to content

Commit

Permalink
Bug: correctly handle denoms with / in pcli tx lp (#4766)
Browse files Browse the repository at this point in the history
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.
## Issue ticket number and link

## Checklist before requesting a review

- [x] If this code contains consensus-breaking changes, I have added the
"consensus-breaking" label. Otherwise, I declare my belief that there
are not consensus-breaking changes, for the following reason:

  > client side change only, for pcli
  • Loading branch information
cronokirby authored Jul 25, 2024
1 parent f00d932 commit acbfe7f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/core/component/dex/src/lp/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit acbfe7f

Please sign in to comment.