Skip to content

Remove v1 token-prices fallback - #1052

Merged
JakeUrban merged 3 commits into
mainfrom
claude/nifty-pasteur-a5ekw1
Nov 10, 2026
Merged

JakeUrban merged 3 commits into
mainfrom
claude/nifty-pasteur-a5ekw1

Conversation

@JakeUrban

@JakeUrban JakeUrban commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What

The app gets token prices only from freighter-backend-v2. This PR removes the v1 /token-prices path and the use_token_prices_v2 feature flag.

Functional changes:

  • fetchTokenPrices always sends POST /token-prices to freighter-backend-v2 with the network query param. It does not call freighterBackendV1 for prices anymore.
  • fetchTokenPrices does not take a useV2 argument anymore. The native-ID translation (XLM to native and back) now always runs.
  • The prices store does not track which endpoint filled each network cache. sourceByNetwork and reconcileSource are removed. A response is not dropped because of a flag change anymore.
  • The Amplitude flag use_token_prices_v2 has no effect. The app does not read it. It is removed from remote config, from the price callers (balances, account fiat totals, swap, send, Blockaid balance list) and from the confirmation snapshot.
  • The confirmation price snapshot always reports priceSource: "token_prices_v2". The value does not change for users on the default path, so dashboards keep working.

These items do not change:

  • LP shares are still removed from the request.
  • Contract (SEP-41) tokens are still sent.
  • Only mainnet gets prices. Testnet and futurenet still skip the request.
  • Other v1 calls (balances, simulate, submit, Blockaid, token details) do not change. The use_balances_v2 flag is not touched.

Why

The v1 token price service on freighter-backend is not healthy. Repair is not useful, because v2 replaces it. The flag defaults to v2, so users on current versions do not use v1.

Known limitations

After this change, a rollback to v1 prices through Amplitude is not possible. Old app versions that do not have the flag still call v1. This PR cannot change that.

Screenshots / video

N/A. There is no UI change.

Before After
N/A N/A

Checklist

PR structure

  • This PR does not mix refactoring changes with feature changes (break it down into smaller PRs if not).
  • This PR has reasonably narrow scope (break it down into smaller PRs if not).
  • This PR includes relevant before and after screenshots/videos highlighting these changes. (No UI change.)
  • I took the time to review my own PR.

Testing

  • These changes have been tested and confirmed to work as intended on Android.
  • These changes have been tested and confirmed to work as intended on iOS.
  • These changes have been tested and confirmed to work as intended on small iOS screens.
  • These changes have been tested and confirmed to work as intended on small Android screens.
  • I have tried to break these changes while extensively testing them.
  • This PR adds tests for the new functionality or fixes. (Tests for the v1 path and the rollback cache logic are removed. The v2 tests stay.)

Release

  • This is not a breaking change.
  • This PR updates existing JSDocs when applicable.
  • This PR adds JSDocs to new functionalities.
  • I've checked with the product team if we should add metrics to these changes.
  • I've shared relevant before and after screenshots/videos highlighting these changes with the design team and they've approved the changes.

Checks run locally: tsc --noEmit passes. Jest: 345 suites pass. 2 suites fail: __tests__/config/theme.test.ts and __tests__/scripts/stellar-testnet.test.ts. They fail on main too. The cause is the local install, which skipped native builds such as sharp.

Companion PR for the extension: stellar/freighter#3078

Follow-up after release: archive use_token_prices_v2 in Amplitude. Then remove the v1 price worker and /token-prices route in freighter-backend.

🤖 Generated with Claude Code

https://claude.ai/code/session_01R8cp3zUn1aPP4zQrPvEFDQ

The app now gets token prices only from freighter-backend-v2. The v1
/token-prices path on freighter-backend is removed, together with the
use_token_prices_v2 feature flag that selected it.

- fetchTokenPrices no longer takes a useV2 argument.
- The prices store no longer tracks which endpoint filled its cache.
- Remove the flag from remote config and from all callers.
- The confirmation price snapshot always reports token_prices_v2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01R8cp3zUn1aPP4zQrPvEFDQ

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Active issues remain: a misleading comment needs correction, and missing reset-generation guards allow stale in-flight price responses to repopulate cleared or newly selected account data.

2 open issues
What changed in this PR

This PR completes the migration of mobile token-price requests to freighter-backend-v2 by removing the v1 fallback, endpoint-selection flag, and source-specific cache bookkeeping while preserving network scoping, native-token translation, contract-token support, and confirmation analytics compatibility.

Changes:

  • Routes all token-price requests through the v2 network-scoped endpoint.
  • Removes the use_token_prices_v2 flag and related caller dependencies.
  • Updates price state, confirmation snapshots, consumers, and tests for v2-only pricing.
