Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/GaugeRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { Ownable2Step } from "@openzeppelin/contracts/access/Ownable2Step.sol";
/**
* @title Gauge Registry
* @author Puffer Finance
* @notice This contract is used to register and manage gauges for the Puffer Finance protocol.
*/
contract GaugeRegistry is Ownable2Step {
error InvalidAddress();
error GaugeDoesNotExist();
error GaugeAlreadyExists();
error GaugeActivationUnchanged();
event GaugeRegistered(address indexed gauge, string metadataURI);
event GaugeDeactivated(address indexed gauge);
event GaugeActivated(address indexed gauge);
event GaugeMetadataUpdated(address indexed gauge, string oldMetadataURI, string newMetadataURI);
/**
* @dev Gauge info
* @param active Whether the gauge is active
* @param created The timestamp when the gauge was created
* @param metadataURI The URI of the gauge metadata
*/
struct Gauge {
bool active;
uint48 created;
string metadataURI;
}
mapping(address => Gauge) private _gauges;
address[] private _gaugeList;
modifier onlyExistingGauge(address gauge) {
require(gaugeExists(gauge), GaugeDoesNotExist());
_;
}
constructor(address _owner) Ownable(_owner) { }
//// GAUGES MANAGEMENT ////
/**
* @notice Register a new gauge
* @param gauge The address of the gauge to register
* @param metadataURI The URI of the gauge metadata
* @dev Can only be called by the contract owner
*/
function registerGauge(address gauge, string calldata metadataURI) external onlyOwner {
require(gauge != address(0), InvalidAddress());
require(!gaugeExists(gauge), GaugeAlreadyExists());
_gauges[gauge] = Gauge({ active: true, created: uint48(block.timestamp), metadataURI: metadataURI });
_gaugeList.push(gauge);
emit GaugeRegistered(gauge, metadataURI);
}
/**
* @notice Deactivate a gauge
* @param gauge The address of the gauge to deactivate
* @dev Can only be called by the contract owner
*/
function deactivateGauge(address gauge) external onlyOwner onlyExistingGauge(gauge) {
require(isActive(gauge), GaugeActivationUnchanged());
_gauges[gauge].active = false;
emit GaugeDeactivated(gauge);
}
/**
* @notice Activate a gauge
* @param gauge The address of the gauge to activate
* @dev Can only be called by the contract owner
*/
function activateGauge(address gauge) external onlyOwner onlyExistingGauge(gauge) {
require(!isActive(gauge), GaugeActivationUnchanged());
_gauges[gauge].active = true;
emit GaugeActivated(gauge);
}
/**
* @notice Update the metadata of a gauge
* @param gauge The address of the gauge to update
* @param metadataURI The new URI of the gauge metadata
* @dev Can only be called by the contract owner
*/
function updateGaugeMetadata(address gauge, string calldata metadataURI)
external
onlyOwner
onlyExistingGauge(gauge)
{
emit GaugeMetadataUpdated(gauge, _gauges[gauge].metadataURI, metadataURI);
_gauges[gauge].metadataURI = metadataURI;
}
//// GAUGES GETTERS ////
/**
* @notice Check if a gauge exists
* @param gauge The address of the gauge to check
* @return True if the gauge exists, false otherwise
*/
function gaugeExists(address gauge) public view returns (bool) {
return _gauges[gauge].created != 0;
}
/**
* @notice Check if a gauge is active
* @param gauge The address of the gauge to check
* @return True if the gauge is active, false otherwise
*/
function isActive(address gauge) public view returns (bool) {
return _gauges[gauge].active;
}
/**
* @notice Get the list of all gauges addresses
* @return The list of all gauges addresses
*/
function getGaugeList() external view returns (address[] memory) {
return _gaugeList;
}
/**
* @notice Get the details of a gauge
* @param gauge The address of the gauge to get the details of
* @return The details of the gauge
*/
function getGauge(address gauge) external view returns (Gauge memory) {
return _gauges[gauge];
}
}
"
},
"dependencies/@openzeppelin-contracts-5.4.0/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
"
},
"dependencies/@openzeppelin-contracts-5.4.0/access/Ownable2Step.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}
"
},
"dependencies/@openzeppelin-contracts-5.4.0/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
"
}
},
"settings": {
"remappings": [
"@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.4.0/",
"forge-std/=dependencies/forge-std-1.10.0/src/",
"@openzeppelin-contracts-5.4.0/=dependencies/@openzeppelin-contracts-5.4.0/",
"forge-std-1.10.0/=dependencies/forge-std-1.10.0/src/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "prague",
"viaIR": false
}
}}
Submitted on: 2025-10-06 15:57:45
Comments
Log in to comment.
No comments yet.