fix(explorer): use max instead of sum for transaction value display#712
Open
fix(explorer): use max instead of sum for transaction value display#712
Conversation
DEX swaps contain two token transfer events (input + output). The previous logic summed all amount parts, causing a $10 swap to display as $20. Using max of individual amounts correctly shows $10. Co-authored-by: kazanins <3875832+kazanins@users.noreply.github.com> Amp-Thread-ID: https://ampcode.com/threads/T-019ce654-42a6-7421-a473-bd1b8205fa84
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
DEX swap transactions show double the actual value (e.g. $10 swap displays as $20).
Motivation
A stablecoin DEX swap of $10 AlphaUSD → BetaUSD produces two token transfer events — one in, one out. The explorer sums all amount parts: $10 + $10 = $20 displayed.
Changes
apps/explorer/src/comps/TxTransactionRow.tsx— use max instead of sum foramountPartsreduceapps/explorer/src/routes/_layout/address/$address.tsx— same fix inTransactionTotalCellFor a simple send (1 amount part), behavior is unchanged. For swaps (2 amount parts), the max correctly shows the value of one side.
Testing
pnpm --filter explorer checkpasses (lint + types)Prompted by: jev