feat: move StockOracleSwitch setGlobal to MANAGER + add batchSetStatus#196
Open
ricklista wants to merge 2 commits into
Open
feat: move StockOracleSwitch setGlobal to MANAGER + add batchSetStatus#196ricklista wants to merge 2 commits into
ricklista wants to merge 2 commits into
Conversation
- setGlobal (global market switch) now requires MANAGER instead of BOT; BOT keeps per-stock open/close. The sensitive daily/global switch moves to governance while routine per-stock toggling stays with the automation bot. - Add batchSetStatus(address[] tokens, bool status): sets every listed registered stock to status (true=open / false=close) in one call (BOT role). Idempotent — tokens already in the target state are skipped; an unregistered token reverts the whole batch. - Update tests for both changes + fix stale "BOT calls setGlobal" comments in deploy_stockOracle.sol. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… -> public - open/close: external -> public so batchSetStatus can call them in-loop (the internal call preserves msg.sender = BOT, so onlyRole still passes). ABI/selectors unchanged. - batchSetStatus now delegates to open/close per element instead of inlining state writes; it is strict — an already-in-state (AlreadySet) or unregistered (NotRegistered) token reverts the whole batch. - Update test: idempotent no-op skip -> AlreadySet revert. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Two changes to
StockOracleSwitch(the open/closed gate for tokenized-stock markets):setGlobalmoves fromBOTtoMANAGER— the single global market-hours switch becomes governance-controlled, while routine per-stock open/close stays with the automationBOT.batchSetStatus(address[] tokens, bool status)— letsBOTopen or close many registered stocks in one call by delegating toopen/close(strict — reverts the whole batch on a no-op or unregistered token).Change type
Contracts changed
src/oracle/StockOracleSwitch.solscript/oracle/deploy_stockOracle.soltest/oracle/StockOracleSwitch.t.soltest/oracle/StockOracle.t.solInterface changes
setGlobal(bool open)— access role changedBOT→MANAGER(signature unchanged).open(address)/close(address)— visibilityexternal→public(stillBOT-gated) sobatchSetStatuscan call them internally. ABI/selectors unchanged.batchSetStatus(address[] calldata tokens, bool status)— newexternal,BOTrole. Opens (status = true) or closes (status = false) every token intokensby delegating toopen/close. Strict — inherits theopen/closeguards, so a token already in the target state (AlreadySet) or unregistered (NotRegistered) reverts the whole batch. Emits the existingStockEnable(token, status)event per token.Storage layout
Verified via
forge inspect StockOracleSwitch storage-layout— unchanged:No state variables added/removed/reordered (only a function added, a modifier changed, and
open/closevisibility widened). Safe to deploy as a UUPS implementation upgrade — no collision risk.Access control
setGlobalnow requiresMANAGERinstead ofBOT. Operationally, the global daily/market-hours switch must be toggled by theMANAGERholder (a Gnosis Safe afterdeploy_stockOracleTransferRole.sol), not the bot.batchSetStatusisBOT-gated and delegates toopen/close, which becamepublicbut stayBOT-gated; the per-element role check still passes because the internal call preservesmsg.sender.MANAGERstill adminsBOT;_authorizeUpgradestillDEFAULT_ADMIN_ROLE).Risk assessment
StockOracle.peekviaisEnabled.setGlobalrole moveBOT→MANAGER;open/closewidened topublicbut stayBOT-gated. Covered by tests (incl. a test assertingBOTis now rejected onsetGlobal).batchSetStatusonly delegates to in-contractopen/close.Deployment
StockOracleSwitchimplementation and callingupgradeToAndCallon the live proxy0xb4678C3E8B49d2b95Da48458f98805da193A8498(admin = Timelock0x07D274a68393E8b8a2CCf19A2ce4Ba3518735253after role handoff).MANAGER(Safe) action; per-stock open/close (incl. bulkbatchSetStatus) remains aBOTaction.Test plan
forge test --mc StockOraclepasses — 64 tests (StockOracleSwitchTest 43 + StockOracleTest 21).batchSetStatuscoverage: bulk close-then-open + event order, already-in-state reverts (AlreadySet), non-BOTrejected, unregistered token reverts the whole batch (state rolled back), empty array no-op.setGlobaltests updated toMANAGER, plus a new test assertingBOTcan no longer call it.prettier --checkclean.forge testincludes BSC fork suites needingBSC_RPC; this PR ran the targeted oracle suites, which exercise all changed code.🤖 Generated with Claude Code