add message for min debt on payback

This commit is contained in:
Georges KABBOUCHI 2021-09-07 22:17:15 +03:00
parent cfd957648f
commit c913be69ad
2 changed files with 26 additions and 4 deletions

View File

@ -136,7 +136,7 @@ export default defineComponent({
const maxBalance = computed(() => min(balance.value, debt.value).toFixed())
const { toggle, isMaxAmount } = useMaxAmountActive(amount, maxBalance)
const { validateAmount, validateLiquidation, validateIsLoggedIn, validateReflexerDebt } = useValidators()
const { validateAmount, validateLiquidation, validateIsLoggedIn, validateReflexerPaybackDebt } = useValidators()
const errors = computed(() => {
const hasAmountValue = !isZero(amount.value)
@ -145,7 +145,7 @@ export default defineComponent({
amount: { message: validateAmount(amountParsed.value, maxBalance.value), show: hasAmountValue },
liquidation: { message: validateLiquidation(status.value, liquidation.value), show: hasAmountValue },
auth: { message: validateIsLoggedIn(!!account.value), show: true },
minDebt: { message: validateReflexerDebt(changedDebt.value), show: hasAmountValue },
minDebt: { message: validateReflexerPaybackDebt(changedDebt.value), show: hasAmountValue },
}
})
const { errorMessages, isValid } = useValidation(errors)

View File

@ -114,7 +114,7 @@ export function useValidators() {
function validateReflexerDebt(
debtParsed,
minDebt = reflexerMinDebt.value,
vaultId
vaultId,
) {
if (lt(debtParsed, minDebt) && gt(debtParsed, "0")) {
const vaultText = vaultId
@ -122,7 +122,28 @@ export function useValidators() {
? `on vault #${vaultId}`
: `on new vault`
: "";
return `Minimum debt requirement is ${minDebt} RAI ${vaultText}`;
return `Minimum debt requirement is ${minDebt} RAI ${vaultText}` ;
}
return null;
}
function validateReflexerPaybackDebt(
debtParsed,
minDebt = reflexerMinDebt.value,
vaultId,
) {
console.log(debtParsed, minDebt);
if (lt(debtParsed, minDebt) && gt(debtParsed, "0")) {
const vaultText = vaultId
? vaultId !== "0"
? `on vault #${vaultId}`
: `on new vault`
: "";
return `Minimum debt requirement is ${minDebt} RAI ${vaultText} + accumulated interest, supply additional ${debtParsed} RAI` ;
}
return null;
@ -164,5 +185,6 @@ export function useValidators() {
validateLiquityTroveExists,
validateReflexerDebtCeiling,
validateReflexerDebt,
validateReflexerPaybackDebt,
};
}