Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
87a6e270
Unverified
Commit
87a6e270
authored
Oct 11, 2022
by
lynn
Committed by
GitHub
Oct 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: remove double $ render (#4864)
remove double $ render
parent
d704e782
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
TradePrice.tsx
src/components/swap/TradePrice.tsx
+1
-1
formatNumbers.ts
src/utils/formatNumbers.ts
+22
-3
No files found.
src/components/swap/TradePrice.tsx
View file @
87a6e270
...
@@ -63,7 +63,7 @@ export default function TradePrice({ price, showInverted, setShowInverted }: Tra
...
@@ -63,7 +63,7 @@ export default function TradePrice({ price, showInverted, setShowInverted }: Tra
</Text>{' '}
</Text>{' '}
{usdcPrice && (
{usdcPrice && (
<ThemedText.DeprecatedDarkGray>
<ThemedText.DeprecatedDarkGray>
<Trans>(
$
{
formatDollar
({
num
:
priceToPreciseFloat
(
usdcPrice
)
})}
)</Trans>
<Trans>({formatDollar({ num: priceToPreciseFloat(usdcPrice) })})</Trans>
</ThemedText.DeprecatedDarkGray>
</ThemedText.DeprecatedDarkGray>
)}
)}
</StyledPriceContainer>
</StyledPriceContainer>
...
...
src/utils/formatNumbers.ts
View file @
87a6e270
...
@@ -31,7 +31,19 @@ interface FormatDollarArgs {
...
@@ -31,7 +31,19 @@ interface FormatDollarArgs {
round
?:
boolean
round
?:
boolean
}
}
// Using a currency library here in case we want to add more in future.
/**
* Returns a USD dollar or equivalent denominated numerical value formatted
* in human readable string for use in template.
*
* Adheres to guidelines for prices and other numbers defined here:
* https://www.notion.so/uniswaplabs/Number-standards-fbb9f533f10e4e22820722c2f66d23c0
* @param num numerical value denominated in USD or USD equivalent
* @param isPrice whether the amount represents a price or not
* @param lessPreciseStablecoinValues whether or not we should show less precise values for
* stablecoins (around 1$ in value always) for the sake of readability
* @param digits number of digits after the decimal for non-price amounts
* @param round whether or not to round up non-price amounts
*/
export
const
formatDollar
=
({
export
const
formatDollar
=
({
num
,
num
,
isPrice
=
false
,
isPrice
=
false
,
...
@@ -83,8 +95,15 @@ export const formatDollar = ({
...
@@ -83,8 +95,15 @@ export const formatDollar = ({
}
}
}
}
// For transaction review numbers, such as token quantities, NFT price (token-denominated),
/**
// network fees, transaction history items.
* Returns a numerical amount of any token formatted in human readable string for use in template.
*
* For transaction review numbers, such as token quantities, NFT price (token-denominated),
* network fees, transaction history items. Adheres to guidelines defined here:
* https://www.notion.so/uniswaplabs/Number-standards-fbb9f533f10e4e22820722c2f66d23c0
* @param num numerical value denominated in any token
* @param maxDigits the maximum number of digits that should be shown for the quantity
*/
export
const
formatTransactionAmount
=
(
num
:
number
|
undefined
|
null
,
maxDigits
=
9
)
=>
{
export
const
formatTransactionAmount
=
(
num
:
number
|
undefined
|
null
,
maxDigits
=
9
)
=>
{
if
(
num
===
0
)
return
'
0.00
'
if
(
num
===
0
)
return
'
0.00
'
if
(
!
num
)
return
''
if
(
!
num
)
return
''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment