Summary
The setAmountPerRound function in BuyerAgent allows setting amountPerRound to 0, which breaks core functionality as this value is used to determine minimum fund requirements and purchase limits.
Vulnerability Details
The function lacks any validation on the new amount:
function setAmountPerRound(uint256 _amountPerRound) external onlyOwner {
_checkRoundPhase(Phase.Withdraw);
amountPerRound = _amountPerRound;
}
This value is used in critical functions:
function minFundAmount() public view returns (uint256) {
return amountPerRound + swan.getOracleFee();
}
function purchase() external onlyAuthorized {
for (uint256 i = 0; i < assets.length; i++) {
address asset = assets[i];
uint256 price = swan.getListingPrice(asset);
spendings[round] += price;
if (spendings[round] > amountPerRound) {
revert BuyLimitExceeded(spendings[round], amountPerRound);
}
}
}
Impact
Purchase function becomes unusable
Cannot buy any assets if price > 0
Tools Used
Manual Review
Recommendations
Add minimum amount validation:
contract BuyerAgent {
uint256 public constant MIN_AMOUNT_PER_ROUND = 0.01 ether;
function setAmountPerRound(uint256 _amountPerRound) external onlyOwner {
_checkRoundPhase(Phase.Withdraw);
if (_amountPerRound < MIN_AMOUNT_PER_ROUND) {
revert InvalidAmount(_amountPerRound);
}
amountPerRound = _amountPerRound;
}
}