Skip to content

fix(vault): scale XRP drops & MPT amounts on Vault detail page#1328

Open
Patel-Raj11 wants to merge 2 commits into
mainfrom
fix-vault-page-scaled-amount
Open

fix(vault): scale XRP drops & MPT amounts on Vault detail page#1328
Patel-Raj11 wants to merge 2 commits into
mainfrom
fix-vault-page-scaled-amount

Conversation

@Patel-Raj11

Copy link
Copy Markdown
Contributor

High Level Overview of Change

  • Apply the same parseAmount(convertScaledPrice(BigInt(raw), scale)) pattern used by the MPT page to all amount fields on the Vault detail page (header + loans), so raw ledger values are converted to display units before formatting.
  • Along the way: fix a related display bug where Max Total Supply, Available to Borrow, and Unrealized Loss rows showed a $X USD prefix/suffix when the currency toggle was set to USD but never multiplied by the conversion rate — i.e., a 100 XRP vault rendered $100 USD instead of ~$200 USD. Those three rows now route through convertToDisplayCurrency just like Total Value Locked does.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Tests (updated fixtures that were locking in the buggy behavior, added MPT scaling + USD toggle coverage)

Codebase Modernization

  • Updated files to React Hooks (already on hooks)
  • Updated files to TypeScript (already TS)

Before / After

XRP vault (devnet example, AssetsTotal = 2500000000 drops):

Before

XRP
image

MPT
image

After
image

MPT
image

Test Plan

Added/Fixed tests.

@cybele-ripple cybele-ripple self-requested a review June 11, 2026 23:12
convertedAmount === undefined &&
displayCurrency === 'USD'
) {
return '--'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: I think there's a default empty value variable somewhere, instead of hardcoding repetitively

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it's not exported constant, each component has a local constant as shown below (for instance, AMM page, Amendments Table etc). I can create a constant here following the same convention, if we need an repo wide export and want to consume it, we can refactor entire codebase in another task.

const DEFAULT_EMPTY_VALUE = '--'


const formatAmount = (amount: string | number): string => {
const num = typeof amount === 'string' ? Number(amount) : amount
const raw = String(amount)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems repetitive, can we use/create a shared function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, I noticed this but formatAmount, formatFee seems to be repetitive entirely before these additions and there are some repetitions in other components introduced by Vault page as far as currency conversion and display goes. I think it's better to revisit these pages and tackle them as opposed to trying to clean the code in this PR. I can extract out the XRP/MPT switch part but that doesn't add any value until we clean the entire components.

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.

2 participants