Initial commit: simple frontend helper for mortgageFi, basic debt repayment and debt viewing functionality works, tested for both cbbtc and wbtc and not weth
This commit is contained in:
21
utils/format.ts
Normal file
21
utils/format.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export function formatAddress(address: string): string {
|
||||
if (!address) return '';
|
||||
return `${address.substring(0, 6)}...${address.substring(address.length - 4)}`;
|
||||
}
|
||||
|
||||
export function formatCurrency(amount: number, currency: string = 'USD'): string {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency,
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}).format(amount);
|
||||
}
|
||||
|
||||
export function formatAPY(apy: number): string {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
style: 'percent',
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}).format(apy / 100);
|
||||
}
|
||||
Reference in New Issue
Block a user