Test functions#1
Open
avernikoz wants to merge 6 commits into
Open
Conversation
avernikoz
commented
Aug 20, 2025
- add create_order_info_for_tests test func
- make functions public (remove (package)) for bm and pool tests
…move (package)) for bm and pool tests
bathord
pushed a commit
that referenced
this pull request
Mar 14, 2026
* feat: add portfolio endpoint for margin wallet overview Adds GET /portfolio/:wallet_address endpoint that returns a comprehensive margin portfolio view including positions, collateral, and LP balances with real-time USD valuations. * fix: address claude review comments on portfolio endpoint - Add wallet address format validation (0x prefix + 64 hex chars) - Increment db_requests_failed metric on query errors - Fix LP query to filter on supplier (indexed) instead of sender (unindexed), using margin_manager_created join to resolve wallet -> balance_manager_id; uses existing idx_asset_supplied_supplier / idx_asset_withdrawn_supplier - Remove spurious + 0.0 in PortfolioSummary construction - Add comment explaining LIKE asset_id suffix matching pattern - Consolidate row struct definitions above queries for readability * fix: revert LP query sender->supplier change, document missing index The supplier column in asset_supplied/asset_withdrawn stores the SupplierCap NFT object ID, not the balance_manager_id. The join through margin_manager_created.balance_manager_id produced zero results. Revert to filtering on sender (wallet address) which is correct, and add a comment noting that sender lacks an index — a follow-up migration should add idx_asset_supplied_sender and idx_asset_withdrawn_sender. * fix: address SQL linter findings in portfolio queries - Guard am.decimals against NULL with COALESCE(am.decimals, 9) in collateral query division (linter: division without zero guard) - Document intentional UNION dedup in asset_meta CTE (linter: UNION vs UNION ALL) * fix: address PR review comments #1, #2, #5, #6 - Fix metrics accounting: increment per-query (3 succeeded on full success) instead of 1, consistent with rest of codebase - Add hex character validation to wallet address check - Add TODO for LIKE '%...' pattern preventing index use on balances.asset - Move row structs (MarginPositionRow, CollateralRow, LpPositionRow) to module level, consistent with OhclvRow * fix: remove lp.price_usd from GROUP BY, use short diesel type aliases - Remove lp.price_usd from collateral query GROUP BY clause. It is functionally dependent on am.symbol (already in GROUP BY) and could produce phantom duplicate rows if latest_prices returns NULL. - Switch row struct diesel annotations from fully qualified paths (diesel::sql_types::Text) to imported short aliases (Text, Double, BigInt) for consistency with OhclvRow.
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.