feat(hyperliquid): populate UserTrade marketId/outcomeId/fee; synthesize closed+all orders#1255
Merged
Merged
Conversation
…ize closed+all orders from fills UserTrade enrichment: - Widen UnifiedUserTrade with optional marketId, fee fields. - HL normalizeUserTrade now sets marketId, outcomeId, fee on every fill using the existing coinToMarketId / coinToOutcomeId helpers and the raw.fee field. Previously these were undefined, leaving consumers unable to tell which market a fill was on. - Verified against an active wallet (0x6476...): 2000/2000 trades now fully populated in both Python and TS SDKs. Closed + all orders: - HL has no closed-orders endpoint. Synthesize from userFills by grouping fills by oid and excluding oids that are currently open. - VWAP for the synthesized price, sum of sizes for filled/amount, sum of fees, earliest fill time as the order timestamp. - ponytail comment notes the limitation: cancelled-with-no-fills orders are not visible to the public info API and cannot be reconstructed. - fetchAllOrders = open ∪ closed. - Verified against 0x5af8... (7 open + 104 derived closed = 111 all), identical counts and sample output across Python and TS.
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.
Summary
Two HL gaps surfaced by ground-truth assertion checks against real active wallets:
UserTrade enrichment
Trade.outcomeIdand newUserTrade.marketId/UserTrade.feeare now populated by HL'snormalizeUserTradefromraw.coinandraw.fee. Previously every HL fill came back withmarketId=null,outcomeId=null,fee=null— consumers couldn't tell which market a fill was on.coinToMarketId/coinToOutcomeIdhelpers (same ones used bynormalizeOpenOrder).Closed + all orders
fetchClosedOrdersnow synthesizes by groupinguserFillsbyoidand excluding currently-open oids. VWAP price, summed size for amount/filled, summed fee, earliest fill time as timestamp.fetchAllOrders = openOrders ∪ closedOrders.ponytail:comment marks the limitation: cancelled-with-no-fills orders aren't reconstructable from the public info API.Verified (Python + TS, ground-truth against HL raw API)
Wallet
0x6476…(2000 fills): both SDKs return 2000/2000 trades with marketId / outcomeId / fee populated, identical sample.Wallet
0x5af8…(7 open, 104 unique fill-only oids):Identical on both SDKs.