SentryGuard is an autonomous security layer designed for the Drips ecosystem. It acts as a fail-safe mechanism (a "Kill-Switch") that monitors the health of funded projects through the PulseRegistry. If a project fails to maintain its "active" status, SentryGuard automatically intervenes by triggering the StreamController to halt all outgoing funds, preserving DAO treasury assets.
SentryGuard operates as a decentralized sentinel. Its architecture consists of three primary components working in harmony:
The enforceSafety function is the core of the sentinel. It can be triggered periodically by:
- Chainlink Keepers: For fully autonomous, time-based checks.
- Gelato Network: For event-driven or automated executions.
- Public Callers: Any community member can trigger the check to ensure treasury safety.
SentryGuard interfaces with the PulseRegistry, which serves as the "source of truth" for project health. This registry tracks:
- Last activity timestamp.
- Maintenance signals.
- Governance-voted status changes.
When a project is flagged as inactive, SentryGuard executes an emergency call to the StreamController. This interaction updates the DripsHub configuration, setting the streaming rate to 0, effectively pausing the grant instantly.
graph TD
A[Keepers / Bot] -->|Trigger| B(SentryGuard)
B -->|Check Status| C{PulseRegistry}
C -->|Inactive| D[StreamController]
C -->|Active| E[No Action]
D -->|Set Rate = 0| F[DripsHub]
F -->|Halt Funds| G[Project Wallet]
The core logic is optimized for gas efficiency and reliability:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./PulseRegistry.sol";
import "./StreamController.sol";
contract SentryGuard {
PulseRegistry public pulse;
StreamController public controller;
/**
* @notice Initializes the SentryGuard with Pulse and Controller addresses.
* @param _pulse The address of the PulseRegistry.
* @param _controller The address of the StreamController.
*/
constructor(address _pulse, address _controller) {
pulse = PulseRegistry(_pulse);
controller = StreamController(_controller);
}
/**
* @notice Enforces safety by checking project health and halting streams if inactive.
* @dev This function can be called by anyone to protect DAO funds.
* @param _project The address of the project to check.
* @param _uid The unique ID associated with the stream in DripsHub.
* @param _token The ERC20 token address being streamed.
*/
function enforceSafety(address _project, uint256 _uid, address _token) external {
if (!pulse.isProjectActive(_project)) {
// Halt the stream immediately to save DAO funds
controller.dripsHub().setStreams(_uid, _token, 0);
}
}
}- Autonomous Protection: Reduces the need for manual intervention during project failures.
- Treasury Preservation: Prevents "leaking" funds to abandoned or inactive projects.
- Interoperable: Designed to fit seamlessly into the existing Drips v2 ecosystem.
- Transparent: Every halt action is on-chain and verifiable.
This project is built using the Foundry development framework.
# Clone the repository and install dependencies
git clone https://github.com/chucksentertainment-hash/SentryGuard.git
cd SentryGuard
forge installforge build# Run the security test suite
forge test -vvDistributed under the MIT License. See LICENSE for more information.