Skip to content

fix(wallet): order token cards at the figure they display - #701

Merged
bmc08gt merged 1 commit into
mainfrom
fix/wallet-card-stack-order
Aug 31, 2026
Merged

fix(wallet): order token cards at the figure they display#701
bmc08gt merged 1 commit into
mainfrom
fix/wallet-card-stack-order

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Two wallet cards showing the same $1.00 — Dollars (USDF reserves) and a launchpad currency — swap places on screen while the user watches. Observed on Android, and Session.balances sorts the same way, so the same swap is latent here.

The sort compared StoredBalance.usdf, which carries six decimals against the two USD renders. Reserves sit at exactly 1.000000; a launchpad currency's USD worth is a bonding-curve result that lands on arbitrary sixth decimals and moves on every price refresh. Each refresh re-decided which of the two was greater and the cards traded places. The stack positions cards by index with no per-card position animation, so it reads as a jump rather than a reorder.

Change

  • StoredBalance.walletOrder — the comparator, named and lifted out of Session.balances, now comparing values rounded to USD display precision. The existing alphabetical-by-name tiebreak settles cards showing the same figure, and no refresh changes a name.
  • StoredBalance.displayedUSDF — the stored value at the cents a user actually sees, following the rounding shape already used in AddMoneyGate and UserFlags.

Ports code-payments/code-android-app#1369 (efdba1d3e), which extracted the same comparator as BalanceOrder and switched it to nativeAmount.toDouble(). Android's comparator was written to match this one, tiebreak included, so the two stay in step.

Tests

SessionBalanceOrderTests drives the real Session.balances through a database refresh, mirroring Android's two regression tests:

  • Dollars at $1.000000 against a launchpad currency at $0.999600, refreshed to $1.000400. Every card displays $1.00 across both, and the order must hold.
  • A genuine one-cent difference ($0.99, then $1.01) still orders the deck by value.

The launchpad amounts are picked so the curve sells inside a single 100-token pricing step, which makes each USD figure exact and hand-checkable.

The wallet's card stack sorted on `StoredBalance.usdf`, which carries six
decimals against the two USD renders. Reserves sit at exactly 1.000000, while a
launchpad currency's USD worth is a bonding-curve result landing on arbitrary
sixth decimals that moves on every price refresh. With both cards reading
$1.00, each refresh re-decided which was greater and the two traded places on
screen. The stack positions cards by index with no per-card position animation,
so the swap reads as a jump.

Extract the comparator as `StoredBalance.walletOrder` and compare the values
rounded to USD display precision. The existing alphabetical-by-name tiebreak
then settles cards showing the same figure, identically on every refresh.

Ports the Android fix in code-payments/code-android-app#1369.
@bmc08gt bmc08gt self-assigned this Aug 31, 2026
@bmc08gt
bmc08gt merged commit 3aefbc6 into main Aug 31, 2026
@bmc08gt
bmc08gt deleted the fix/wallet-card-stack-order branch August 31, 2026 16:56
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.

1 participant