validateRepay, paybackAmount
Last updated
Was this helpful?
Last updated
Was this helpful?
amountSent
is params.amount
, which is amount
passed into repay
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
Select the non-zero debt value and assign it to paybackAmount
If useAtokens == true && params.amount == type.max
overwrite repay amount (params.amount
) to the user's AToken balance
this 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
User has opted to repay his debt partially,
overwrite paybackAmount
to 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"
See link for in-depth explanation on