Due to security purposes, a variable (uint256) should exist as a counter for total number of vaults. It will be incremented when deployVault() is called and its value will be returned directly when totalVaults() will be called.
Proof of Concept
Tools Used
Manual review
Recommended Mitigation Steps
this can be used
uint256 vaultCounter = 0;
function deployVault(
params
) external returns (PrizeVault) {
...
allVaults.push(_vault);
vaultCounter++;
...
}
function totalVaults() external view returns (uint256) {
return vaultCounter;
// this function also saves gas as we are reading the value from a state variable
}
Lines of code
https://github.com/code-423n4/2024-03-pooltogether/blob/main/pt-v5-vault/src/PrizeVaultFactory.sol#L66
Vulnerability details
Impact
Due to security purposes, a variable (uint256) should exist as a counter for total number of vaults. It will be incremented when
deployVault()
is called and its value will be returned directly whentotalVaults()
will be called.Proof of Concept
Tools Used
Manual review
Recommended Mitigation Steps
this can be used
Assessed type
Other