Skip to content

fix: Gains position reconstruction for HL funding projection - #2213

Merged
Flotapponnier merged 2 commits into
devfrom
feat/fee-compare-fixes-v2
Aug 30, 2026
Merged

fix: Gains position reconstruction for HL funding projection#2213
Flotapponnier merged 2 commits into
devfrom
feat/fee-compare-fixes-v2

Conversation

@Flotapponnier

Copy link
Copy Markdown
Collaborator

Summary

  • Positions opened before the 90-day fetch window now use the earliest TradePosSizeIncrease as a synthetic anchor instead of being silently dropped
  • Long-running positions (opened >90 days ago) are now included in the HL funding projection with openMs = cutoffMs

Test result

Tested with wallet 0x2EF...35a2: previously projected $0 HL funding, now correctly projects $33.60 (15 positions reconstructed, 6 using increase anchor).

Why it was broken

fetchGainsTrades only fetches from startDate = cutoffMs, so open events for long-running positions are absent. The old code skipped any trade ID without an open event → entire positions dropped from projection.

@Flotapponnier
Flotapponnier merged commit 2fb8d63 into dev Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant