Skip to content

Conversation

@mihoward21
Copy link
Contributor

Summary

  • Fixes getUserEarningsByContract returning empty activeBalances when users have balances in the warehouse (v2)
  • The top-level activeBalances now correctly includes both splitmain and warehouse balances, matching getUserEarnings behavior

Root Cause

The getUserEarningsByContract method used contractEarnings[contract].internalBalances for activeBalances, 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

  • Modified _getUserBalancesByContract to also return the user's aggregated splitmainBalances and warehouseBalances
  • Updated getUserEarningsByContract to use mergeFormattedTokenBalances to combine these for the top-level activeBalances

Limitation

Per-contract activeBalances in earningsByContract still 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

  • Build passes (pnpm run lerna-build)
  • Lint passes (pnpm run eslint)
  • Manual verification with the test script from PE-5857 (using address 0xBB338D474184297b1F38025CAB983bfe9Cf7Fc12)

Fixes PE-5857

🤖 Generated with Claude Code

The getUserEarningsByContract method was returning empty activeBalances
because it only used per-contract internalBalances (splitmain balances).
The subgraph doesn't track warehouse balances at the per-contract level,
so these were missing from the aggregate.

Root cause: formatContractEarnings used contractEarnings[contract].internalBalances
for activeBalances, but this only contains SplitMain (v1) balances. Warehouse
balances (v2) are only available at the user level, not per contract.

Fix: Modified _getUserBalancesByContract to also return the user's aggregated
splitmainBalances and warehouseBalances. Updated getUserEarningsByContract to
use mergeFormattedTokenBalances to combine these for the top-level activeBalances,
matching the behavior of getUserEarnings.

Note: Per-contract activeBalances in earningsByContract still only includes
splitmain balances due to subgraph schema limitations. This is documented
in the code comments.

Fixes PE-5857

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Jan 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
splits-kit Ready Ready Preview Jan 8, 2026 4:48am

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.

2 participants