fix: restore sats volume in fixed-price order title (regression from …#851
fix: restore sats volume in fixed-price order title (regression from …#851Matobi98 wants to merge 1 commit into
Conversation
WalkthroughOrder 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 ChangesAmount-aware order title generation
Estimated code review effort: 2 (Simple) | ~12 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (11)
bot/ordersActions.tslocales/de.yamllocales/en.yamllocales/es.yamllocales/fa.yamllocales/fr.yamllocales/it.yamllocales/ko.yamllocales/pt.yamllocales/ru.yamllocales/uk.yaml
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:
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 showedPrecio: 100.000.000(confirming it is a fixed order) but the title readComprando satswith no amount — identical to a market-rate order. A market order (/buy 0 1304 ars nx) showed the same title but withTasa: yadioinstead of aPrecio:line.Root cause
PR #770 ("Improve i18n flexibility for showusername order sentences", commit
66e0004).Before #770,
buildDescription()inbot/ordersActions.tsprinted the sats amount in the first line for fixed-price orders:So a fixed order clearly read
Selling 100 sats, while a market order readSelling 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 newgetOrderTitleMessage()never printed the sats amount: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.ts→getOrderTitleMessage()now receivesamount,fiatCodeandpriceFromAPI. It fills${amount}withnumberFormat(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:
price_from_api === false):Selling 1,000 sats/@user is selling 1,000 sats.price_from_api === true):Selling sats/@user is selling sats(unchanged, no double space).Notes
Affected files
bot/ordersActions.ts(buildDescription,getOrderTitleMessage)locales/*.yaml(all languages)Summary by CodeRabbit
New Features
Bug Fixes
Localization