This repository was archived by the owner on Aug 7, 2026. It is now read-only.
fix: evaluated positive or negative balanceDiff to put transactions in from or to - #632
Closed
gabrieledm wants to merge 2 commits into
Closed
Conversation
… in 'from' or 'to'
from or tobalanceDiff to put transactions in from or to
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
7 tasks
Contributor
|
May worth to add a changelog fixed entry in |
|
10 tasks
Author
|
Replaced by: MetaMask/internal-snaps#108 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.



Description
Fixes incorrect transaction direction and type detection when the fee payer receives an amount of SOL that is less than or equal to the transaction fee.
Previously, native transfer direction was determined using the raw pre and post transaction balances.
For a USDC-to-SOL swap, the fee payer’s balance can still decrease when the received SOL is smaller than the fee.
This caused the incoming SOL to be classified as outgoing and could prevent the transaction from being identified as a swap.
The mapper now determines direction from the fee-adjusted balance difference:
Fixes MetaMask/metamask-extension#43164
Changes
Testing
Before
WPN-1223.Before.mov
After
WPN-1223.After.mp4
Note
Medium Risk
Changes transaction type/direction logic for all native SOL balance parsing in activity; wrong edge cases could misclassify sends, receives, or swaps.
Overview
Fixes Solana activity mislabeling small USDC→SOL swaps as sends when the fee payer’s net SOL change is dominated by the transaction fee.
TransactionMappernow classifies native SOL movement from the fee-adjusted balance difference (pre − post − feefor the fee payer): positive →from, negative →to, zero → skip (fee-only, not a transfer). Direction no longer uses raw pre/post balances alone.Tests add a
withTransactionMapperhelper and cover incoming SOL at fee boundaries, fee-only txs, and SPL→SOL swap classification; one swap fixture expectation is updated for correct SOL leg ordering. Changelog and snap manifest shasum are updated.Reviewed by Cursor Bugbot for commit 0895f9d. Bugbot is set up for automated code reviews on this repo. Configure here.