Add NUPL feature to block nodes#41
Merged
Merged
Conversation
… like dot in attribute keys.
VJalili
marked this pull request as ready for review
April 12, 2026 14:27
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.
Net Unrealized Profit and Loss (NUPL) is a highly informative metric for market sentiment in quant analysis. However, this feature cannot be computed using on-chain data alone, as it requires the fiat value of a UTxO's BTC at the time of its creation. Therefore, to compute this metric, two major improvements are implemented in this PR:
Retrieving UTxOs at a given block: This requires tracking when a TxO is spent, and then retrieving the ones that were created before a given block and spent after it. Because EBA processes each block independently—and tracking a spent TxO depends on inputs from other transactions and potentially other blocks—determining when a TxO is spent requires a post-initial iteration process. Once this tracking is complete, an index recording when a TxO was created and spent is necessary to find UTxOs at a given block height. Txo spending is determined post-traverse, and implemented in Resolve Txo spending post-traverse #43; this PR adds the required index.
Integrating off-chain data: The fiat value of BTC is not tracked on-chain; it is market data that requires an additional post-traversal process to integrate. This PR takes the first step in supporting off-chain data, starting with fiat values.
Leveraging these two improvements, this PR enables the computation of NUPL for every block.
Limitations
The downside of this method is that it requires multiple iterations through the edges for different tasks. This approach is extremely slow even at a relatively small scale; for context, processing 1 million edges took approximately one hour, whereas the graph at full scale contains roughly 40 billion edges.
Ideally this method should be implemented as a database server-side task (currently implemented using database drivers, that involves data transfer to client side), or on the raw data pre-bulk import. #43 implements some of the required tasks on the graph serializations before database import, which runs significantly faster than its equivalent neo4j-based queries.