fix: percent can be gt 100

This commit is contained in:
UniverseFinance 2021-12-24 10:32:46 +08:00
parent 1168467ee2
commit ddeedcf8e6
2 changed files with 3 additions and 3 deletions

View File

@ -42,7 +42,7 @@
</div>
</div>
<div class="ml-auto text-right">
<p class="leading-8 text-lg font-bold text-green-500">{{ formatPercent(feeAprLifetime) }}</p>
<p class="leading-8 text-lg font-bold text-green-500">{{ formatPercent(feeAprLifetime, 2, true) }}</p>
<div class="h-4 flex">
<p class="text-sm font-medium text-[#9FB0C9]">Fee APR</p>
<Info class="ml-1 h-3" text="Trading fees earned in Uniswap V3 pool" />

View File

@ -32,9 +32,9 @@ export function useFormatting() {
}
}
function formatPercent(value: any, fractionDigits = 2) {
function formatPercent(value: any, fractionDigits = 2, noLimit = false) {
if (isZero(value)) return "0%";
if (gt(value, 1)) return ">100%";
if (!noLimit && gt(value, 1)) return ">100%";
const formatter = new Intl.NumberFormat(locale, {
style: "percent",