Skip to content

fix: 1yr Gains lookback for accurate HL funding projection - #2214

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

fix: 1yr Gains lookback for accurate HL funding projection#2214
Flotapponnier merged 3 commits into
devfrom
feat/fee-compare-fixes-v3

Conversation

@Flotapponnier

Copy link
Copy Markdown
Collaborator

Summary

Fetch 1 year of Gains history specifically for position reconstruction, separate from the 90-day fee accounting window.

Why

Positions opened >90 days ago had their open events outside the fetch window. With only POSSIZEINCREASE events visible, the reconstruction underestimated notional and duration. Now we fetch from 1 year back, find the actual open timestamps, and still cap openMs to cutoffMs so only carry within the analysis window is projected.

Test result (wallet 0x2EF...35a2)

Version Positions reconstructed Projected HL funding
Before (broken) 0 $0
v2 fix (increase anchor) 15 $33.60
v3 fix (1yr lookback) 57 $155.96

The wallet has positions opened 200+ days ago — none were captured before.

@Flotapponnier
Flotapponnier merged commit e7037ef into dev Aug 30, 2026
1 check failed
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