Skip to content

Commit

Permalink
Ux feedback - max should not exceed dai balance (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
marshall2112 authored Oct 31, 2024
1 parent eb5dd41 commit 369da79
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions apps/dapp/src/components/Pages/Core/DappPages/Borrow/TLC/Repay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,25 @@ export const Repay: React.FC<IProps> = ({
setState({
...state,
repayValue: accountPosition
? formatToken(accountPosition.currentDebt, state.outputToken)
? accountPosition.currentDebt.gt(state.outputTokenBalance)
? formatToken(state.outputTokenBalance, state.outputToken)
: formatToken(accountPosition.currentDebt, state.outputToken)
: '0',
});
}}
min={0}
// Max is total debt
hint={`Max: ${formatToken(
accountPosition ? accountPosition.currentDebt : ZERO,
accountPosition
? accountPosition.currentDebt.gt(state.outputTokenBalance)
? state.outputTokenBalance
: accountPosition.currentDebt
: ZERO,
state.outputToken
)}`}
width="100%"
/>
{fromAtto(state.outputTokenBalance) < Number(state.repayValue) && (
{fromAtto(state.outputTokenBalance).toFixed(2) <
Number(state.repayValue).toFixed(2) && (
<Warning>
<InfoCircle>
<p>i</p>
Expand Down Expand Up @@ -164,7 +170,8 @@ export const Repay: React.FC<IProps> = ({
// Disable if repay amount is lte zero, or gt wallet balance
disabled={
Number(state.repayValue) <= 0 ||
fromAtto(state.outputTokenBalance) < Number(state.repayValue)
fromAtto(state.outputTokenBalance).toFixed(2) <
Number(state.repayValue).toFixed(2)
}
style={{ width: 'auto' }}
>
Expand Down

0 comments on commit 369da79

Please sign in to comment.