Skip to content

Commit

Permalink
feat(ui-ux): allow 100% dusd vault to borrow non-dusd tokens (#4129)
Browse files Browse the repository at this point in the history
  • Loading branch information
lykalabrada authored Nov 7, 2023
1 parent d61a44b commit f29a056
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,12 @@ export function useValidateLoanAndCollateral(
(col) => col.symbol === "DUSD",
);

const isNonDUSDLoanAllowed =
!isTakingDUSDLoan && isDFIGreaterThanHalfOfRequiredCollateral;

const isDUSDLoanAllowed =
isTakingDUSDLoan &&
(isDFIGreaterThanHalfOfRequiredCollateral ||
(isFeatureAvailable("loop_dusd") && isDUSD100PercentOfCollateral));

return {
isLoanAllowed: isNonDUSDLoanAllowed || isDUSDLoanAllowed,
isLoanAllowed: isDUSDLoanAllowed || !isTakingDUSDLoan,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,18 @@ export function AddOrRemoveCollateralScreen({ route }: Props): JSX.Element {
message: addOrRemoveCollateralErrors.InsufficientBalance,
};
} else if (
isFeatureAvailable("loop_dusd") &&
hasLoan &&
vault.loanAmounts.some((loan) => loan.symbol === "DUSD") &&
vault.collateralAmounts.every((col) => col.symbol === "DUSD")
vault.loanAmounts.some((loan) => loan.symbol === "DUSD")
) {
const has100PercentDusdCol = vault.collateralAmounts.every(
(col) => col.symbol === "DUSD",
);
if (
!["DFI", "DUSD"].includes(selectedCollateralItem.token.symbol) ||
(isFeatureAvailable("loop_dusd") &&
has100PercentDusdCol &&
!["DFI", "DUSD"].includes(selectedCollateralItem.token.symbol)) ||
(!has100PercentDusdCol &&
selectedCollateralItem.token.symbol === "DUSD") ||
(selectedCollateralItem.token.symbol === "DFI" &&
isDFILessThanHalfOfRequiredCollateral)
) {
Expand Down

0 comments on commit f29a056

Please sign in to comment.