From 65d4dd8e0ff1b43c561e268b88c174b1b0ab0c19 Mon Sep 17 00:00:00 2001 From: sneak Date: Mon, 21 Sep 2026 07:27:00 +0000 Subject: [PATCH] docs: name every approval-screen amount string, fix stale zero claim (closes #369) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The README's amount-display section claimed a genuine zero always renders `0.0000`. That is corrected and scoped: it holds for the ERC-20 amount and for the swap's `Amount` line on a literal-zero `amountIn` in a V2/V3 exact-in swap or a zero `WRAP_ETH`. Only two zeros are stated in words before the floor — the swap's `Min. received` (any zero minimum) and its V4 exact-in `Amount` (an `amountIn` of zero, V4's open delta). A new list names every string an amount slot can show: a formatted quantity, `Unlimited`, `All available (V4 open delta)`, `None (no minimum guaranteed)`, base units with decimals unknown, and `Unknown (not named in the calldata)`. It also records that a zero `minBalance` on a `BALANCE_CHECK_ERC20` step now reads the no-minimum wording where it once read `0.0000`. Each claim checked against the tree. Docs only. Model: opus-4-8 --- README.md | 47 ++++++++++++++++++++++++++++++++++++++++++++--- TODO.md | 15 +++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1563171..231d089 100644 --- a/README.md +++ b/README.md @@ -882,9 +882,18 @@ On those screens, when the truncated string would contain no digit from 1 to 9 and the value does, the amount is extended to its first significant digit instead: `0.000000000000000001 DAI`, not `0.0000 DAI`. The test is on the whole truncated string, integer part included, so `1.00005` still shows as `1.0000` — -the exception only fires where the entire displayed figure would read as zero. A -genuine zero still renders `0.0000`, and truncation stays truncation: `0.99999` -shows as `0.9999`, never rounded up. +the exception only fires where the entire displayed figure would read as zero. +Truncation stays truncation: `0.99999` shows as `0.9999`, never rounded up. A +genuine zero reaching this rule renders `0.0000`. The ERC-20 +`approve`/`transfer` amount does exactly that, and so does the swap's `Amount` +line for a literal-zero `amountIn` on a V2 or V3 exact-in swap, or a zero +`WRAP_ETH` (`0.0000 ETH`). Only two zeros are stated in words before the floor: +the swap's `Min. received` line reads `None (no minimum guaranteed)` for any +zero minimum, and its `Amount` line reads `All available (V4 open delta)` for a +V4 exact-in `amountIn` of zero, which V4 treats as the whole open credit rather +than a quantity. So the guarantee that a zero is never shown as `0.0000` covers +the `Min. received` line and the V4 exact-in `Amount`; a V2/V3 or `WRAP_ETH` +`Amount` still renders it (see the list of amount-slot strings below). The rule and its exception live in `src/shared/amountDisplay.js` as `truncateAmount()` and `truncateAmountNeverZero()`. Everything the approval and @@ -936,6 +945,38 @@ and compare against. Reading the stored field directly instead answers `null` for a bundled or tracked token the explorer merely omitted, which is not a refusal the wallet has any reason to make. +**Every string an amount slot can show:** taken together, the exceptions above +mean an amount line on the dApp approval screen (and the wait/success/error +screens that carry a figure forward) shows one of a fixed set of strings, not +always a number: + +- A formatted quantity, e.g. `17.1900 USDT`: the token's scale is known and the + figure is at or above the floor, or below it and extended to its first + significant digit. This is `truncateAmountNeverZero()` + (`src/shared/amountDisplay.js`). +- `Unlimited`: an unbounded allowance or permit, which needs no scale to + describe — a `uint256`-max ERC-20 `approve` (`src/popup/views/approval.js`) or + a Permit2 amount at the `uint160` max on a swap's `Amount` + (`src/shared/uniswap.js`). +- `All available (V4 open delta)`: a V4 exact-in swap whose `amountIn` is zero. + V4 reads that zero as "use the whole open delta", not as a literal zero, so + the calldata states no quantity at all. Swap `Amount` line only + (`src/shared/uniswap.js`). +- `None (no minimum guaranteed)`: a zero minimum — the swap guarantees nothing + back. It is a literal zero slippage floor on a V2/V3/V4 swap, and it also + reaches a `BALANCE_CHECK_ERC20` step: a zero `minBalance`, which once rendered + `0.0000` beside the token symbol, now reads this. Swap `Min. received` line + (`src/shared/uniswap.js`). +- ` base units (decimals unknown)`: the token's scale could not be + resolved, so the base-unit integer is shown with that caveat rather than + formatted (see Unknown token scale above). Reaches both the ERC-20 amount line + and the swap's `Amount` and `Min. received` (`unknownDecimalsAmount()` in + `src/shared/approvalAmount.js`). +- `Unknown (not named in the calldata)`: not an amount but the currency itself — + the `Token In` or `Token Out` line when nothing in the calldata established + which token, shown beside the amount and, like the strings above, a sentence + rather than a value (`src/shared/uniswap.js`). + #### Partial USD totals Prices are fetched for the top 25 tokens only, so an address can hold assets the diff --git a/TODO.md b/TODO.md index 8df4a10..213733f 100644 --- a/TODO.md +++ b/TODO.md @@ -143,6 +143,21 @@ but the review is broader than any of them. both routes take, so they behave the same and the button is live for the next delete. +- 2026-09-21: `README.md` now documents the approval screen's amount-slot + vocabulary and no longer contradicts itself + ([#369](https://git.eeqj.de/sneak/AutistMask/issues/369)). The stale claim + that a genuine zero still renders `0.0000` is corrected: it holds for the + ERC-20 amount, and also for the swap's `Amount` line on a literal-zero + `amountIn` in a V2/V3 exact-in swap or a zero `WRAP_ETH`. Only two zeros are + stated in words upstream — the swap's `Min. received` (any zero minimum) and + its V4 exact-in `Amount` (an `amountIn` of zero, V4's open delta). The + amount-display section now names every string a slot can show — a formatted + quantity, `Unlimited`, `All available (V4 open delta)`, + `None (no minimum guaranteed)`, base units with decimals unknown, and + `Unknown (not named in the calldata)` — and records that a zero `minBalance` + on a `BALANCE_CHECK_ERC20` step now reads `None (no minimum guaranteed)` where + it once read `0.0000`. Docs only; each claim checked against the tree. + - 2026-08-30: An address no longer wraps, or is shortened to fit, in any of the common views ([#380](https://git.eeqj.de/sneak/AutistMask/issues/380)). The wallet list was the reported case: the address shared one row with the -- 2.54.0