fix(perps): Don't see latest funding payments in Activity#28671
fix(perps): Don't see latest funding payments in Activity#28671abretonc7s wants to merge 8 commits intomainfrom
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Automated fix-bug run — TAT-2057
Worker reportFix Report — TAT-2057: Don't see latest funding payments in ActivitySummary
Root CauseFile: The original const rawFunding = await infoClient.userFunding({
user: userAddress,
startTime: Date.now() - 365 * 24 * 60 * 60 * 1000,
endTime: undefined,
});HyperLiquid's The oscillation between two cutoff dates on consecutive refreshes was caused by Reproduction CommitSHA: Added Changes
Fix DetailDivided the 365-day range into 30-day windows (~13 chunks), fetched all in parallel via const chunks: { start: number; end: number }[] = [];
let chunkEnd = finalEndTime;
while (chunkEnd > finalStartTime) {
const chunkStart = Math.max(finalStartTime, chunkEnd - pageWindowMs);
chunks.push({ start: chunkStart, end: chunkEnd });
chunkEnd = chunkStart;
}
const pages = await Promise.all(
chunks.map((chunk) => infoClient.userFunding({ user: userAddress, startTime: chunk.start, endTime: chunk.end }))
);
const allRaw = pages.flatMap((page) => page ?? []);
allRaw.sort((a, b) => a.time - b.time);Test PlanUnit tests: Recipe validation (account 0x316BDE, 1174 records):
CI gates: lint (0 errors), lint:tsc (0 errors), format:check (pass) ✅ Evidence
TicketTAT-2057 — https://consensyssoftware.atlassian.net/browse/TAT-2057 |
…issing latest payments HyperLiquid userFunding API returns records ascending (oldest first) and caps each call at 500 records. A single 365-day window silently drops the most recent payments for accounts with >500 funding events. Replace the single call with parallel 30-day window fetches via Promise.all. Each window stays well under the cap, guaranteeing the most recent records are always present regardless of history length. Fixes TAT-2057
- Merge duplicate perps-controller imports (no-duplicate-imports) - Move PAGE_WINDOW_MS/MAX_LOOKBACK_MS to module level (exhaustive-deps) - Remove dead startTime/endTime from useCallback dep array - Apply prettier formatting to all changed files
7609ee6 to
eac26df
Compare
…nding - Fix early return guard: check cursorEndTime instead of cursorStartTime so the last partial funding window is fetched rather than silently dropped (365d / 30d = 12.17 pages; ~5 days were previously skipped) - Deduplicate transactions by id when merging in loadMoreFunding to prevent boundary-timestamp duplicates from HyperLiquid's inclusive API ranges
- Add try/catch so API rejections don't propagate as unhandled promise rejections through FlashList's fire-and-forget onEndReached callback - Add fetchGenerationRef counter bumped on every fetchAllTransactions; loadMoreFunding captures it before the await and discards results if a concurrent refresh has reset the cursor, preventing stale cursor writes and stale data being appended after pull-to-refresh
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag selection:
No other tags are affected - changes are isolated to the Perps feature with no impact on accounts, network, swaps, identity, or other wallet features. Performance Test Selection: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6d59712. Configure here.
|
✅ E2E Fixture Validation — Schema is up to date |
|



Description
Root cause
The Activity page was not showing the most recent funding payments for accounts with many open positions. `HyperLiquidProvider.getFunding()` made a single API call for the full 365-day history window; HyperLiquid's API silently caps responses at 500 records (oldest-first), so the most recent payments were dropped.
Fix
Changes
Changelog
CHANGELOG entry: Fixed missing recent perpetuals funding payments — `getFunding` now fetches the most recent 30-day window by default (1 API call) and loads older history on demand as the user scrolls, replacing the previous 365-day call that silently dropped recent records past the 500-record cap.
Related issues
Fixes: TAT-2057
Manual testing steps
Screenshots/Recordings
Recipe proof: `log_watch` confirmed `[PERPS-FUNDING] loadMoreFunding: older records loaded` fired 3× with non-zero count.
Pre-merge author checklist
Pre-merge reviewer checklist
Validation Recipe
recipe.json — automated validation script (19/19 nodes pass)
{ "pr": "28671", "title": "Verify on-demand funding history pagination — TAT-2057 follow-up", "jira": "TAT-2057", "acceptance_criteria": [ "AC1: Activity shows funding payments up to today (30-day initial window, 1 API call, isRecent=true)", "AC2: Multiple getFunding calls with same window return consistent results (no oscillation)", "AC3: Scrolling to bottom of Funding tab triggers a second fetch and loads older entries", "AC5: Refresh resets cursor and returns fresh recent data" ] }Note
Medium Risk
Changes funding history fetching and pagination behavior across provider, hook, and UI; mistakes could lead to missing/duplicated funding rows or extra API calls, but scope is limited to perps activity history.
Overview
Fixes missing recent perps funding payments by changing
HyperLiquidProvider.getFunding()to fetch a default 30-day window and, when given larger ranges, page through 30-day chunks with recursive window-splitting when the 500-record API cap is hit (plus hash-based dedup + sorting).Adds cursor-based “load more” funding pagination to
usePerpsTransactionHistory(newloadMoreFunding/hasFundingMore/isFetchingMoreFunding), resets pagination on refresh, and wires the Funding tab UI to triggerloadMoreFundingon scroll with a footer spinner (PerpsTransactionsViewSelectorsIDs.FUNDING_LOAD_MORE_SPINNER). Tests are updated/extended to cover the new funding pagination and provider chunking/splitting behavior.Reviewed by Cursor Bugbot for commit 6d59712. Bugbot is set up for automated code reviews on this repo. Configure here.