Skip to content

Commit

Permalink
Merge pull request #1153 from yieldprotocol/feat/issue-1144
Browse files Browse the repository at this point in the history
fixing lend input validation
  • Loading branch information
brucedonovan authored Mar 15, 2023
2 parents 0b2910d + 01e138d commit ad9afa5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hooks/useInputValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const useInputValidation = (
const _inputAsFloat = parseFloat(input);
const aboveMax: boolean = !!limits[1] && _inputAsFloat > parseFloat(limits[1].toString());
const belowMin: boolean = !!limits[0] && _inputAsFloat < parseFloat(limits[0].toString());
const aboveUserBalance: boolean = aboveMax && !protocolLimited
const aboveUserBalance: boolean = aboveMax && !protocolLimited;
const aboveProtocolLendLimit: boolean = aboveMax && protocolLimited;

// General input validation here:
if (parseFloat(input) < 0 && actionCode !== ActionCodes.TRANSFER_VAULT) {
Expand Down Expand Up @@ -90,7 +91,7 @@ export const useInputValidation = (

case ActionCodes.LEND:
aboveUserBalance && setInputError('Amount exceeds available balance');
protocolLimited && setInputError('Amount exceeds the maximum you can lend');
aboveProtocolLendLimit && setInputError('Amount exceeds the maximum you can lend');
belowMin && setInputError('Amount should be expressed as a positive value');
break;

Expand Down

0 comments on commit ad9afa5

Please sign in to comment.