In _replaceScope, the expression IAgreement(agreement) is evaluated on every iteration of the loop that validates and adds new scope accounts. Since agreement is a storage variable that never changes during the call, this produces an SLOAD per iteration for a value that is invariant. The value never changes within the loop — it's invariant. Each SLOAD costs ~100 gas (warm), so over N accounts you're paying N * 100 gas extra.
The one instance is in _replaceScope at line 764. agreement is a storage variable (address public agreement, line 61) that gets read via SLOAD on every loop iteration to make the external call to IAgreement(agreement).isContractInScope(account). Its value never changes mid-loop.
Link to affected codes:
https://github.com/CodeHawks-Contests/2026-07-bc-confidence-pools/blob/main/src/ConfidencePool.sol#L764-L773
https://github.com/CodeHawks-Contests/2026-07-bc-confidence-pools/blob/main/src/ConfidencePool.sol#L755-L757
Impact:
Gas
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.
The contest is complete and the rewards are being distributed.