MCPcopy
hub / github.com/Uniswap/interface / getFormatterRule

Function getFormatterRule

src/utils/formatNumbers.ts:450–465  ·  view source on GitHub ↗
(input: number, type: FormatterType, conversionRate?: number)

Source from the content-addressed store, hash-verified

448}
449
450function getFormatterRule(input: number, type: FormatterType, conversionRate?: number): FormatterRule {
451 const rules = Array.isArray(type) ? type : TYPE_TO_FORMATTER_RULES[type]
452 for (const rule of rules) {
453 const shouldConvertInput = rule.formatterOptions.currency && conversionRate
454 const convertedInput = shouldConvertInput ? input * conversionRate : input
455
456 if (
457 (rule.exact !== undefined && convertedInput === rule.exact) ||
458 (rule.upperBound !== undefined && convertedInput < rule.upperBound)
459 ) {
460 return rule
461 }
462 }
463
464 throw new Error(`formatter for type ${type} not configured correctly`)
465}
466
467interface FormatNumberOptions {
468 input: Nullish<number>

Callers 1

formatNumberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…