In the BuyerAgent contract, the request function unnecessarily checks the token allowance even though it is already pre-approved with the maximum value during contract deployment. This check causes redundancy, as the approve function has already set the allowance to its maximum.
The request function checks the allowance of the BuyerAgent contract using the feeToken.allowance() function, expecting it to be greater than or equal to the required totalFee. However, in the constructor, the allowance has already been approved with the maximum uint256 value (type(uint256).max), making this check redundant and unnecessary. This could confuse future audits and maintainers, as it introduces an unnecessary condition.
https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/BuyerAgent.sol#L142-L143
https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/llm/LLMOracleCoordinator.sol#L159-L162
This redundancy does not introduce a direct security vulnerability but adds unnecessary checks, which can increase transaction complexity, gas usage, and confusion in the contract logic.
Remove the unnecessary allowance check in the request function as the contract already ensures maximum approval during deployment.
Optionally, include a comment in the constructor clarifying that the approve function has set the maximum allowance to avoid future confusion.
This cleanup will make the contract logic more efficient and easier to maintain.
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.