Purchase function prevents partial purchases when the cumulative spending exceeds amountPerRound, causing the function to revert entirely. This means that even if the user has sufficient funds to buy some assets within the limit, the function does not attempt to complete those purchases before hitting the limit
The purchase() is defined as :
The for loop iterates over all assets and adds the price to spendings. Later the cumulative spendings are compared to amountPerRound. if spendings[round] > amountPerRound , the whole tx will revert. This is not correct logic,because it will prevent any user who has sufficient amount for some assets. Consider the following example:
Bob creates a buyerAgent with amountPerRound=8 ETH.
He calls Purchase function and let's say the returned assets array is [A1, A2, A3, A4, A5] with listing prices {2, 3, 5, 4, 2} ETH.
The first two iteration of loop will make spendings=5(2+3)
The third iteration will exceed the Bob's amountPerRound.(2+3+5=10). The function will revert .
The Bob supposed to buy A1 and A2 but he will not able to .
The user does not have to buy all returned assets, s/he may simply wants to buy some of the assets. Also based on mentioned example Bob could buy A1, A2 and A5.However since in the third iteration the function reverted, he will not able to get the last asset.
Partiall purchases are not possible, limiting the functionality of the codebase/protocol, disincentivizing the users
None. Manual Review
Adjust the loop so that users can buy as many assets as possible without exceeding amountPerRound. A way to achieve this in my opinion is break out of the loop once the cumulative spending exceeds amountPerRound, rather than reverting. Here is the adjusted loop:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.