Skip to content

Commit

Permalink
🚸 leverage: show an error message when the asset is not collateral
Browse files Browse the repository at this point in the history
  • Loading branch information
franm91 committed May 2, 2024
1 parent 6761fd9 commit a229043
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions contexts/LeveragerContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,14 @@ export const LeveragerContextProvider: FC<PropsWithChildren> = ({ children }) =>
);

const setCollateralSymbol = useCallback(
(collateralSymbol: string) => setBorrowSymbol(collateralSymbol),
[setBorrowSymbol],
(collateralSymbol: string) => {
const marketAccount = getMarketAccount(collateralSymbol);
setBorrowSymbol(collateralSymbol);
if (marketAccount && !marketAccount.isCollateral) {
return setErrorData({ status: true, message: t('Please set this asset as collateral in your dashboard') });
}
},
[getMarketAccount, setBorrowSymbol, t],
);

const setSecondaryOperation = useCallback((secondaryOperation: 'deposit' | 'withdraw') => {
Expand Down Expand Up @@ -834,6 +840,7 @@ export const LeveragerContextProvider: FC<PropsWithChildren> = ({ children }) =>
[
assetIn,
chain.id,
contractVersion,
debtManager,
isPermit,
maIn,
Expand Down
3 changes: 2 additions & 1 deletion i18n/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -632,5 +632,6 @@
" In {{installments}} installments": "En {{installments}} cuotas",
"Repay Amount": "Monto a Pagar",
"Join the waitlist": "Únete a la lista de espera",
"The first onchain debit & credit card.": "La primer tarjeta de débito y crédito onchain."
"The first onchain debit & credit card.": "La primer tarjeta de débito y crédito onchain.",
"Please set this asset as collateral in your dashboard": "Por favor, establece este activo como colateral en tu panel de control"
}

0 comments on commit a229043

Please sign in to comment.