VaultRegistry.totalSupply(vault) to token.totalSupply(id)
When the total supply of fractional tokens of a vault is needed, we can make a call VaultRegistry.totalSupply(vault), that gets the token/id and then calls FERC1155(info.token).totalSupply(info.id).
However, sometimes we already have these values, so with this method we have a staticall and two warm SLOAD extra. In the following lines, consider using directly FERC1155(token).totalSupply(id).
VaultRegistry.totalSupply(vault)
totoken.totalSupply(id)
When the total supply of fractional tokens of a vault is needed, we can make a call
VaultRegistry.totalSupply(vault)
, that gets thetoken
/id
and then callsFERC1155(info.token).totalSupply(info.id)
.However, sometimes we already have these values, so with this method we have a
staticall
and two warmSLOAD
extra. In the following lines, consider using directlyFERC1155(token).totalSupply(id)
.Buyout.sol: L71, L210, L267, L288 Migration.sol: L95, L200, L470
VaultInfo.id
can be uint96token
andid
can be packed in a single storage slot if instead of using uint256 we use uint96. The number of vaults won't realistically reach 2**96.for-loop
i++
In general, a for-loop like this can be made more gas efficient.
Consider rewriting it like this:
Lines
grep -r 'i++'
Migration.sol
buyout
can be immutableSInce this variable doesn't change, it can be set
immutable
. It saves a SLOAD in every function.nonReentrant
modifier injoin
isn't neededThere's a
nonReentrant
modifier in Migration.sol#join. I don't a way to reenter from this function, so I suggest to remove it (to save gas of course).