Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Polymarket/ctf-exchange/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The Auth mixin manages authenticated addresses with two distinct tiers: admins and operators. Admins have the highest level of access control and can add or remove both admins and operators. All admins are equal in authority. The contract deployer is initially designated as the only admin and operator. Source: src/exchange/mixins/Auth.sol

State Variables

admins

mapping(address => uint256) public admins
Mapping of addresses authorized as admins. A value of 1 indicates the address is an admin.

operators

mapping(address => uint256) public operators
Mapping of addresses authorized as operators. A value of 1 indicates the address is an operator.

Modifiers

onlyAdmin

modifier onlyAdmin()
Reverts if the caller is not an admin. Checks if admins[msg.sender] equals 1. Reverts: NotAdmin() if the caller is not an admin.

onlyOperator

modifier onlyOperator()
Reverts if the caller is not an operator. Checks if operators[msg.sender] equals 1. Reverts: NotOperator() if the caller is not an operator.

Constructor

constructor()
Initializes the contract, designating the deployer as the sole admin and operator.

Functions

isAdmin

function isAdmin(address usr) external view returns (bool)
Checks whether an address has been designated as an admin.

Parameters

  • usr (address): The address to check for admin status

Returns

  • bool: true if the address is an admin, false otherwise

isOperator

function isOperator(address usr) external view returns (bool)
Checks whether an address has been designated as an operator.

Parameters

  • usr (address): The address to check for operator status

Returns

  • bool: true if the address is an operator, false otherwise

addAdmin

function addAdmin(address admin_) external onlyAdmin
Adds a new admin by setting their value to 1 in the admins mapping.

Parameters

  • admin_ (address): The address to add as an admin

Requirements

  • Caller must be an admin (onlyAdmin)

Emits

  • NewAdmin(admin_, msg.sender)

addOperator

function addOperator(address operator_) external onlyAdmin
Adds a new operator by setting their value to 1 in the operators mapping.

Parameters

  • operator_ (address): The address to add as an operator

Requirements

  • Caller must be an admin (onlyAdmin)

Emits

  • NewOperator(operator_, msg.sender)

removeAdmin

function removeAdmin(address admin) external onlyAdmin
Removes an existing admin by setting their value to 0 in the admins mapping.

Parameters

  • admin (address): The address to remove as an admin

Requirements

  • Caller must be an admin (onlyAdmin)

Emits

  • RemovedAdmin(admin, msg.sender)

removeOperator

function removeOperator(address operator) external onlyAdmin
Removes an existing operator by setting their value to 0 in the operators mapping.

Parameters

  • operator (address): The address to remove as an operator

Requirements

  • Caller must be an admin (onlyAdmin)

Emits

  • RemovedOperator(operator, msg.sender)

renounceAdminRole

function renounceAdminRole() external onlyAdmin
Removes the admin role for the caller.

Requirements

  • Caller must be an admin (onlyAdmin)

Emits

  • RemovedAdmin(msg.sender, msg.sender)

renounceOperatorRole

function renounceOperatorRole() external onlyOperator
Removes the operator role for the caller.

Requirements

  • Caller must be an operator (onlyOperator)

Emits

  • RemovedOperator(msg.sender, msg.sender)

Events

NewAdmin

event NewAdmin(address indexed newAdminAddress, address indexed admin)
Emitted when a new admin is added.

NewOperator

event NewOperator(address indexed newOperatorAddress, address indexed admin)
Emitted when a new operator is added.

RemovedAdmin

event RemovedAdmin(address indexed removedAdmin, address indexed admin)
Emitted when an admin is removed.

RemovedOperator

event RemovedOperator(address indexed removedOperator, address indexed admin)
Emitted when an operator is removed.

Errors

NotAdmin

error NotAdmin()
Thrown when a caller is not an admin but the function requires admin privileges.

NotOperator

error NotOperator()
Thrown when a caller is not an operator but the function requires operator privileges.

Build docs developers (and LLMs) love