validateRepay, paybackAmount
Overview

validateRepay

amountSentisparams.amount, which isamountpassed intorepay

The first two require statements serves as input validation for amountSent
ensure that value is non-zero
ensure that an explicit amount was set by the user, else ensure that msg.sender is paying for himself
Then we check if the asset status via getFlags:
Active
Not Paused
Lastly, we check that user has a non-zero debt in either one of the interest rate mode: stable or variable.
if both are zero, there is no debt to repay
Setting paybackAmount

Select the non-zero debt value and assign it to
paybackAmount
If useAtokens == true && params.amount == type.max
If useAtokens == true && params.amount == type.max overwrite repay amount (
params.amount) to the user's AToken balancethis is the max that can be repaid, given AToken balances
In the case of repay, useATokens is set to false, therefore the code within the if section is not executed.
If params.amount < paybackAmount
If params.amount < paybackAmount User has opted to repay his debt partially,
overwrite
paybackAmountto reflect user's choice of partial repayment
Another way to view this, is: "Is the user able to cover his total debt with the repay amount, if not, set paybackAmount to what he has offered to repay"
Last updated
Was this helpful?