fix(oracles): UniswapV3Oracle quote-feed circuit breaker + setTwapPeriod cardinality recheck#187
Merged
Conversation
…iod cardinality recheck
Two adapter/oracle hardening fixes; the other three reported items are non-issues
(see below).
F1 (Medium) — quote-feed min/maxAnswer circuit breaker:
ChainlinkOracle rejects answers pinned to the aggregator's min/maxAnswer bound
(saturated/untrustworthy), but UniswapV3Oracle's quote-token Chainlink read had
no such check, so a saturated quote feed propagated a floor/ceiling value through
the TWAP→USD conversion (under-/over-valuing the asset). Added the same
_checkAnswerBounds (try/catch, aggregator() resolution) and AnswerOutOfBounds
revert for parity.
F2 (Medium/low) — setTwapPeriod skipped the cardinality check:
configurePool grows a pool's observation buffer to span the period in effect at
config time, but setTwapPeriod just set the new period — a raised period could
outrun already-configured pools (observe() reverts → price unavailable). Now
setTwapPeriod re-ensures (and opportunistically grows) every configured pool for
the new period, reverting InsufficientObservationCardinality if a pool cannot be
grown to support it. Configured tokens are tracked in an appended array.
Not fixed (verified non-issues):
- ChainlinkOracle / UniswapV3Oracle sequencer-uptime "staleness": _requireSequencerUp
already implements Chainlink's canonical L2 pattern (answer==0 + startedAt!=0 +
grace period); Chainlink's own reference does not staleness-check a status feed.
- ChainlinkOracle native decimals hardcoded to 18: correct for every EVM native gas
token (ETH/MATIC/BNB…).
Tests (test/audit/medlow/Oracles.t.sol): quote answer at min/max bound reverts
AnswerOutOfBounds (and within-bounds prices normally); setTwapPeriod grows a
growable pool and reverts for a non-growable one. Full oracle suite green.
tangletools
approved these changes
Jun 19, 2026
tangletools
left a comment
Contributor
There was a problem hiding this comment.
✅ Auto-approved PR — b52f5c50
Blanket team auto-approval is enabled for this reviewer service.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.
tangletools · auto-approval · reason: blanket_auto_approve · 2026-06-19T22:17:32Z
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Of the five reported oracle items, two are real and fixed here; three are non-issues (verified against the code).
setTwapPeriodskips observation-cardinality checkF1 (Medium) — quote-feed circuit breaker
ChainlinkOracle._getPriceDatarejects an answer pinned to the aggregator'sminAnswer/maxAnswerbound (a saturated, untrustworthy reading), butUniswapV3Oracle's quote-token Chainlink read (_getPriceData) only did sign/round/staleness checks. A saturated quote feed during an extreme dislocation would propagate a pinned floor/ceiling through the TWAP→USD conversion, under-/over-valuing the asset. Fix: added the same_checkAnswerBounds(try/catch withaggregator()resolution, direct-getter fallback) +AnswerOutOfBoundsrevert — parity withChainlinkOracle.F2 (Medium / low-ish — fail-closed) —
setTwapPeriodcardinalityconfigurePoolgrows a pool's observation ring buffer to span the TWAP period in effect at config time.setTwapPeriodjust reassigned the period, so raising it could outrun already-configured pools —observe()over the longer window then reverts (price unavailable; fail-closed, not mispricing, hence low-ish). Fix: track configured tokens and havesetTwapPeriodre-ensure (and opportunistically grow) every configured pool for the new period, revertingInsufficientObservationCardinalityif a pool can't be grown to support it (so an unsupportable period is rejected up front).Non-issues (no change)
_requireSequencerUpalready implements Chainlink's canonical L2 pattern —answer == 0(up),block.timestamp - startedAt >= grace, plus astartedAt == 0incomplete-round guard. Chainlink's own reference does not add anupdatedAtstaleness check on a status feed; the grace-period check is the correct equivalent.Tests (
test/audit/medlow/Oracles.t.sol)minAnswer/maxAnswer→AnswerOutOfBounds; within-bounds prices normally.setTwapPeriodgrows a growable configured pool to cover the raised window; revertsInsufficientObservationCardinalityfor a non-growable pool.