From c12d1231bfbdd22618fe8752d1c4c8abc2896a9d Mon Sep 17 00:00:00 2001 From: "nature.xie" Date: Sun, 14 Jan 2024 23:38:41 +0800 Subject: [PATCH] min repay decimal handle --- components/Modal/Action.tsx | 3 +++ components/Modal/utils.ts | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/components/Modal/Action.tsx b/components/Modal/Action.tsx index 1ce0484f..b647d32c 100644 --- a/components/Modal/Action.tsx +++ b/components/Modal/Action.tsx @@ -101,6 +101,9 @@ export default function Action({ maxBorrowAmount, healthFactor, poolAsset }) { decimals, 0, ); + if (+interestChargedIn1min === 0) { + interestChargedIn1min = "1"; + } } if (poolAsset?.supplied?.shares) { minRepay = new Decimal(poolAsset?.supplied?.balance) diff --git a/components/Modal/utils.ts b/components/Modal/utils.ts index dc521cd4..9cf001fb 100644 --- a/components/Modal/utils.ts +++ b/components/Modal/utils.ts @@ -130,7 +130,7 @@ export const getModalData = (asset): UIAsset & Props & { disabled: boolean } => .div(poolAsset?.supplied?.shares) .mul(2) .toFixed(0, 2), - extraDecimals + decimals, + decimals, ); } let interestChargedIn1min = "0"; @@ -139,7 +139,7 @@ export const getModalData = (asset): UIAsset & Props & { disabled: boolean } => .div(365 * 24 * 60) .div(100) .mul(borrowed) - .toFixed(); + .toFixed(decimals, 2); } const repayAmount = Decimal.max( new Decimal(borrowed).plus(interestChargedIn1min),