-
Notifications
You must be signed in to change notification settings - Fork 2
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(#328): my trades implementation #337
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: filter out irrelevant swaps from pindexer | ||
const { data, isLoading, error } = useLatestSwaps(subaccount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: pindexer might return 2+ swaps per asset pair and a block height. Only one swap must be filtered out to match the user's swap. Might need some help do to 2+ swaps in the same block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it’s almost there! I left some comments with observations specific to my wallet
return []; | ||
} | ||
|
||
// Two requests to get swaps in both directions: buy and sell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK – rendering both swap directions of the pair.
* Combines the list of pair:height combinations into a list of unique pairs with all heights in a merged array. | ||
* This transformation is needed to reduce the amount of database queries. | ||
*/ | ||
const adaptBody = (body: MyExecutionsRequestBody[]): ExecutionCollection[] => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK – taking the mapped swap objects and transforming them into a form more amenable for efficient pindexer querying.
![Screenshot 2025-02-04 at 8 47 35 PM](https://private-user-images.githubusercontent.com/70081547/409833185-0718d983-d61e-4919-9e49-52792a246634.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNDQ4MzcsIm5iZiI6MTczOTM0NDUzNywicGF0aCI6Ii83MDA4MTU0Ny80MDk4MzMxODUtMDcxOGQ5ODMtZDYxZS00OTE5LTllNDktNTI3OTJhMjQ2NjM0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDA3MTUzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM0ZjgxMzIyZDJjYzEyYzgwMGJiNDZkMTMwZjYxODY2NDJkYmU4YjEzNmQwNmE5ZTMyN2NmNjk2NjRiYjgwOTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.A5pDMPES_Z88BJeWZ5V9N7gP2-MnBThC6STuC0rS6Zc)
const [registry, sellStream, buyStream] = await Promise.all([ | ||
registryClient.remote.get(chainId), | ||
Promise.all(data.map(data => pindexer.myExecutions(data.base, data.quote, data.heights))), | ||
Promise.all(data.map(data => pindexer.myExecutions(data.quote, data.base, data.heights))), | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment:
myTradesQuery
is returning 52 results for UM <> USDC pair (out of 64 swaps stored in IndexedDB).
![Screenshot 2025-02-04 at 7 52 22 PM](https://private-user-images.githubusercontent.com/70081547/409833718-15a00de2-b32e-4a08-8ef3-299ad814dc17.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNDQ4MzcsIm5iZiI6MTczOTM0NDUzNywicGF0aCI6Ii83MDA4MTU0Ny80MDk4MzM3MTgtMTVhMDBkZTItYjMyZS00YTA4LThlZjMtMjk5YWQ4MTRkYzE3LnBuZz9YLUFtei1BbGdvcml0aG09QV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U2lnbmVkSGVhZGVycz1ob3N0In0.cFJ23YQ3o3geXKf7EBeRMNAWGh48rwFBfJftr-K9O98)
myExecutionsQuery
then sends the mapped swap objects to the server endpoint (/api/my-executions
).
![Screenshot 2025-02-04 at 8 54 13 PM](https://private-user-images.githubusercontent.com/70081547/409834272-582dcf0d-d19a-4b32-89bf-35f0e0d9c278.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNDQ4MzcsIm5iZiI6MTczOTM0NDUzNywicGF0aCI6Ii83MDA4MTU0Ny80MDk4MzQyNzItNTgyZGNmMGQtZDE5YS00YjMyLTg5YmYtMzVmMGUwZDljMjc4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDA3MTUzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE3YTQ1MWExOGRmYWFiNWM5MTBlMjhjOWUzZGRhNzJkYTQwOWU5YTM4N2Y2ZjUwMDBiYTRkZTM4MjdlYmVhNzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.E9NBNxfjouhO_FLF29gkPAKmSNpkGBoqmYBHTsfvpN8)
- The server then queries pindexer which filters these results down to only 5 swaps, which isn't correct. I think this is pointing to an incorrect SQL query.
![Screenshot 2025-02-04 at 8 46 18 PM](https://private-user-images.githubusercontent.com/70081547/409834852-4ee741f3-5039-4892-b93a-1656a280d350.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNDQ4MzcsIm5iZiI6MTczOTM0NDUzNywicGF0aCI6Ii83MDA4MTU0Ny80MDk4MzQ4NTItNGVlNzQxZjMtNTAzOS00ODkyLWI5M2EtMTY1NmEyODBkMzUwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDA3MTUzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTViYjdhMGViZDFmZjU2YjVlZDdlNTU4MmFkOTA4OTQ3NmRjMzdhZDM0YzcwNjkwNGVlOWM0ZWZkNjk2NmU1OGUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.niP8eaY-QpVIu0_IJZwIIm0d0l5Ybgm_mEJpJzPXSq4)
![Screenshot 2025-02-04 at 7 52 14 PM](https://private-user-images.githubusercontent.com/70081547/409834874-6a34c73e-04cd-444a-867f-f7fb358498fc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNDQ4MzcsIm5iZiI6MTczOTM0NDUzNywicGF0aCI6Ii83MDA4MTU0Ny80MDk4MzQ4NzQtNmEzNGM3M2UtMDRjZC00NDRhLTg2N2YtZjdmYjM1ODQ5OGZjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDA3MTUzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ3NmFkYzNmZTA3NjdlMjk5ZDAzMDljOTdlMWQ4NGQ5MDAxNDk0Nzc4ZTIyMzdlZjI2ODQyY2FmNjM2OTg1N2UmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.qmnbO2nq0_x8ET-MoHzwq9do-4bo44QI5PcHo_Kt3yc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TalDerei this might be related to the issue with pindexer not storing (or losing) some swaps, discussed in the protocol chat. Same happens to me with old swaps, the new ones should work fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TalDerei this might be related to the issue with pindexer not storing (or losing) some swaps, discussed in the protocol chat. Same happens to me with old swaps, the new ones should work fine
I see, linked this discussion in that thread
@TalDerei I did a major refactor to the SQL query. Now it sends only 1 request to Pindexer instead of multiple ones and uses only Postgres features to perform the checks:
An important recent change: now the merge happens not only by pair and height, but also by the |
reviewed the diff, and I think these changes generally make sense to me. I'll spend some time investigating our missing data issue. update: I personally haven't found the culprit, and pindexer is now returning zero swap information for me. |
@VanishMax what happens if the user has more swaps than we can display in the page? will it overflow the rendering? |
@TalDerei good point, I added the limit of 10 swaps, can be adjusted any time. Also, sorted by time desc |
found an issue with amount filtering – should've filtered by |
Thanks, will do a round of review as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to be rendering recent trades, and we can circle back and iterate on why historical swaps aren't displayed. great work 👍
We will want to harden the virtual table query, and carve out some time to iron out the kinks as they come up. Nice work |
Closes #328 #327
Waits for penumbra-zone/web#2019 and then Prax release
Considerations of this PR:
/api/my-executions
is a POST method that accepts a possibly large body + AssetIds instead of symbols to not search for it in the registry and save timeuseLatestSwaps
hook requests data in a pipeline, from Prax first, then from Pindexer/api/my-executions
will not be made to save timemy-trades.mp4
Before running: install local version of the
protobuf
package