Skip to content

fix(perps): handle liquidation price request failures - #6547

Merged
crossle merged 1 commit into
masterfrom
fix/liquidation-price-retry-policy
Jul 30, 2026
Merged

fix(perps): handle liquidation price request failures#6547
crossle merged 1 commit into
masterfrom
fix/liquidation-price-retry-policy

Conversation

@SeniorZhai

Copy link
Copy Markdown
Member

Summary

  • retry liquidation price estimates only when the API returns error code 500
  • stop after non-500 failures and display - on open/add position screens
  • skip liquidation price requests when the entered margin is below minAmount
  • share the retry policy between both screens and cover it with unit tests

Root cause

Both position screens treated every failed estimate as a temporary failure and retried indefinitely. The ViewModel returned only a nullable price, so callers could not distinguish server errors from non-retryable failures.

User impact

Open and add-position screens no longer repeatedly request liquidation prices for non-500 errors, and invalid below-minimum amounts do not trigger the estimate API.

Validation

  • ./gradlew :app:testGooglePlayDebugUnitTest --tests one.mixin.android.ui.home.web3.trade.perps.LiquidationPriceRequestTest

Retry only 500 errors, stop polling on other failures, and skip liquidation price estimates below the minimum margin.
Copilot AI review requested due to automatic review settings July 30, 2026 08:05
@SeniorZhai
SeniorZhai marked this pull request as ready for review July 30, 2026 08:06
@SeniorZhai SeniorZhai added the bug Something isn't working label Jul 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates liquidation-price estimation to avoid unnecessary retries and invalid requests.

Changes:

  • Retry only error code 500; stop on other failures.
  • Skip estimates below the market minimum.
  • Share and unit-test retry/request policy.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
LiquidationPriceRequestTest.kt Tests retry and minimum-amount behavior.
PerpsAddBottomSheetDialogFragment.kt Applies shared policy to add-position estimates.
PerpetualViewModel.kt Returns structured estimation results.
OpenPositionPage.kt Applies minimum validation and retry handling.
LiquidationPriceRequest.kt Defines shared result and retry logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@crossle
crossle merged commit 6ed1386 into master Jul 30, 2026
2 checks passed
@crossle
crossle deleted the fix/liquidation-price-retry-policy branch July 30, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants