Skip to content

[VPD-927] [VPD-928]: [Phase 0] Configure EBrakeV2-integrated DeviationSentinel on BSC testnet and mainnet #690

Open
Debugger022 wants to merge 12 commits intomainfrom
feat/VPD-927
Open

[VPD-927] [VPD-928]: [Phase 0] Configure EBrakeV2-integrated DeviationSentinel on BSC testnet and mainnet #690
Debugger022 wants to merge 12 commits intomainfrom
feat/VPD-927

Conversation

@Debugger022
Copy link
Copy Markdown
Contributor

@Debugger022 Debugger022 commented Apr 1, 2026

Summary

Wire up EBrake and migrate DeviationSentinel to route all emergency actions through it on both BSC Testnet and BSC Mainnet.

Changes

BSC Mainnet (vips/vip-661/bscmainnet.ts)

  • Proxy upgrade: Upgrade DeviationSentinel to new EBrake-integrated implementation
  • EBrake → Comptroller: Grant EBrake all required Core Pool Comptroller permissions (_setActionsPaused, setCollateralFactor x2, _setMarketBorrowCaps, _setMarketSupplyCaps, setFlashLoanPaused, setIsBorrowAllowed, setWhiteListFlashLoanAccount)
  • Sentinel → EBrake: Grant DeviationSentinel pauseBorrow, pauseSupply, decreaseCF on EBrake
  • Governance reset perms: Grant Normal/FastTrack/Critical Timelocks and Guardian the three granular snapshot-reset functions (resetCFSnapshot, resetBorrowCapSnapshot, resetSupplyCapSnapshot) on EBrake
  • Governance EBrake perms: Grant Timelocks and Guardian all 12 EBrake action functions directly (so Critical VIPs can route through EBrake and benefit from snapshot coverage)
  • Multisig EBrake perms: Grant Venus team multisig (0xCCa5a587eBDBe80f23c8610F2e53B03158e62948) all 12 EBrake action functions for emergency pausing (Phase 0)
  • Revoke old: Remove DeviationSentinel's direct comptroller permissions granted in VIP-590

BSC Testnet (vips/vip-661/bsctestnet.ts + addenda)

  • bsctestnet.ts: Initial testnet wiring — proxy upgrade, EBrake/Sentinel/governance permissions, revoke old Sentinel comptroller perms
  • Addendum 1: Recover vETH_Core after EBrake incident on testnet; grant keeper extra convenience permissions
  • Addendum 2: Follow-up recovery step for vETH_Core on testnet
  • Addendum 3 (Phase-0 audit fixes): Upgrade both EBrake and DeviationSentinel proxies; swap setCFZerodecreaseCF(address,uint256) for Sentinel; replace resetMarketState with three granular reset functions; grant new Comptroller surgical controls (setIsBorrowAllowed, setWhiteListFlashLoanAccount) to EBrake; grant Timelocks and keeper full EBrake action permissions

Contracts

Contract Network Address
EBrake (proxy) Mainnet TBD — post-deployment
EBrake (proxy) Testnet 0x957c09e3Ac3d9e689244DC74307c94111FBa8B42
DeviationSentinel (proxy) Mainnet 0x6599C15cc8407046CD91E5c0F8B7f765fF914870
DeviationSentinel (proxy) Testnet 0x9245d72712548707809D66848e63B8E2B169F3c1
New DeviationSentinel impl Mainnet TBD — post-deployment
New DeviationSentinel impl Testnet TBD — post-deployment
Venus Team Multisig Mainnet 0xCCa5a587eBDBe80f23c8610F2e53B03158e62948

Test plan

  • Set deployed implementation addresses (EBrake + DeviationSentinel) once available
  • Set fork block for simulations/vip-661/bsctestnet-addendum-3.ts to a block after Addendum 2 execution
  • Testnet simulation: npx hardhat test simulations/vip-661/bsctestnet.ts --fork bsctestnet
  • Testnet addendum-3 simulation: npx hardhat test simulations/vip-661/bsctestnet-addendum-3.ts --fork bsctestnet
  • Mainnet simulation: npx hardhat test simulations/vip-661/bscmainnet.ts --fork bscmainnet

