Fix activeBalances in getUserEarningsByContract #89
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
getUserEarningsByContractreturning emptyactiveBalanceswhen users have balances in the warehouse (v2)activeBalancesnow correctly includes both splitmain and warehouse balances, matchinggetUserEarningsbehaviorRoot Cause
The
getUserEarningsByContractmethod usedcontractEarnings[contract].internalBalancesforactiveBalances, but this only contains SplitMain (v1) balances. The subgraph schema doesn't track warehouse balances at the per-contract level, so these were missing from the aggregate.Fix
_getUserBalancesByContractto also return the user's aggregatedsplitmainBalancesandwarehouseBalancesgetUserEarningsByContractto usemergeFormattedTokenBalancesto combine these for the top-levelactiveBalancesLimitation
Per-contract
activeBalancesinearningsByContractstill only includes splitmain balances due to subgraph schema limitations. This is documented in code comments. A future subgraph update would be needed to provide warehouse balances per contract.Test plan
pnpm run lerna-build)pnpm run eslint)0xBB338D474184297b1F38025CAB983bfe9Cf7Fc12)Fixes PE-5857
🤖 Generated with Claude Code