Skip to content

Show the balance in fiat again, priced from the 1Click listing - #692

Merged
n13 merged 7 commits into
mainfrom
n13/qtc-price-under-balance
Oct 9, 2026
Merged

n13 merged 7 commits into
mainfrom
n13/qtc-price-under-balance

Conversation

@n13

@n13 n13 commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

What

The fiat line under the QTC balance on the home screen is back, driven by a real price instead of the 1:1 placeholder it was removed with.

  • Price source: 1Click's token listing (GET /v0/tokens) lists QTC with a USD price (166.66 at the time of writing). A new tokenUsdPriceProvider reads it on start and every 5 minutes.
  • Cheapest possible query: the 1Click endpoint has no per-token filter, but it serves an ETag. OneClickService now remembers each GET's ETag and sends If-None-Match, so an unchanged listing answers 304 with no body. The first fetch is ~10 KB gzipped, refreshes cost nothing until a price changes. Verified against the live API.
  • No CoinGecko on the price path: SwapService now caches the raw listing separately from the ranked swap list, so getListedQuantusToken never triggers the CoinGecko ranking. Only the swap screen's token list does.
  • No fake prices: ExchangeRateService.tokenToUsdRate is nullable and converting without a price throws. CurrencyDisplayState.secondaryAmount is null until a price is known, so nothing shows rather than a wrong number. Transaction amounts stay QTC-only; only the balance carries the fiat line. The hide-balance toggle masks it.
  • Fiat conversion uses the selected fiat and the quersi exchange rates as before.

Tests

  • SDK: the listed QTC never asks CoinGecko; the listing is revalidated by ETag and the body reused on 304.
  • App: no fiat line without a price, $3.00 for 1.5 QTC at $2, transaction amounts carry none, the widget shows and hides the line.
  • All affected test files pass: swap service, exchange rate, amount input, home gating, send amount, review send, swap flow.

QTC's USD price is the one 1Click lists it with, read every five minutes
with a conditional GET: the client remembers each GET's ETag, so an
unchanged listing answers 304 with no body. Reading the listed QTC no
longer costs the CoinGecko ranking, which only the swap token list
needs. The exchange rate service carries the price as nullable and
refuses to convert without one, so the fiat line under the balance only
appears once a real price is known, and the hide toggle masks it too.
@n13 n13 added the bot-review Request automated review from review-bot label Oct 9, 2026

@n13 n13 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer model: GPT-6.1 Sol

Verdict (advisory): Request changes

Reviewed head ed168eddfa1b56c98d537f7d02209446cc29321e against base a67f13b230f79b2c46f331debc55a8c703e4e686.

No other blocking findings in the price lookup, ETag handling, fiat conversion, transaction display, or hide-balance behavior.

Validation in a detached worktree:

  • SDK: flutter test --no-pub test/services/swap_service_test.dart test/services/one_click_service_test.dart — 46 passed.
  • Wallet: flutter test --no-pub with balance_fiat_line, exchange_rate_service, amount_input_logic, input_amount_max, send_amount_layout, review_send_screen, home_intent_gating, swap_flow, and transaction_detail_sheet tests — 87 passed.
  • git diff --check and dart format --output=none --set-exit-if-changed --line-length=120 on all nine changed Dart files — passed.
  • SDK analysis passed. Local wallet analysis was terminated at the required 10-second cap, so it is incomplete; the linked CI log confirms the new warning.

@n13 n13 removed the bot-review Request automated review from review-bot label Oct 9, 2026
@n13

n13 commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author

Removed the unused package:flutter/material.dart import from the balance fiat test; CI re-triggered.

n13 added 4 commits October 9, 2026 11:41
The swap list no longer asks CoinGecko for a market-cap ranking or for
token logos. It is 1Click's own listing, one asset per symbol, with QTC
moved to the top and USDC right after it; every other token keeps its
place. QTC now appears in the token picker, and picking it for the
other side moves QTC there. Token icons are the monograms the picker
already fell back to.
@n13 n13 added the bot-review Request automated review from review-bot label Oct 9, 2026
Order swap tokens as 1Click lists them, QTC first and USDC second

@n13 n13 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer model: GPT-6.1 Sol

Verdict (advisory): Approve

Reviewed head df3a68b860beb801e93f134b6dde40a1ea29d063 against base b8de5e97a04dc549ec8ebd6be46e4a7ad4ae80fe, including the merged swap-token ordering changes. No blocking findings. The unused import from the previous review is removed.

The balance waits for a listed QTC price, uses the selected fiat currency, and masks both amounts when hidden. Transaction amounts remain QTC-only. The shared listing cache and ETag revalidation preserve token identification and avoid CoinGecko requests; the swap screen selects a foreign token initially and handles QTC selection on either side consistently.

Validation in a detached worktree:

  • SDK: flutter test --no-pub test/services/swap_service_test.dart test/services/one_click_service_test.dart — 45 passed.
  • Wallet: flutter test --no-pub across balance_fiat_line, exchange_rate_service, amount_input_logic, input_amount_max, send_amount_layout, review_send_screen, home_intent_gating, swap_flow, transaction_detail_sheet, and swap_math tests — 89 passed.
  • git diff --check and dart format --output=none --set-exit-if-changed --line-length=120 on all 12 changed Dart files — passed.
  • Root Melos analysis was terminated at the required 10-second cap after cold-wallet and miner analysis passed; SDK/wallet analysis is incomplete. GitHub CI is still running, and dependency cooldown passed.

@n13 n13 removed the bot-review Request automated review from review-bot label Oct 9, 2026
@n13
n13 merged commit e7de1a7 into main Oct 9, 2026
3 checks passed
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