Skip to content

fix: restore sats volume in fixed-price order title (regression from …#851

Open
Matobi98 wants to merge 1 commit into
lnp2pBot:mainfrom
Matobi98:fix/fixed-order-sats-volume
Open

fix: restore sats volume in fixed-price order title (regression from …#851
Matobi98 wants to merge 1 commit into
lnp2pBot:mainfrom
Matobi98:fix/fixed-order-sats-volume

Conversation

@Matobi98

@Matobi98 Matobi98 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Fixed-price orders hide the sats volume, making them look mispriced vs market rate (regression from #770)

Fixes #850

Summary

Users are reporting that for some orders (notably CUP, sometimes VES) the bot asks the buyer for ~10–20% fewer sats than the market rate on yadio suggests. Example from a report:

  • Offer: selling sats for 7,560 CUP, shown Price: 45,542,168.67
  • Bot asks buyer for an invoice of 16,600 sats
  • yadio market rate for 7,560 CUP ≈ 21,000 sats
  • Apparent gap: ~20%

The bot is not miscalculating. The order is a fixed-price order:
7,560 / 45,542,168 × 100,000,000 ≈ 16,600 sats, which is exactly what the bot asks. The gap is simply the difference between the seller's fixed price (~45.5M CUP/BTC) and the current market rate (~36M CUP/BTC).

The real problem is transparency: fixed-price offers no longer display the sats volume, so they look almost identical to market-rate offers. Buyers assume market rate, check yadio, and are surprised. This started after PR #770 was deployed ("since last night"), and shows up most on CUP/VES because those have the widest spread between fixed listings and the yadio rate.

Reproduced locally with an ARS fixed-price order (/buy 1303 1303 ars nx): the offer showed Precio: 100.000.000 (confirming it is a fixed order) but the title read Comprando sats with no amount — identical to a market-rate order. A market order (/buy 0 1304 ars nx) showed the same title but with Tasa: yadio instead of a Precio: line.

Root cause

PR #770 ("Improve i18n flexibility for showusername order sentences", commit 66e0004).

Before #770, buildDescription() in bot/ordersActions.ts printed the sats amount in the first line for fixed-price orders:

const action = type === 'sell' ? i18n.t('selling') : i18n.t('buying');
let amountText = `${numberFormat(fiatCode, amount)} `; // sats quantity
if (priceFromAPI) {
  amountText = ''; // hidden only for market-price orders
}
let description = `${username}${action} ${amountText}` + i18n.t('sats') + `\n`;

So a fixed order clearly read Selling 100 sats, while a market order read Selling sats.

#770 moved the whole sentence into single-template strings (selling_sats, buying_sats, showusername_selling_sats, ...) that only accept {username}, to give translators freedom to write natural sentences. In doing so it dropped the ${amount} interpolation. The new getOrderTitleMessage() never printed the sats amount:

return isSell ? i18n.t('selling_sats') : i18n.t('buying_sats'); // no amount, ever

So #770 did not change any price/amount math — it removed the sats-volume display that made fixed-price (off-market) orders obvious to buyers. The result is that fixed orders now look like market orders, and the fixed-vs-market spread becomes an invisible surprise.

Fix

Reintroduce the sats volume as a single ${amount} variable inside the existing title templates, instead of adding a parallel set of keys:

  • bot/ordersActions.tsgetOrderTitleMessage() now receives amount, fiatCode and priceFromAPI. It fills ${amount} with numberFormat(fiatCode, amount) for fixed orders and with an empty string for market orders, then collapses whitespace (.replace(/\s+/g, ' ').trim()) so the market case never leaves a double space regardless of where translators place the slot.
  • locales/*.yaml (all 10 languages) → the same 4 keys now carry a ${amount} placeholder. No new keys added.

Resulting behavior:

  • Fixed-price order (price_from_api === false): Selling 1,000 sats / @user is selling 1,000 sats.
  • Market-price order (price_from_api === true): Selling sats / @user is selling sats (unchanged, no double space).

Notes

  • This is not a separate market-rate bug. The CUP/VES "10–20% difference" reports are the fixed-vs-market spread becoming invisible once the sats volume stopped being shown; restoring it makes fixed orders recognizable again.

Affected files

  • bot/ordersActions.ts (buildDescription, getOrderTitleMessage)
  • locales/*.yaml (all languages)

Summary by CodeRabbit

  • New Features

    • Order and notification text now shows the traded amount more consistently, including username-based sale/buy messages.
  • Bug Fixes

    • Market-price orders now display without an amount in titles, while fixed-price orders show a formatted fiat amount.
    • Improved spacing and formatting in order titles for cleaner display.
  • Localization

    • Updated translated order strings across multiple languages to include dynamic amount placeholders and match the new display behavior.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Order title generation is refactored to include the traded amount, formatting an empty amount for market-price orders and a formatted fiat amount otherwise. Corresponding locale strings across ten languages are updated to interpolate ${amount} into selling/buying sats and username-display messages.

Changes

Amount-aware order title generation

Layer / File(s) Summary
Order title logic and wiring
bot/ordersActions.ts
buildDescription now passes order amount, fiatCode, and priceFromAPI to getOrderTitleMessage, which computes an amount string (empty for market orders, formatted otherwise), selects translation keys based on show_username, and returns a whitespace-normalized title.
Locale string updates for amount interpolation
locales/de.yaml, locales/en.yaml, locales/es.yaml, locales/fa.yaml, locales/fr.yaml, locales/it.yaml, locales/ko.yaml, locales/pt.yaml, locales/ru.yaml, locales/uk.yaml
selling_sats, buying_sats, and showusername_* message strings across all supported languages now interpolate ${amount} instead of generic amount-less text.

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related issues

Possibly related PRs

  • lnp2pBot/bot#770: Both PRs modify getOrderTitleMessage and the showusername_* i18n strings in bot/ordersActions.ts.

Suggested reviewers: Luquitasjeffrey, mostronatorcoder, grunch

Poem

A rabbit hops with sats in tow,
${amount} now joins the show!
Ten tongues speak the traded sum,
No more titles blank and glum.
Hop, hop, hooray—the numbers glow! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: restoring sats volume in fixed-price order titles after a regression.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Matobi98 Matobi98 marked this pull request as draft July 1, 2026 22:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bot/ordersActions.ts`:
- Around line 279-287: The title-building logic in the order action helper uses
`numberFormat` directly, but the reachable fallback can still return a
non-string value and end up interpolated into the title. Update the `amount`
handling in the order title builder to normalize the result to a string fallback
(or empty string) before it is passed into the template, using the
`numberFormat` call site as the fix point.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 80248338-b585-4d19-8881-eafe7b09cf05

📥 Commits

Reviewing files that changed from the base of the PR and between fea5d84 and 4dec4ff.

📒 Files selected for processing (11)
  • bot/ordersActions.ts
  • locales/de.yaml
  • locales/en.yaml
  • locales/es.yaml
  • locales/fa.yaml
  • locales/fr.yaml
  • locales/it.yaml
  • locales/ko.yaml
  • locales/pt.yaml
  • locales/ru.yaml
  • locales/uk.yaml

Comment thread bot/ordersActions.ts
@Matobi98 Matobi98 marked this pull request as ready for review July 1, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fixed-price orders hide the sats volume, making them look mispriced vs market rate (regression from #770)

1 participant