…C testnet

- Upgrade DeviationSentinel proxy to new EBrake-routing implementation
- Grant EBrake ACM permissions on comptrollers (_setActionsPaused, setCollateralFactor, borrow/supply caps)
- Grant DeviationSentinel permissions to call EBrake (pauseBorrow, pauseSupply, setCFZero)
- Revoke old direct comptroller permissions from DeviationSentinel
- Add simulation tests verifying pre/post VIP state
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 79ecd79f-4cb0-4538-8b00-33588ad2b26a

📥 Commits

Reviewing files that changed from the base of the PR and between 6b4cdae and 24f2067.

📒 Files selected for processing (2)
  • simulations/vip-661/bsctestnet.ts
  • vips/vip-661/bsctestnet.ts

📝 Walkthrough

Walkthrough

Upgrade the DeviationSentinel proxy, add new ABIs (AccessControlManager, DeviationSentinel, EBrake, ProxyAdmin), introduce a VIP-661 proposal module, and add a Hardhat fork simulation that validates pre- and post-VIP permission and proxy state changes.

Changes

Cohort / File(s) Summary
ABI artifacts
simulations/vip-661/abi/AccessControlManager.json, simulations/vip-661/abi/DeviationSentinel.json, simulations/vip-661/abi/EBrake.json, simulations/vip-661/abi/ProxyAdmin.json
Added ABI JSONs: role/permission management, deviation sentinel interfaces (constructor, errors, events, check/handle functions), eBrake controller interfaces (pause/cap/CF controls, errors, events), and ProxyAdmin admin/upgrade functions. Verify signatures, indexed event params, and overloads.
VIP proposal
vips/vip-661/bsctestnet.ts
New proposal builder exporting constants and vip661Testnet(): orders actions to upgrade DeviationSentinel proxy, grant ACM call permissions to eBrake-related methods, grant resetMarketState to timelocks, grant DeviationSentinel→eBrake call permissions, and revoke legacy direct comptroller permissions.
Fork simulation
simulations/vip-661/bsctestnet.ts
New Hardhat fork test validating pre-VIP state (impl, permissions), runs proposal, asserts PermissionGranted/PermissionRevoked events, and verifies post-VIP state (proxy impl switched, ACM/eBrake/DeviationSentinel permissions updated, legacy permissions removed).

Sequence Diagram

sequenceDiagram
    participant ProxyAdmin
    participant DeviationSentinelProxy as DeviationSentinel Proxy
    participant ACM as AccessControlManager
    participant EBrake
    participant NewImpl as DeviationSentinel Impl
    participant Timelock

    rect rgba(100, 149, 237, 0.5)
    Note over ProxyAdmin,DeviationSentinelProxy: VIP-661 execution
    ProxyAdmin->>DeviationSentinelProxy: upgrade(DeviationSentinelProxy, NEW_IMPL)
    DeviationSentinelProxy->>NewImpl: delegate to new implementation
    ACM->>EBrake: grant call permissions for pause/CF/cap/flashLoan
    ACM->>Timelock: grant `resetMarketState(address)` to timelocks
    ACM->>DeviationSentinelProxy: grant permission to call EBrake.pauseBorrow/pauseSupply/setCFZero
    ACM->>DeviationSentinelProxy: revoke legacy direct comptroller permissions
    end

    rect rgba(144, 238, 144, 0.5)
    Note over DeviationSentinelProxy,EBrake: Post-VIP runtime
    DeviationSentinelProxy->>EBrake: invoke emergency actions via ACM-authorized calls
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through ABIs, proxy skies so bright,

