diff --git a/components/sidebar/context/reflexer/SidebarReflexerPayback.vue b/components/sidebar/context/reflexer/SidebarReflexerPayback.vue index 6387d99..804b0b3 100644 --- a/components/sidebar/context/reflexer/SidebarReflexerPayback.vue +++ b/components/sidebar/context/reflexer/SidebarReflexerPayback.vue @@ -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) diff --git a/composables/useValidators.ts b/composables/useValidators.ts index 2de9cf5..e44e334 100644 --- a/composables/useValidators.ts +++ b/composables/useValidators.ts @@ -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, }; }