Skip to content

feat(wallet): support margin adjustments and maximum earn apy - #6679

Merged
crossle merged 39 commits into
masterfrom
feat/adjust-perps-margin
Sep 28, 2026
Merged

crossle merged 39 commits into
masterfrom
feat/adjust-perps-margin

Conversation

@SeniorZhai

Copy link
Copy Markdown
Member

No description provided.

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.

🟡 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() with onMarginConfirmed == null and shows Data_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))
}
@SeniorZhai
SeniorZhai force-pushed the feat/adjust-perps-margin branch from b682617 to f8eb970 Compare September 18, 2026 08:17
@SeniorZhai
SeniorZhai force-pushed the feat/adjust-perps-margin branch from d4f0bd1 to b7d8f5d Compare September 22, 2026 09:11
@SeniorZhai
SeniorZhai force-pushed the feat/adjust-perps-margin branch from b7d8f5d to c9a155e Compare September 22, 2026 13:20
@SeniorZhai
SeniorZhai force-pushed the feat/adjust-perps-margin branch from 49e0ff7 to 6e34200 Compare September 28, 2026 05:26
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.
@crossle
crossle merged commit 50be1c3 into master Sep 28, 2026
1 check passed
@crossle
crossle deleted the feat/adjust-perps-margin branch September 28, 2026 08:46
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.

3 participants