Verified contractPartialGPL-2.0-or-later
Root
Address0x6e82f40ebddcad6515a65c9337bb7ddbf8bc3cec
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.28
- Same code
Only this contract
Details
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- solidity
- Optimization
- No
- License
- GPL-2.0-or-later
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,425,106
- Creation transaction
- 0x8bd3186b79…028a48901f
7 files
- contracts/src/admin/Root.solmain4.09 KB
- contracts/src/admin/interfaces/IRoot.sol4.25 KB
- contracts/src/core/messaging/interfaces/IProtocolPauser.sol309 B
- contracts/src/core/messaging/interfaces/IScheduleAuth.sol570 B
- contracts/src/core/spoke/interfaces/IEndorsements.sol424 B
- contracts/src/misc/Auth.sol866 B
- contracts/src/misc/interfaces/IAuth.sol768 B
contracts/src/admin/Root.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.28;
import {IRoot} from "./interfaces/IRoot.sol";
import {Auth} from "../misc/Auth.sol";
import {IAuth} from "../misc/interfaces/IAuth.sol";
import {IEndorsements} from "../core/spoke/interfaces/IEndorsements.sol";
import {IScheduleAuth} from "../core/messaging/interfaces/IScheduleAuth.sol";
/// @title Root
/// @notice Core contract that is a ward on all other deployed contracts.
/// @dev Pausing can happen instantaneously, but relying on other contracts
/// is restricted to the timelock set by the delay.
contract Root is Auth, IRoot {
/// @dev To prevent filing a delay that would block any updates indefinitely
uint256 internal constant MAX_DELAY = 4 weeks;
bool public paused;
uint256 public delay;
mapping(address => uint256) public endorsements;
mapping(address relyTarget => uint256 timestamp) public schedule;
constructor(uint256 _delay, address deployer) Auth(deployer) {
require(_delay <= MAX_DELAY, DelayTooLong());
delay = _delay;
}
//----------------------------------------------------------------------------------------------
// Administration
//----------------------------------------------------------------------------------------------
/// @inheritdoc IRoot
function file(bytes32 what, uint256 data) external auth {
if (what == "delay") {
require(data <= MAX_DELAY, DelayTooLong());
delay = data;
} else {
revert FileUnrecognizedParam();
}
emit File(what, data);
}
/// @inheritdoc IRoot
function endorse(address user) external auth {
endorsements[user] = 1;
emit Endorse(user);
}
/// @inheritdoc IRoot
function veto(address user) external auth {
endorsements[user] = 0;
emit Veto(user);
}
/// @inheritdoc IEndorsements
function endorsed(address user) external view returns (bool) {
return endorsements[user] == 1;
}
//----------------------------------------------------------------------------------------------
// Pause management
//----------------------------------------------------------------------------------------------
/// @inheritdoc IRoot
function pause() external auth {
paused = true;
emit Pause();
}
/// @inheritdoc IRoot
function unpause() external auth {
paused = false;
emit Unpause();
}
//----------------------------------------------------------------------------------------------
// Timelocked ward management
//----------------------------------------------------------------------------------------------
/// @inheritdoc IScheduleAuth
function scheduleRely(address target) external auth {
schedule[target] = block.timestamp + delay;
emit ScheduleRely(target, schedule[target]);
}
/// @inheritdoc IScheduleAuth
function cancelRely(address target) external auth {
require(schedule[target] != 0, TargetNotScheduled());
schedule[target] = 0;
emit CancelRely(target);
}
/// @inheritdoc IRoot
function executeScheduledRely(address target) external {
require(schedule[target] != 0, TargetNotScheduled());
require(schedule[target] <= block.timestamp, TargetNotReady());
wards[target] = 1;
emit Rely(target);
schedule[target] = 0;
}
//----------------------------------------------------------------------------------------------
// External contract ward management
//----------------------------------------------------------------------------------------------
/// @inheritdoc IRoot
function relyContract(address target, address user) external auth {
IAuth(target).rely(user);
emit RelyContract(target, user);
}
/// @inheritdoc IRoot
function denyContract(address target, address user) external auth {
IAuth(target).deny(user);
emit DenyContract(target, user);
}
}
contracts/src/admin/interfaces/IRoot.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import {IEndorsements} from "../../core/spoke/interfaces/IEndorsements.sol";
import {IScheduleAuth} from "../../core/messaging/interfaces/IScheduleAuth.sol";
import {IProtocolPauser} from "../../core/messaging/interfaces/IProtocolPauser.sol";
interface IRoot is IEndorsements, IProtocolPauser, IScheduleAuth {
//----------------------------------------------------------------------------------------------
// Events
//----------------------------------------------------------------------------------------------
event File(bytes32 indexed what, uint256 data);
event RelyContract(address indexed target, address indexed user);
event DenyContract(address indexed target, address indexed user);
//----------------------------------------------------------------------------------------------
// Errors
//----------------------------------------------------------------------------------------------
error DelayTooLong();
error FileUnrecognizedParam();
error TargetNotScheduled();
error TargetNotReady();
//----------------------------------------------------------------------------------------------
// View methods
//----------------------------------------------------------------------------------------------
/// @notice Returns the current timelock for adding new wards
function delay() external view returns (uint256);
/// @notice Trusted contracts within the system
function endorsements(address target) external view returns (uint256);
/// @notice Returns when `relyTarget` has passed the timelock
function schedule(address relyTarget) external view returns (uint256 timestamp);
//----------------------------------------------------------------------------------------------
// Administration
//----------------------------------------------------------------------------------------------
/// @notice Updates a contract parameter
/// @param what Accepts a bytes32 representation of 'delay'
function file(bytes32 what, uint256 data) external;
//----------------------------------------------------------------------------------------------
// Endorsements
//----------------------------------------------------------------------------------------------
/// @notice Endorses the `user`
/// @dev Endorsed users are trusted contracts in the system. They are allowed to bypass
/// token restrictions (e.g. the Escrow can automatically receive share class tokens by being endorsed), and
/// can automatically set operators in ERC-7540 vaults (e.g. the VaultRouter) is always an operator.
function endorse(address user) external;
/// @notice Removes the endorsed user
function veto(address user) external;
//----------------------------------------------------------------------------------------------
// Pause management
//----------------------------------------------------------------------------------------------
/// @notice Pause any contracts that depend on `Root.paused()`
function pause() external;
/// @notice Unpause any contracts that depend on `Root.paused()`
function unpause() external;
//----------------------------------------------------------------------------------------------
// Timelocked ward management
//----------------------------------------------------------------------------------------------
/// @notice Execute a scheduled rely
/// @dev Can be triggered by anyone since the scheduling is protected
function executeScheduledRely(address target) external;
//----------------------------------------------------------------------------------------------
// External contract ward management
//----------------------------------------------------------------------------------------------
/// @notice Make an address a ward on any contract that Root is a ward on
function relyContract(address target, address user) external;
/// @notice Removes an address as a ward on any contract that Root is a ward on
function denyContract(address target, address user) external;
}
contracts/src/core/messaging/interfaces/IProtocolPauser.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
interface IProtocolPauser {
event Pause();
event Unpause();
/// @notice Returns whether the root is paused
/// @return True if the protocol is paused, false otherwise
function paused() external view returns (bool);
}
contracts/src/core/messaging/interfaces/IScheduleAuth.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
interface IScheduleAuth {
event ScheduleRely(address indexed target, uint256 indexed scheduledTime);
event CancelRely(address indexed target);
/// @notice Schedule relying a new ward after the delay has passed
/// @param target The address to schedule as a ward
function scheduleRely(address target) external;
/// @notice Cancel a pending scheduled rely
/// @param target The address to cancel the scheduled rely for
function cancelRely(address target) external;
}
contracts/src/core/spoke/interfaces/IEndorsements.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
interface IEndorsements {
event Endorse(address indexed user);
event Veto(address indexed user);
/// @notice Returns whether the user is endorsed
/// @param user The address to check for endorsement status
/// @return True if the user is endorsed, false otherwise
function endorsed(address user) external view returns (bool);
}
contracts/src/misc/Auth.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.28;
import {IAuth} from "./interfaces/IAuth.sol";
/// @title Auth
/// @notice Simple authentication pattern
/// @author Based on code from https://github.com/makerdao/dss
abstract contract Auth is IAuth {
/// @inheritdoc IAuth
mapping(address => uint256) public wards;
constructor(address initialWard) {
wards[initialWard] = 1;
emit Rely(initialWard);
}
/// @dev Check if the msg.sender has permissions
modifier auth() {
require(wards[msg.sender] == 1, NotAuthorized());
_;
}
/// @inheritdoc IAuth
function rely(address user) public auth {
wards[user] = 1;
emit Rely(user);
}
/// @inheritdoc IAuth
function deny(address user) public auth {
wards[user] = 0;
emit Deny(user);
}
}
contracts/src/misc/interfaces/IAuth.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
interface IAuth {
event Rely(address indexed user);
event Deny(address indexed user);
error NotAuthorized();
/// @notice Returns whether the target is a ward (has admin access)
/// @param target The address to check for ward status
/// @return The ward status (1 if ward, 0 if not)
function wards(address target) external view returns (uint256);
/// @notice Make user a ward (give them admin access)
/// @param user The address to grant ward status to
function rely(address user) external;
/// @notice Remove user as a ward (remove admin access)
/// @param user The address to remove ward status from
function deny(address user) external;
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.