fix(balances): consolidate Pioneer calls on /portfolio + fix USDT-TRON#47
Merged
BitHighlander merged 1 commit intodevelopfrom Apr 24, 2026
Merged
Conversation
…etwork-ids
Two related fixes that together make TRC-20 (USDT-TRON) appear on the
dashboard for the first time.
1. One endpoint instead of two
---------------------------------
Before: the Pioneer call was split across /charts/portfolio (for
EVM/UTXO/Cosmos/TON) and /portfolio (for Solana only), with a separate
fallback for TON/TRON partial responses. /charts/portfolio is a fast
cached path backed by pre-computed charts + Zapper-provided EVM
tokens; it does NOT run Pioneer's SPL / TRC-20 / ERC-20 auto-discovery
blocks that live in balance.controller.ts. Only /portfolio
(GetPortfolioBalances) hits those — which is why the vault, which uses
/portfolio exclusively via pioneer-client, saw USDT while the BEX did
not.
Consolidated every pubkey (Solana + Tron + EVM + UTXO + Cosmos + TON
+ Ripple + THORChain) onto /portfolio in one call, matching vault's
GetPortfolioBalances flow exactly. Classification (native vs token)
uses the same rule as vault: caip path not in {slip44:, native:}
OR type === 'token' OR (isNative === false && contract).
Net: -118 lines vs. the three-batch split. Slower per call (no
pre-warm charts cache) but correct, and the user explicitly accepted
the latency trade.
2. Tron has two network-ids; alias them
------------------------------------------
Pioneer emits the native TRX balance under `tron:27Lqcw` (CAIP-2
genesis-hash convention), but TRC-20 tokens under `tron:0x2b6653dc`
(hex chain-id convention). Both refer to Tron mainnet. Pioneer's own
ChainToNetworkId declares `tron:0x2b6653dc` as canonical (vault
consumes that and works); our BEX has hardcoded `tron:27Lqcw`
throughout `chainConfig.ts` and `tronHandler.ts`. Rather than rewire
every pubkey cache entry in users' storage, alias Pioneer's response
ids at the normalizer:
NETWORK_ID_ALIASES = {
'tron:27lqcw' -> 'tron:27Lqcw' // casing
'tron:0x2b6653dc' -> 'tron:27Lqcw' // cross-convention
'solana:5eykt4...' -> 'solana:5eykt4UsFv8...' // existing Solana casing
}
Rewrites both `networkId` and the network prefix of `caip`. The
side-panel's strict `networkId === 'tron:27Lqcw'` filter now matches
both native rows and TRC-20 token rows, so USDT-TRON appears on the
Tron asset page.
Known ceiling: the canonical-id mismatch is tech debt. Switching our
BEX to `tron:0x2b6653dc` would remove the alias entry but requires a
storage migration (existing pubkey caches have `networks:
['tron:27Lqcw']`). Deferred — alias is localized and cheap.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 24, 2026
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related fixes that together make TRC-20 (USDT-TRON) appear on the dashboard for the first time, and bring the BEX's balance-fetch path in line with how the vault talks to Pioneer.
1. One endpoint instead of two
Before: pubkeys were split across two Pioneer endpoints:
Plus a `/api/v1/{ton,tron}/accountInfo` fallback for partial responses.
`/charts/portfolio` serves natives from a pre-computed cache and decorates EVM tokens via Zapper — but does not run Pioneer's SPL / TRC-20 / Unchained ERC-20 auto-discovery blocks. Those live exclusively in `/api/v1/portfolio` (`GetPortfolioBalances`). That's why the vault — which uses `pioneer.GetPortfolioBalances` for everything — sees USDT-TRON and the BEX didn't.
After: one call, `/api/v1/portfolio`, all pubkeys (Solana + Tron + EVM + UTXO + Cosmos + TON + Ripple + THORChain). Native/token classification mirrors the vault's rule (`caip path not slip44:/native:` OR `type === 'token'` OR `isNative === false && contract`). Fallback is gone — vault doesn't have one either.
Net: −118 LOC. Slower per call (no pre-warm charts cache) — user explicitly accepted the latency trade to match vault exactly.
2. Tron has two network-ids; alias them
Pioneer emits the same Tron chain under two different IDs:
Pioneer's canonical is `tron:0x2b6653dc` (that's what `pioneer-caip` / `pioneer-sdk` declare; vault consumes that and works). Our BEX has hardcoded `tron:27Lqcw` everywhere. Without a rewrite, the side-panel's strict `networkId === 'tron:27Lqcw'` filter skips every TRC-20 row.
Fix: alias at the response normalizer.
```ts
const NETWORK_ID_ALIASES = {
'tron:27lqcw': 'tron:27Lqcw', // casing
'tron:0x2b6653dc': 'tron:27Lqcw', // cross-convention
'solana:5eykt4...': 'solana:5eykt4UsFv8...' // existing Solana casing
};
```
Rewrites both `networkId` and the network prefix of `caip`. USDT-TRON now shows at the correct chain.
Known follow-up
The canonical-id mismatch is tech debt. Switching the BEX to `tron:0x2b6653dc` everywhere would drop the alias entry but requires a storage migration (existing users' pubkey caches have `networks: ['tron:27Lqcw']`). Deferred — alias is localized to one function and cheap to maintain.
Test plan
🤖 Generated with Claude Code