Fix database price calc#604
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the price-change notification pipeline to compute and compare a token USD unit price (USD per token) rather than using a raw USD transaction amount, aligning the Go-side parsing with a new DB-side helper function.
Changes:
- Added
calculateUSDPriceFromTxEventto derive USD/token fromtoken_symbol+tx_amounttags, and switched price-change queries to compare against unit price. - Introduced SQL function
subzero_get_token_price_from_tx(tags)and updated queries to use it for the latest-trade baseline. - Extended tests to cover USD/token calculation and updated test event fixtures to include the required tags.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
database/query/query_pn_price.go |
Computes current price as USD/token and updates baseline comparisons to use subzero_get_token_price_from_tx. |
database/query/query_pn_price_test.go |
Adds unit tests for USD/token computation and updates helper events with token_symbol + token tx_amount. |
database/query/ddl/00023_pn_price_fn.sql |
Adds DB function to compute token USD unit price from event tags. |
go.mod / go.sum |
Dependency/version bumps from module update/tidy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.