Skip to content

fix: HL funding projection accuracy - #2216

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

fix: HL funding projection accuracy#2216
Flotapponnier merged 2 commits into
devfrom
feat/fee-compare-funding-fix

Conversation

@Flotapponnier

Copy link
Copy Markdown
Collaborator

Bugs fixed

1. Math.max(0, cost) in computeHlFunding
The cross-sim was ignoring funding received (negative cost). If your Gains positions would have received funding on HL, the projection was showing $0 instead of a negative number. This made HL look artificially expensive. Now the projection is signed (positive = paid, negative = received).

2. PONS in coinsToFetch
When building the list of coins to fetch HL funding history for, we were including Gains-exclusive coins (e.g. PONS) which don't exist on HL. This wasted an API call and a slot in the 6-coin cap, potentially missing actual HL-comparable coins.

3. 6-coin cap too restrictive
Raised to 20. A wallet trading 7+ distinct coins would miss funding history for the extra ones.

4. Position reconstruction includes non-HL coins
reconstructGainsPositions now only receives positions for HL-available coins, matching the fee accounting logic.

5. fundingProjected flag not handling negative funding
hlFunding > 0.01Math.abs(hlFunding) > 0.01

Test result (before vs after)

Before After
HL funding projection $189.29 (only paid) $160.17 (signed net)
PONS in coin fetch yes (wasted slot) no
Coin limit 6 20

@Flotapponnier
Flotapponnier merged commit b30332d 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