Registrar

Description:

Decentralized Finance (DeFi) protocol contract providing Factory functionality.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "src/Registrar.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;

import {IProtocolController} from "src/interfaces/IProtocolController.sol";

/// @title Registrar
/// @author Stake DAO
/// @notice Registrar contract manages a list of whitelisted deployment targets (gauges/assets) per protocol.
contract Registrar {
    /// @notice Protocol Controller address.
    address public immutable PROTOCOL_CONTROLLER;

    /// @notice Mapping: protocolId => target => isWhitelisted
    mapping(bytes4 => mapping(address => bool)) public whitelistedTargets;

    /// @notice Error thrown when the caller is not allowed to set allowed targets.
    error OnlyAllowed();

    /// @notice Emitted when a deployment target is whitelisted or unwhitelisted for a protocol.
    /// @param protocolId Protocol ID (bytes4)
    /// @param target     Address (gauge/asset) that is whitelisted or unwhitelisted
    /// @param whitelisted    Boolean if whitelisted
    event WhitelistedTarget(bytes4 indexed protocolId, address indexed target, bool whitelisted);

    /// @notice Modifier to ensure only authorized addresses can modify the whitelist.
    modifier onlyAllowed() {
        require(IProtocolController(PROTOCOL_CONTROLLER).allowed(address(this), msg.sender, msg.sig), OnlyAllowed());
        _;
    }

    /// @param _protocolController Address of the ProtocolController contract
    constructor(address _protocolController) {
        require(_protocolController != address(0), "Zero ProtocolController");
        PROTOCOL_CONTROLLER = _protocolController;
    }

    /// @notice Set or unset an allowed target for a given protocol.
    /// @param protocolId ID of the protocol (bytes4)
    /// @param target     Address to allow/disallow
    /// @param allowed    Boolean if allowed
    function setAllowed(bytes4 protocolId, address target, bool allowed) external onlyAllowed {
        whitelistedTargets[protocolId][target] = allowed;
        emit WhitelistedTarget(protocolId, target, allowed);
    }

    /// @notice Check if a target is whitelisted for a given protocol.
    /// @param protocolId Protocol ID (bytes4)
    /// @param target     Address to check
    /// @return whitelisted   True if whitelisted, false if not whitelisted
    function isWhitelisted(bytes4 protocolId, address target) external view returns (bool whitelisted) {
        return whitelistedTargets[protocolId][target];
    }
}
"
    },
    "src/interfaces/IProtocolController.sol": {
      "content": "/// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;

interface IProtocolController {
    function vault(address) external view returns (address);
    function asset(address) external view returns (address);
    function rewardReceiver(address) external view returns (address);

    function allowed(address, address, bytes4 selector) external view returns (bool);
    function permissionSetters(address) external view returns (bool);
    function isRegistrar(address) external view returns (bool);

    function locker(bytes4 protocolId) external view returns (address);
    function gateway(bytes4 protocolId) external view returns (address);
    function strategy(bytes4 protocolId) external view returns (address);
    function allocator(bytes4 protocolId) external view returns (address);
    function accountant(bytes4 protocolId) external view returns (address);
    function feeReceiver(bytes4 protocolId) external view returns (address);
    function factory(bytes4 protocolId) external view returns (address);

    function isPaused(bytes4) external view returns (bool);
    function isShutdown(address) external view returns (bool);

    function registerVault(address _gauge, address _vault, address _asset, address _rewardReceiver, bytes4 _protocolId)
        external;

    function setValidAllocationTarget(address _gauge, address _target) external;
    function removeValidAllocationTarget(address _gauge, address _target) external;
    function isValidAllocationTarget(address _gauge, address _target) external view returns (bool);

    function pause(bytes4 protocolId) external;
    function unpause(bytes4 protocolId) external;
    function shutdown(address _gauge) external;
    function unshutdown(address _gauge) external;

    function setPermissionSetter(address _setter, bool _allowed) external;
    function setPermission(address _contract, address _caller, bytes4 _selector, bool _allowed) external;
}
"
    }
  },
  "settings": {
    "remappings": [
      "forge-std/=node_modules/forge-std/",
      "layerzerolabs/oft-evm/=node_modules/@layerzerolabs/oft-evm/",
      "@safe/=node_modules/@safe-global/safe-smart-account/",
      "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
      "@interfaces/=node_modules/@stake-dao/interfaces/src/interfaces/",
      "@address-book/=node_modules/@stake-dao/address-book/",
      "@shared/=node_modules/@stake-dao/shared/",
      "@layerzerolabs/=node_modules/@layerzerolabs/",
      "@safe-global/=node_modules/@safe-global/",
      "@solady/=node_modules/@solady/"
    ],
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "metadata": {
      "useLiteralContent": false,
      "bytecodeHash": "ipfs",
      "appendCBOR": true
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "evmVersion": "cancun",
    "viaIR": false
  }
}}

Tags:
DeFi, Factory|addr:0x1c3a4d06532d9d1c631f99ec50dd72da43a5c6de|verified:true|block:23648030|tx:0x78982a36a7f54e8c6c4def41ce998e04b22f16346c11fc0c8fd37d94eae48574|first_check:1761331707

Submitted on: 2025-10-24 20:48:27

Comments

Log in to comment.

No comments yet.