There is an implicit assumption with this line that brew and pour will be called one after the other for the same total amount. For example, if brew is called twice then the next pour call will need to allocate funds all mugs at once for both of the individual brew calls. It may be possible that two different contracts want to allocate funds at the same time in which case pour will fail if the brews happen to be called in a separate transaction.
I'd recommend either merging these two functions or changing the line above to:
https://github.com/makerdao/keg/blob/8202cbd88657ad2a6194691db9c5c5d8754fc229/src/Keg.sol#L134
There is an implicit assumption with this line that
brew
andpour
will be called one after the other for the same total amount. For example, ifbrew
is called twice then the nextpour
call will need to allocate funds allmugs
at once for both of the individualbrew
calls. It may be possible that two different contracts want to allocate funds at the same time in which casepour
will fail if thebrew
s happen to be called in a separate transaction.I'd recommend either merging these two functions or changing the line above to:
require(vat.dai(address(this)) >= mul(beer, RAY), "Keg/not-enough-brew");