fix(perps): potential rate limit on close positions cp-7.63.0 cp-7.64.0 cp-7.62.2#25438
Merged
fix(perps): potential rate limit on close positions cp-7.63.0 cp-7.64.0 cp-7.62.2#25438
Conversation
Contributor
|
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. |
michalconsensys
previously approved these changes
Jan 30, 2026
aganglada
approved these changes
Jan 30, 2026
Contributor
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.


Description
Complete the 429 rate limiting fix for position management operations. The previous fix (commit
425beaead7) only addressedupdatePositionTPSL(). This PR extends the fix toclosePosition(),closePositions(), andupdateMargin()methods.Problem: These methods were using
skipCache: truewhich forced REST API calls on every operation, leading to 429 rate limiting errors during prolonged app usage.Solution:
skipCache: truefromclosePositions()andupdateMargin()to use WebSocket cacheclosePosition(), add optionalpositionparameter so callers can pass the live WebSocket position directly, avoiding the need to fetch positions entirelyusePerpsClosePositionhook to pass the position it already hasChangelog
CHANGELOG entry: Fixed rate limiting errors (429) when closing positions or updating margin after prolonged app usage
Related issues
Fixes: Rate limiting issues during position close/margin update operations
Manual testing steps
Screenshots/Recordings
Before
N/A - Bug fix for rate limiting, no UI changes
After
N/A - Bug fix for rate limiting, no UI changes
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches perps position-management flows (
closePosition,closePositions,updateMargin) and changes them to rely on cached/WebSocket position data, which could surface edge cases if the cache is stale or mismatched, but does not alter core order-placement logic.Overview
Reduces 429 errors in perps position management by stopping forced REST position refreshes during
closePositionsandupdateMargin, and by updatingclosePositionto accept an optional livepositionpayload (with a cache-based fallback).Updates
usePerpsClosePosition(and its tests) to pass the already-available position through, avoiding extragetPositions()calls during close flows.Written by Cursor Bugbot for commit ccfc17e. This will update automatically on new commits. Configure here.