transfer & mint
Overview

transfer
IERC20(params.asset).safeTransferFrom(msg.sender, reserveCache.aTokenAddress, params.amount);
This transfers the asset to be supplied from user to the corresponding AToken contract
from:
msg.sender
to:
aTokenAddress
(aDAI, aWETH...)
mint
minting of ATokens corresponding the supplied asset
bool isFirstSupply = IAToken(reserveCache.aTokenAddress).mint(msg.sender, params.onBehalfOf, params.amount, reserveCache.nextLiquidityIndex);

mint
calls_mintScaled
_mintScaled
mints tokens in-line with the current liquidity index, as seen byamountScaled
amountToMint
:amountScaled
cast asuint128
balanceIncrease
: interest accrued from user's last recorded index and current index_userState[onBehalfOf].additionalData
is updated with the latest index.
balanceIncrease
is calculated as part of the mint event emission.

On super.BalanceOf
and _userState[onBehalfOf].additionalData
super.BalanceOf
and _userState[onBehalfOf].additionalData
super.BalanceOf
callsbalanceOf
declared in IncentivizedERC20.solInheritance: ScaledBalanceTokenBase > MintableIncentivizedERC20 > IncentivizedERC20

notice the irregular definition of
balanceOf
, it calls out a mapping_userState
_userState
is mapping of user addresses toUserState
structsEach
UserState
struct stores a user's balance with a wildcard field ofadditionalData
Returns
mint
returns the bool value of (scaledBalance == 0)
scaledBalance
is the amount of balance a user has of a specific asset pre-dating this supply action(scaledBalance == 0)
will return true only if this supply action is the user's very first supply action - specific to said asset.The return bool value is useful to us as explained in the next section.
Visual Aid
Last updated
Was this helpful?