feat(wallet): support margin adjustments and maximum earn apy - #6679
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Fragment recreation breaks adjustment callbacks, and reduction confirmation omits its liquidation-risk warning.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds perpetual-position margin adjustments and displays maximum Earn APY on wallet cards.
Changes:
- Adds add/reduce-margin flows, API integration, history support, and confirmation UI.
- Displays maximum APY for Earn accounts.
- Adds localized resources, icons, and tests.
File summaries
| File | Description |
|---|---|
WalletHomeEarnAccountTest.kt |
Tests maximum APY calculation. |
WalletHomeCashAccountTest.kt |
Tests legacy cache compatibility. |
WalletHomeAccountStateTest.kt |
Updates Earn account fixture. |
PerpsMarginAmountTest.kt |
Tests margin calculations and validation. |
PerpsOrderDaoTest.kt |
Tests margin-order history queries. |
OpenOrderRequestTest.kt |
Tests adjustment serialization. |
values/strings.xml |
Adds English UI strings. |
values-zh-rTW/strings.xml |
Adds Traditional Chinese strings. |
values-zh-rCN/strings.xml |
Adds Simplified Chinese strings. |
values-ru/strings.xml |
Adds Russian strings. |
values-ms/strings.xml |
Adds Malay strings. |
values-ko/strings.xml |
Adds Korean strings. |
values-ja/strings.xml |
Adds Japanese strings. |
values-in/strings.xml |
Adds Indonesian strings. |
values-es/strings.xml |
Adds Spanish strings. |
ic_perps_reduce_position.xml |
Adds reduce-position icon. |
ic_perps_reduce_margin.xml |
Adds reduce-margin icon. |
ic_perps_add_position.xml |
Adds add-position icon. |
ic_perps_add_margin.xml |
Adds add-margin icon. |
WalletHomeEarnAccount.kt |
Calculates and formats maximum APY. |
WalletHomeAccountCards.kt |
Displays Earn APY badges. |
PositionDetailPage.kt |
Supports margin-order details. |
PerpsMarketDetailPage.kt |
Opens the adjustment menu. |
PerpsMarginBottomSheetDialogFragment.kt |
Implements margin adjustment UI and submission. |
PerpsMarginAmount.kt |
Provides margin calculation helpers. |
PerpsConfirmBottomSheetDialogFragment.kt |
Supports add-margin payment confirmation. |
PerpsCloseBottomSheetDialogFragment.kt |
Reuses confirmation flow for margin reduction. |
PerpsAdjustBottomSheetDialogFragment.kt |
Adds the adjustment action menu. |
PerpsAddBottomSheetDialogFragment.kt |
Refreshes position data and updates previews. |
PerpetualViewModel.kt |
Exposes margin adjustment API. |
OpenedOrderItem.kt |
Displays margin orders in history. |
InputTextField.kt |
Prevents invalid local input state. |
PerpsOrderDao.kt |
Includes margin orders in queries. |
RouteService.kt |
Defines the margin endpoint. |
PerpsOrder.kt |
Adds margin order types. |
OpenOrderRequest.kt |
Defines the adjustment request model. |
Review details
Suppressed comments (1)
app/src/main/java/one/mixin/android/ui/home/web3/trade/perps/PerpsCloseBottomSheetDialogFragment.kt:580
- The reduction amount survives recreation in fragment arguments, but this callback does not. A restored confirmation therefore reaches
showVerifyPinThenClose()withonMarginConfirmed == nulland showsData_error, preventing the user from confirming. Route the result via Fragment Result/shared state, or let this dialog submit from its persisted arguments.
private var onMarginConfirmed: (() -> Unit)? = null
fun setOnMarginConfirmed(callback: () -> Unit): PerpsCloseBottomSheetDialogFragment {
onMarginConfirmed = callback
return this
- Files reviewed: 36/36 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+47
to
+49
| var onAddMargin: (() -> Unit)? = null | ||
| var onReduceMargin: (() -> Unit)? = null | ||
| var onAddPosition: (() -> Unit)? = null |
Comment on lines
+422
to
+435
| if (isReduceMargin) { | ||
| Text( | ||
| text = stringResource(R.string.Amount).uppercase(), | ||
| color = MixinAppTheme.colors.textRemarks, | ||
| fontSize = 14.sp, | ||
| ) | ||
| Spacer(modifier = Modifier.height(8.dp)) | ||
| Text( | ||
| text = formatPerpsExactUsdDecimal(estimatedReceive), | ||
| color = MixinAppTheme.colors.textPrimary, | ||
| fontSize = 16.sp, | ||
| ) | ||
| Spacer(modifier = Modifier.height(20.dp)) | ||
| } |
* fix(wallet): align cash and earn account card styles * fix(wallet): stack cash and earn account cards * fix(wallet): keep account cards side by side
# Conflicts: # app/src/main/res/values-zh-rCN/strings.xml # app/src/main/res/values/strings.xml
SeniorZhai
force-pushed
the
feat/adjust-perps-margin
branch
from
September 18, 2026 08:17
b682617 to
f8eb970
Compare
SeniorZhai
force-pushed
the
feat/adjust-perps-margin
branch
from
September 22, 2026 09:11
d4f0bd1 to
b7d8f5d
Compare
SeniorZhai
force-pushed
the
feat/adjust-perps-margin
branch
from
September 22, 2026 13:20
b7d8f5d to
c9a155e
Compare
SeniorZhai
force-pushed
the
feat/adjust-perps-margin
branch
from
September 28, 2026 05:26
49e0ff7 to
6e34200
Compare
Restrict PerpsOrderDao.getLatestUpdatedAt() to terminal statuses (filled/rejected/closed) so processing orders no longer advance the sync cursor, label PnL as "unrealized PnL" across locales, and add a DAO test covering the behaviour.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.