fix(vault): scale XRP drops & MPT amounts on Vault detail page#1328
fix(vault): scale XRP drops & MPT amounts on Vault detail page#1328Patel-Raj11 wants to merge 2 commits into
Conversation
| convertedAmount === undefined && | ||
| displayCurrency === 'USD' | ||
| ) { | ||
| return '--' |
There was a problem hiding this comment.
nit: I think there's a default empty value variable somewhere, instead of hardcoding repetitively
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
This seems repetitive, can we use/create a shared function?
There was a problem hiding this comment.
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.
High Level Overview of Change
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.Max Total Supply,Available to Borrow, andUnrealized Lossrows showed a$X USDprefix/suffix when the currency toggle was set to USD but never multiplied by the conversion rate — i.e., a 100 XRP vault rendered$100 USDinstead of~$200 USD. Those three rows now route throughconvertToDisplayCurrencyjust like Total Value Locked does.Type of Change
Codebase Modernization
Before / After
XRP vault (
devnetexample,AssetsTotal=2500000000drops):Before
XRP

MPT

After

MPT

Test Plan
Added/Fixed tests.