Conversation
daccd54 to
e5f5334
Compare
| const defaultRoutingBudget = 0.001; | ||
| const btc_now = order.satoshis_now / 100000000; | ||
| const rate = Number(order.max_amount ?? order.amount) / btc_now; | ||
| const rate = Number(order.amount ?? order.max_amount) / btc_now; |
There was a problem hiding this comment.
I just realized in other places we first check has_range, but not here, that's why this was the only place failing. Can you do that instead? https://github.com/RoboSats/robosats/blob/main/frontend/src/components/Charts/DepthChart/index.tsx#L80
388cbd0 to
0b2d4f7
Compare
0b2d4f7 to
053f13a
Compare
KoalaSat
left a comment
There was a problem hiding this comment.
Thank you @FedericoLuque and good catch!
Please accept a little tip for your work, paste here a LN invoice with long expiration date for 40,000 sats
|
lnbc400u1p55aphgpp5zxqpyf64ecqqjmdfpjyd7qtnuu6u2xjqnmhesans8g2ms6qt8ylqdq9xgc56cqzzsxq9phtuqsp5eddl7s3wshrtj5sfk74rgg8ger86yg2d04n4sw8gdy680uklqm5q9qxpqysgq0rg7clrvrqpemrqxzja9k5amy52hct3wqwqr8h477v6hk7hyucf5nj9e5p0j64zee63wrnfjjrgz7xpv7j8dlv0h4kftse8htcfmr6cqks82hn |
|
5e6707e2eb53daefc9598b02fdd308671d0345c9f25358aaa22f0a907105d2b8 |
What does this PR do?
Fixes #2326
The OrderDetails component used a helper function (amountToString) that, by default, limited the precision to 4 digits.
For an amount of 100,155 Sats, this caused rounding to 1.002 x 10^5, displaying 100,200 in the interface ("You send via...").
However, the confirmation button ("Confirm Sent") used a different calculation (toFixed(8)), displaying the exact amount converted to BTC (0.00100155), which caused the discrepancy.
1.2 Fix:
I have forced a precision of 9 digits when the currency is Bitcoin (currentOrder.currency === 1000). This ensures that the amount displayed in the order details is accurate and matches the confirmation button.
This error occurred exclusively in range orders (e.g., from 10k to 1M sats) when a taker decided to take an amount less than the maximum (e.g., 100k sats).
The interface incorrectly calculated the exchange rate using the Maximum Order Amount (1M) instead of the Actual Amount agreed upon (100k).
Since the backend reported the satoshis corresponding to the actual amount (100k), the division Maximum / Actual Sats generated an artificially inflated rate (10 times higher in this example).
When applying this inflated rate to calculate "You receive...", the result was divided by 10, displaying a much lower figure than the actual amount (e.g., 10,000 instead of 100,000).
2.2 Fix:
I reversed the priority logic in the calculation. Now the system correctly uses the Actual Amount (order.amount) if it is defined (the deal has already been closed), and only uses the maximum (order.max_amount) if a final amount has not yet been defined. This ensures that the rate and the displayed satoshis are always consistent.
Checklist before merging
pip install pre-commit, thenpre-commit install. Pre-commit installs git hooks that automatically check the codebase. If pre-commit fails when you commit your changes, please fix the problems it points out.