File Description
src/​services/​backend.ts Makes freighter-backend-v2 the sole token-price endpoint and removes the endpoint-selection parameter.
src/​hooks/​blockaid/​useTransactionBalanceListItems.tsx Removes the token-price feature-flag dependency from Blockaid balance price fetching.
src/​helpers/​confirmationPriceSnapshot.ts Makes confirmation price snapshots consistently report the v2 price source.
src/​ducks/​remoteConfig.ts Removes the token-price endpoint feature flag from remote configuration.
src/​ducks/​prices.ts Removes endpoint-source tracking and simplifies the price-fetching actions and state.
src/​ducks/​balances.ts Stops passing the removed token-price endpoint flag when fetching balance prices.
src/​ducks/​auth.ts Updates account-clearing price state after endpoint-source tracking removal.
src/​ducks/​accountsFiatTotals.ts Updates account fiat-total price fetching for the v2-only pricing flow.
src/​components/​screens/​SwapScreen/​hooks/​useSwapTransaction.ts Removes the token-price endpoint flag from swap confirmation snapshot construction.
src/​components/​screens/​SwapScreen/​hooks/​useSwapTokenPrices.ts Removes feature-flag subscription and arguments from swap price fetching.
src/​components/​screens/​SwapScreen/​helpers/​swapTokenHelpers.ts Updates token-price endpoint documentation and malformed-token handling commentary.
src/​components/​screens/​SendScreen/​screens/​TransactionAmountScreen.tsx Removes the token-price endpoint flag from send confirmation snapshot construction.
tests/​services/​backend.test.ts Updates backend pricing tests for v2-only requests and behavior.
tests/​helpers/​confirmationPriceSnapshot.test.ts Updates confirmation snapshot inputs and expected v2 source values.
tests/​ducks/​prices.test.ts Updates price-store tests and removes endpoint-source and rollback-specific cases.
tests/​ducks/​balances.test.ts Updates balance-store price mocks for the simplified fetch API.
tests/​ducks/​auth.test.ts Updates account-clearing expectations after price-source state removal.
tests/​ducks/​accountsFiatTotals.test.ts Updates account-total pricing expectations and mocks.
tests/​components/​screens/​SwapScreen/​useSwapTransaction.test.ts Updates swap transaction remote-configuration mocks.
tests/​components/​screens/​SwapScreen/​SwapAmountScreen.test.tsx Updates swap pricing mocks and fetch expectations.
tests/​components/​screens/​SendScreen/​screens/​TransactionAmountScreen.test.tsx Updates send-screen remote-configuration mocks.
tests/​components/​screens/​HomeScreen.test.tsx Updates Home screen price-store mocks after source-cache removal.

Review effort: Lite

Comment thread src/ducks/prices.ts Resolved
Comment thread src/ducks/accountsFiatTotals.ts Resolved
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

iOS Simulator preview build is ready: https://github.com/stellar/freighter-mobile/releases/tag/untagged-d6c54c0d75655dca3708
Backend: V1 prod + V2 staging (no sandbox configured for @JakeUrban). SDF collaborators only — install instructions in the release description.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Android Emulator preview APK is ready: https://github.com/stellar/freighter-mobile/releases/tag/untagged-6fb4123fe2c973294433
Backend: V1 prod + V2 staging (no sandbox configured for @JakeUrban). SDF collaborators only — install instructions in the release description.

The removed endpoint check also dropped in-flight price responses
after clearAccountData. Without it, a late response can write the
old account's prices back into the cleared store.

- Add a reset action to the prices store. It clears the data and
  advances a reset generation.
- Both fetch actions compare the generation after the request and
  drop the response when a reset happened.
- clearAccountData calls the reset action.
- Correct a comment that said the prices backend rejects contract
  tokens on v2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01R8cp3zUn1aPP4zQrPvEFDQ

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A critical race condition can repopulate cleared balance data from a previous account, and a clarity issue remains in the related comment.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Low severity Clarify which malformed XLM identifier the endpoint cannot price

src/​components/​screens/​SwapScreen/​helpers/​swapTokenHelpers.ts:26

This sentence is grammatically incomplete and makes the identifier being rejected unclear. Please retain the concrete subject so the comment remains understandable, e.g. say that the endpoint cannot price this malformed XLM: identifier and that it does not match the balance-side XLM key.

2 resolved since last review

Review effort: Lite

Comment thread src/ducks/prices.ts Resolved
Comment thread src/ducks/prices.ts
// it was in flight (see fetchPricesForBalances for the rationale).
if (get().sourceByNetwork[network] !== useV2) return false;
// Drop a response for a request that started before a reset.
if (generation !== resetGeneration) return false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this meant to cover stale quotes or prices from before an account switch? The comment at the top makes it sound like that latter - "the guard keeps the old account's prices out of the cleared store.

I think there is no difference in prices across accounts and the overlap between two requests would be a tiny window and rarely overlap. This can also result in a re-paint where the UI briefly shows -- for funded rows if fetchPricesForTokenIds is in flight while the user changes accounts.

@JakeUrban
JakeUrban merged commit 1c321b2 into main Nov 10, 2026
37 checks passed
@JakeUrban
JakeUrban deleted the claude/nifty-pasteur-a5ekw1 branch November 10, 2026 23:48
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.

4 participants