From ddeedcf8e609d7f53eae6ad0750cb810aa33ad52 Mon Sep 17 00:00:00 2001 From: UniverseFinance Date: Fri, 24 Dec 2021 10:32:46 +0800 Subject: [PATCH] fix: percent can be gt 100 --- components/protocols/CardUniverse.vue | 2 +- composables/useFormatting.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/protocols/CardUniverse.vue b/components/protocols/CardUniverse.vue index ecf4f55..d28125c 100644 --- a/components/protocols/CardUniverse.vue +++ b/components/protocols/CardUniverse.vue @@ -42,7 +42,7 @@
-

{{ formatPercent(feeAprLifetime) }}

+

{{ formatPercent(feeAprLifetime, 2, true) }}

Fee APR

diff --git a/composables/useFormatting.ts b/composables/useFormatting.ts index 4bbf8d2..519faee 100644 --- a/composables/useFormatting.ts +++ b/composables/useFormatting.ts @@ -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",