You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(contracts): TWAP-based MAX_APPEAL_RESTITUTION for SafetyReserve #687
design:economicsToken economics, pricing, fee split, bond sizingkind:featureNew capability or a change to current behaviorkind:testTest coverage, flakes, fixtures or the e2e harness
PR #684 implemented SafetyReserve.payout with MAX_APPEAL_RESTITUTION as a governance-set USDC ceiling. ADR 028 § Contract surface calls for a TWAP-from-pool oracle derivation so the cap tracks the live TOKEN/USDC price rather than requiring a governance vote each time the market moves.
Scope
Wire a TWAP oracle (Balancer V3 pool from ADR 018, or Chainlink if the pool oracle is unreliable on Arbitrum Sepolia) into SafetyReserve.
Derive MAX_APPEAL_RESTITUTION from TWAP_window × TWAP_max_TOKEN_equiv rather than a flat USDC value.
Add fallback: if oracle stale beyond a governance-set max age, fall back to last-good cap (do not brick payout).
Update tests covering ratification with oracle-driven cap, oracle-stale fallback, and governance retune of the TOKEN-equivalent input.
This is a well-scoped follow-up to PR #684, requesting that SafetyReserve.MAX_APPEAL_RESTITUTION be derived from a TWAP oracle (Balancer V3 or Chainlink fallback) rather than a flat governance-set USDC value. The work is explicitly called out in ADR 028 as a deferred follow-up and is production-blocking. Scope is clearly bounded to SafetyReserve.sol + tests.
📊 Assessment
Dimension
Value
Reasoning
Type
Feature
New on-chain capability (oracle integration), not a bug fix
Labels
enhancement, prod-blocking, testing
Matches ADR-required production shape; existing economics+technical labels retained; test coverage update is explicit in scope
Coding agent
Suitable
Requirements are explicit (oracle source, fallback behaviour, governance params, test cases), success criteria are enumerated, scope is limited to one contract + tests
🔗 Similar issues
No duplicates found. Issue #591 (single USDC token decision) is related context — confirms that the oracle must price TOKEN→USDC, not introduce a new payment token.
💡 Notes and suggestions
Oracle source decision needed first:
ADR 018 specifies a Balancer V3 pool. On Arbitrum Sepolia that pool may have insufficient liquidity/history to produce a reliable TWAP. Confirm whether the pool TWAP is available; if not, Chainlink TOKEN/USD + USDC/USD feeds are the safe fallback. This decision should be recorded in ADR 028 before implementation starts.
ADR 028 status note:
ADR 028 was unlocked from "Locked-for-implementation" back to "Draft" (per CLAUDE.md history). This change will need an ADR 028 update to re-approve once the oracle source is selected.
Implementation checklist:
Confirm oracle availability on Arbitrum Sepolia (Balancer V3 pool TWAP vs Chainlink)
Add ITwapOracle interface + oracleMaxAge governance param to SafetyReserve
Replace flat MAX_APPEAL_RESTITUTION storage with derived computation: TWAP_window × TWAP_max_TOKEN_equiv
Store lastGoodCap for stale-oracle fallback; do not revert payout on stale oracle
Emit event on stale-oracle fallback for monitoring
Tests: oracle-driven cap, stale fallback, governance retune of TOKEN-equiv input
Update ADR 028 with oracle source decision and re-approve
Solidity CI gotchas to watch:
nonReentrant + always-reverting paths → W5740 under FOUNDRY_PROFILE=ci --deny warnings (see CLAUDE.md)
Any new bytes32 casts or unchecked ERC20 calls → covered by global forge-lint exclusions in foundry.toml, no per-line suppression needed
Run FOUNDRY_PROFILE=ci forge build --sizes --deny warnings locally before pushing
Recommend closing as not-planned — obsoleted by the SafetyReserve removal (#708, ADR 033 retired).
This issue asked to derive MAX_APPEAL_RESTITUTION from a TWAP oracle. Under escrow-on-slash there is no restitution cap and no TOKEN→USDC conversion to price: a granted appeal refunds the operator's own escrowed TOKEN from CapacityBond, so there is nothing to cap. ADR 028 § Contract surface is explicit — "No MAX_APPEAL_RESTITUTION cap exists ... no TWAP/USDC conversion" — and SlashAppeal never moves USDC.
No follow-up work remains here unless a TOKEN-side cap is wanted somewhere (none is specified today).
design:economicsToken economics, pricing, fee split, bond sizingkind:featureNew capability or a change to current behaviorkind:testTest coverage, flakes, fixtures or the e2e harness
Activity
github-actions commentedon May 28, 2026
🎯 Triage report
This is a well-scoped follow-up to PR #684, requesting that
SafetyReserve.MAX_APPEAL_RESTITUTIONbe derived from a TWAP oracle (Balancer V3 or Chainlink fallback) rather than a flat governance-set USDC value. The work is explicitly called out in ADR 028 as a deferred follow-up and is production-blocking. Scope is clearly bounded toSafetyReserve.sol+ tests.📊 Assessment
enhancement,prod-blocking,testingeconomics+technicallabels retained; test coverage update is explicit in scope🔗 Similar issues
No duplicates found. Issue #591 (single USDC token decision) is related context — confirms that the oracle must price TOKEN→USDC, not introduce a new payment token.
💡 Notes and suggestions
Oracle source decision needed first:
ADR 018 specifies a Balancer V3 pool. On Arbitrum Sepolia that pool may have insufficient liquidity/history to produce a reliable TWAP. Confirm whether the pool TWAP is available; if not, Chainlink
TOKEN/USD+USDC/USDfeeds are the safe fallback. This decision should be recorded in ADR 028 before implementation starts.ADR 028 status note:
ADR 028 was unlocked from "Locked-for-implementation" back to "Draft" (per CLAUDE.md history). This change will need an ADR 028 update to re-approve once the oracle source is selected.
Implementation checklist:
ITwapOracleinterface +oracleMaxAgegovernance param toSafetyReserveMAX_APPEAL_RESTITUTIONstorage with derived computation:TWAP_window × TWAP_max_TOKEN_equivlastGoodCapfor stale-oracle fallback; do not revertpayouton stale oracleSolidity CI gotchas to watch:
nonReentrant+ always-reverting paths → W5740 underFOUNDRY_PROFILE=ci --deny warnings(see CLAUDE.md)bytes32casts or unchecked ERC20 calls → covered by global forge-lint exclusions infoundry.toml, no per-line suppression neededFOUNDRY_PROFILE=ci forge build --sizes --deny warningslocally before pushingAdd this agentic workflows to your repo
To install this agentic workflow, run
alpergundogdu commentedon May 29, 2026
Recommend closing as not-planned — obsoleted by the SafetyReserve removal (#708, ADR 033 retired).
This issue asked to derive
MAX_APPEAL_RESTITUTIONfrom a TWAP oracle. Under escrow-on-slash there is no restitution cap and no TOKEN→USDC conversion to price: a granted appeal refunds the operator's own escrowed TOKEN fromCapacityBond, so there is nothing to cap. ADR 028 § Contract surface is explicit — "NoMAX_APPEAL_RESTITUTIONcap exists ... no TWAP/USDC conversion" — andSlashAppealnever moves USDC.No follow-up work remains here unless a TOKEN-side cap is wanted somewhere (none is specified today).