The purchase()
function in BuyerAgent reverts the entire transaction if the sum price of the assets in the batch would exceed amountPerRound
, even if some assets could have been validly purchased within the limit.
https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/BuyerAgent.sol#L237-L252
The current implementation consist of a for loop of the assets to buy, sum them and compare to the amountPerRound
\
This is inefficient and could lead to missed purchase opportunities:
Forces multiple transactions where one could suffice
Wastes gas on failed transactions
Requires additional oracle requests that depends on the input and llm the response may be the same
Could cause buyers to miss purchases
Makes listers lose potential sales, and also they will have to pay the listing fee (royaltyFee) again if they want to re-list the asset
Modify the purchase function to handle partial purchases:
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.