feat: adjusted aggregator contract for price adjustments based on sig…#201
feat: adjusted aggregator contract for price adjustments based on sig…#201dmytro-horbatenko merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the existing discount-based aggregator feed into a more flexible adjustment-based feed, supporting both price lowering and raising via signed percentages. The changes include updating the contract logic, deployment scripts, and test suites to accommodate the new functionality. I have reviewed the implementation and suggest caching the denominator used in the adjustment calculation as an immutable variable during construction to optimize gas usage, as the current implementation performs redundant external calls and exponentiation on every data retrieval.
| int256 adjustment = (_answer * adjustmentPercentage) / | ||
| int256(100 * 10**decimals()); |
There was a problem hiding this comment.
The calculation of the adjustment denominator involves an external call to decimals() on every execution of latestRoundData and getRoundData. Since the underlyingFeed is immutable and its decimals are constant for a given feed, this value should be cached in an immutable variable during construction to save gas.
22ca867 to
a44110b
Compare
…ned percentage