Upgraded sentinel to guard the night,
Permissions shuffled, old gates swept away,
EBrake, ACM, sentinel hold sway,
I nibble a carrot and code in delight.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: configuring EBrake-integrated DeviationSentinel on BSC testnet, which aligns with the changeset's core objective.
Description check ✅ Passed The description is comprehensive and well-structured with Summary, Changes, Contracts, and Test plan sections that thoroughly explain the modifications and their scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/VPD-927

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Debugger022 Debugger022 marked this pull request as ready for review April 2, 2026 05:10
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@vips/vip-661/bsctestnet.ts`:
- Around line 6-13: The exported constants EBRAKE, NEW_DEVIATION_SENTINEL_IMPL,
DEVIATION_SENTINEL, PROXY_ADMIN, and ACM are hardcoded; instead import
NETWORK_ADDRESSES from src/networkAddresses.ts and change each export to
reference NETWORK_ADDRESSES.bsctestnet.<appropriateKey> (e.g.,
NETWORK_ADDRESSES.bsctestnet.EBRAKE,
NETWORK_ADDRESSES.bsctestnet.NEW_DEVIATION_SENTINEL_IMPL,
NETWORK_ADDRESSES.bsctestnet.DEVIATION_SENTINEL,
NETWORK_ADDRESSES.bsctestnet.PROXY_ADMIN, NETWORK_ADDRESSES.bsctestnet.ACM),
removing the literal strings so all network addresses come from the shared
NETWORK_ADDRESSES object.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ab8c2d47-150d-49bc-b160-0ade5b6bc44e

📥 Commits

Reviewing files that changed from the base of the PR and between 0f14d26 and 151d37a.

📒 Files selected for processing (6)
  • simulations/vip-661/abi/AccessControlManager.json
  • simulations/vip-661/abi/DeviationSentinel.json
  • simulations/vip-661/abi/EBrake.json
  • simulations/vip-661/abi/ProxyAdmin.json
  • simulations/vip-661/bsctestnet.ts
  • vips/vip-661/bsctestnet.ts

Comment on lines +6 to +13
export const EBRAKE = "0x73f0d19A34e466286f909346F2EF08A18D0228D2";
export const NEW_DEVIATION_SENTINEL_IMPL = "0x10716E3Bde7770BD84C4A3d7EC06BB0885C0a891";

// Existing testnet addresses
export const DEVIATION_SENTINEL = "0x9245d72712548707809D66848e63B8E2B169F3c1";
export const PROXY_ADMIN = "0x7877ffd62649b6a1557b55d4c20fcbab17344c91";
export const ACM = "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use NETWORK_ADDRESSES instead of hardcoded addresses.

These network addresses should be sourced from src/networkAddresses.ts (NETWORK_ADDRESSES.bsctestnet.<key>) rather than declared as literals in the VIP file.

As per coding guidelines, **/*.{ts,tsx}: Network addresses must be imported from src/networkAddresses.ts via NETWORK_ADDRESSES.<network>.<key>.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@vips/vip-661/bsctestnet.ts` around lines 6 - 13, The exported constants
EBRAKE, NEW_DEVIATION_SENTINEL_IMPL, DEVIATION_SENTINEL, PROXY_ADMIN, and ACM
are hardcoded; instead import NETWORK_ADDRESSES from src/networkAddresses.ts and
change each export to reference NETWORK_ADDRESSES.bsctestnet.<appropriateKey>
(e.g., NETWORK_ADDRESSES.bsctestnet.EBRAKE,
NETWORK_ADDRESSES.bsctestnet.NEW_DEVIATION_SENTINEL_IMPL,
NETWORK_ADDRESSES.bsctestnet.DEVIATION_SENTINEL,
NETWORK_ADDRESSES.bsctestnet.PROXY_ADMIN, NETWORK_ADDRESSES.bsctestnet.ACM),
removing the literal strings so all network addresses come from the shared
NETWORK_ADDRESSES object.

Grant additional EBrake comptroller permissions (setCollateralFactor,
setMarketBorrowCaps, setMarketSupplyCaps, setFlashLoanPaused) and
resetMarketState permission to all three timelocks. Update simulation
with corresponding pre/post checks and event count
@Debugger022
Copy link
Copy Markdown
Contributor Author

… on testnet

- Restore vETH_Core collateral factor and unpause mint after EBrake
  tightened the market during DeviationSentinel testing
- Clear EBrake snapshot for vETH_Core via resetMarketState
- Grant keeper permissions for _setActionsPaused, setCollateralFactor,
  and resetMarketState on testnet to enable repeatable E2E testing
- Update EBrake ABI with new initialize, marketStates,
  getMarketCFSnapshot, resetMarketState, and MarketStateReset entries
- Add ERC20, ResilientOracle, and Comptroller ABIs for simulation
- adds minimal 3-action VIP: restore CF/LT, unpause MINT, clear EBrake snapshot
- no permission grants needed — established by bsctestnet.ts (Guardian/EBrake perms) and addendum 1 (Normal Timelock → resetMarketState)
- simulation forks from block 100233050 (post-addendum-1, second incident active via Tenderly web action)
- serves as reference for minimal governance footprint to recover any future EBrake-tightened market
…onSentinel

- upgrades DeviationSentinel proxy to EBrake-integrated implementation
- grants EBrake permissions on Core Pool Comptroller (_setActionsPaused, setCollateralFactor, _setMarketBorrowCaps, _setMarketSupplyCaps, setFlashLoanPaused)
- grants Guardian and all three timelocks resetMarketState permission on EBrake
- grants DeviationSentinel pauseBorrow, pauseSupply, and setCFZero permissions on EBrake
- revokes DeviationSentinel's old direct comptroller permissions from VIP-590
- simulation uses isAllowedToCall pattern (BSC mainnet ACM) with impersonated host contracts
- EBRAKE and NEW_DEVIATION_SENTINEL_IMPL marked as TODO pending deployment
@Debugger022 Debugger022 changed the title [VPD-927]: Configure EBrake-integrated DeviationSentinel on BSC testnet [VPD-927] [VPD-928]: Configure EBrake-integrated DeviationSentinel on BSC testnet and mainnet Apr 7, 2026
[VPD-985] feat: add VIP-661 addendum to recover vETH_Core after EBrake incident on testnet
@Debugger022 Debugger022 self-assigned this Apr 7, 2026
@Debugger022 Debugger022 changed the title [VPD-927] [VPD-928]: Configure EBrake-integrated DeviationSentinel on BSC testnet and mainnet [VPD-927] [VPD-928]: Configure EBrakeV2-integrated DeviationSentinel on BSC testnet and mainnet Apr 7, 2026
Replace setCFZero with decreaseCF, split resetMarketState into three
granular snapshot-reset functions, and grant governance timelocks
permission on all EBrake action functions so Critical VIPs can route
through EBrake and benefit from its snapshot mechanism.

Refactor VIP body to use signature arrays with giveCallPermission/
revokeCallPermission helpers, reducing makeProposal from ~100 to 13 lines.
Upgrades EBrake and DeviationSentinel to the new implementations, swaps
setCFZero for decreaseCF on DeviationSentinel, replaces resetMarketState
with three granular snapshot-reset functions, and grants timelocks and
keeper permission on all EBrake action functions so Critical VIPs can
route through EBrake and benefit from its snapshot mechanism.
@Debugger022 Debugger022 changed the title [VPD-927] [VPD-928]: Configure EBrakeV2-integrated DeviationSentinel on BSC testnet and mainnet [VPD-927] [VPD-928]: [Phase 0] Configure EBrakeV2-integrated DeviationSentinel on BSC testnet and mainnet Apr 10, 2026
Add MULTISIG (0xCCa5a587) to VIP-661 so the Venus team can call all
EBrake action functions directly for emergency pausing (Phase 0).
Updates simulation with pre/post permission checks and bumps RoleGranted
count from 71 to 83.
…IP-661

Fill in deployed contract addresses for EBrake and DeviationSentinel
implementations on both mainnet and testnet, and set fork block numbers.
Exclude setMarketBorrowCaps/setMarketSupplyCaps from pre-VIP assertions
since governance already holds those grants at the comptroller level.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant