change the state of totalDistributedTokens then mint new tokens.
function _distribute(
DistributionParams storage params,
uint256 mintAmount
) private {
+ _totalDistributed += mintAmount;
uint256 stakingAmount = TempleMath.mulDivRound(
params.staking,
mintAmount,
DISTRIBUTION_DIVISOR,
false
);
if (stakingAmount > 0) {
_mint(address(staking), stakingAmount);
staking.notifyDistribution(stakingAmount);
}
uint256 escrowAmount = TempleMath.mulDivRound(
params.escrow,
mintAmount,
DISTRIBUTION_DIVISOR,
false
);
if (escrowAmount > 0) {
_mint(address(escrow), escrowAmount);
escrow.notifyDistribution(escrowAmount);
}
uint256 gnosisAmount = mintAmount - stakingAmount - escrowAmount;
if (gnosisAmount > 0) {
_mint(teamGnosis, gnosisAmount);
/// @notice no requirement to notify gnosis because no action has to be taken
}
//@audit state changed later....
- _totalDistributed += mintAmount;
emit Distributed(
stakingAmount,
escrowAmount,
gnosisAmount,
block.timestamp
);
}
function _getMintAmount(
VestingFactor memory vestingFactorCache
) private view returns (uint256 mintAmount) {
uint32 _lastMintTimestamp = lastMintTimestamp;
uint256 totalSupplyCache = _totalDistributed;
/// @dev if vesting factor is not set, return 0. `_lastMintTimestamp` is set when vesting factor is set
if (_lastMintTimestamp == 0) {
return 0;
}
mintAmount = TempleMath.mulDivRound(
//0
(block.timestamp - _lastMintTimestamp) * (MAX_SUPPLY),
vestingFactorCache.numerator,
vestingFactorCache.denominator,
false
);
if (totalSupplyCache + mintAmount > MAX_SUPPLY) {
unchecked {
mintAmount = MAX_SUPPLY - totalSupplyCache;
}
}
}