Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): calculate cumulative balances when parsing Solana transactions #5062

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

AntonioVentilii
Copy link
Collaborator

Motivation

The redeemed SOL value of a Solana closeAccount transaction is not explicitly indicated in the transaction data. So it must be inferred/calculated from the latest SOL balance of the ATA that is being closed.

After PR #5056 , we can provide the accumulated balances to the mapper.

To calculate them we keep a record in the reduce function: every instruction inside a generic transaction will affect the cumulative SOL balance of each address.

It is guaranteed to be progressive since the RPC returns the list of instructions in the correct internal chronological order.

The redeemed SOL value is the latest total SOL balance of the closed Associated Token Account.

NOTE: We include WSOL in the calculation, because it is used to affect the SOL balance of the ATA.

Changes

Tests

Apart from expanding the current tests, we verified with a practical transaction comparing our results with Solscan.

Screenshot 2025-03-06 at 22 40 33
Screenshot 2025-03-06 at 22 41 56

@AntonioVentilii AntonioVentilii requested a review from a team as a code owner March 6, 2025 22:26
@AntonioVentilii AntonioVentilii marked this pull request as draft March 6, 2025 22:26
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