Closed pmerkleplant closed 7 months ago
Thanks for the review!
About 2) code coverage not 100%:
Added functionality to include the _verifyTwapConfig()
function, which is only used in the constructor, to also be included in the coverage. Forge does not normally include construction code in the coverage report.
However, note that the Uniswap TWAP fails if the price returned overflows a uint128
. We were unable to construct a mocked Uniswap pool state with such a high price and also couldn't find any real pool to use in a fork test. Therefore, there are two test cases that revert with NotImplemented()
- one for each case the twap is read.
Except of those 2 cases, the coverage is complete.
About 5) chainlink oracle not upgradeable:
Yes, as this oracle instance does not use a proxy a try-catch
would be sufficient, ie a call either succeeds with the expected return data or it reverts. However, note that for a deployment of aggor for a different asset pair the proxy defense mechanisms would need to be implemented again - which may be easy to forget.
About 7) agreementDistance
semantic:
Fixed, nice pattern!
5) I would like to proceed with the switch to try catch on the Chainlink price feed. There shouldn't be any more complexity than needed.
Coverage looks better now, but I'm still getting test failures.
[FAIL. Reason: revert: NotImplemented] testFuzz_read_ChronicleNotOk_ChainlinkNotOk_TwapNotOk() (gas: 324)
[FAIL. Reason: revert: NotImplemented; counterexample: calldata=0x89c7d318000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 args=[0, 0, 0]] testFuzz_read_ChronicleOk_ChainlinkOk_NotInAgreementDistance_TwapNotOk(uint128,uint256,uint256) (runs: 0, μ: 0, ~: 0)
Great PR and great tests!
Couple of notes:
testFuzz_setAgreementDistance_RevertsIf_AgreementDistanceMoreThan1WAD
. That test fuzzes the entire state space, and only shows one side of the condition. With something like the below example, you can demonstrate the exact boundary for when a condition is met and not met and no fuzzing is needed: function test_setAgreementDistance_RevertsIf_AgreementDistanceMoreThan1WAD() public {
vm.expectRevert();
aggor.setAgreementDistance(1e18 + 1);
aggor.setAgreementDistance(1e18);
}
I think this approach would be great to apply to the IAggor.Status.path
values changing depending on:
Looks solid otherwise!
Aggor Review 2. I'll respond to each of the points from my previous review.
Previous Review for Reference:
forge coverage
the coverage is still not 100% onAggor.sol
.0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419
. The interface is not upgradable on that contract, so how would it return anything other than what is expected or revert?agreementDistance
semantics can be changed to have1 WAD
represent identical values to remove the subtraction in the calculation. IEagreementDistance = 0.95e18
implies a 5% deviation of price instead of setting the value to0.05e18
with the current setup. This will remove a subtraction and this is important because it's a hot path. Also can remove a division/stack var. I've rewritten the code below.becomes
Also, I ran
forge test
and got some failures: