# Roles and permissions

The protocol uses [OpenZeppelin's AccessControl](https://docs.openzeppelin.com/contracts/4.x/api/access#AccessControl) mechanism. The roles and delegations are managed by the [AccesManager](https://docs.ensuro.co/ensuro-docs/smart-contracts/contracts/accessmanager) smart contract.

In some operations, both global roles and component roles are accepted. [Component roles](https://docs.ensuro.co/ensuro-docs/contracts/accessmanager#component-roles) are special roles that are restricted to a specific component (eToken, RiskModule, or PremiumsAccount).

## Common Roles

These roles are defined at the protocol level and are used across its components. They form the core of the access control structure.

<table><thead><tr><th width="193">Role</th><th>Description</th><th>Methods accessible</th></tr></thead><tbody><tr><td><strong>LEVEL1_ROLE</strong></td><td>High impact changes like upgrades or other critical operations.</td><td><ul><li><a href="#pause-unpause">unpause</a>: Pauses the smart contract.</li><li><a href="#upgrade">upgrade</a>: Upgrade to the smart contract implementation.</li></ul></td></tr><tr><td><strong>LEVEL2_ROLE</strong></td><td>Mid-impact changes like changing some parameters.</td><td>-</td></tr><tr><td><strong>LEVEL3_ROLE</strong></td><td>Low-impact changes like changing some parameters up to given percentage (tweaks).</td><td>-</td></tr><tr><td><strong>GUARDIAN_ROLE</strong></td><td><p>For emergency operations oriented to protect the protocol in case of attacks or hacking.</p><p></p></td><td><ul><li><a href="#pause-unpause">pause</a>: Pauses the smart contract.</li><li><a href="#pause-unpause">unpause</a>: Unpause the smart contract.</li><li><a href="#upgrade">upgrade</a>: Upgrade the smart contract implementation.</li></ul></td></tr><tr><td><strong>DEFAULT_ADMIN_ROLE</strong></td><td>By default, it is the admin role for all roles, which means that only accounts with this role will be able to grant or revoke other roles. See  <a href="https://docs.openzeppelin.com/contracts/4.x/access-control">OpenZeppelin's documentation</a> for additional details.</td><td><p></p><ul><li>grantRole: Grants a role to an account.</li><li>revokeRole: Revokes  a role to an account.</li><li>grantComponentRole: Assigns the specified role to the specified account within the component identified by the address component.</li><li>setComponentRoleAdmin: Sets the component-role admin for a specific component or for any component within the contract.</li></ul></td></tr></tbody></table>

## Component roles

Besides the general use roles described above, each contract can have its own defined roles for specific operations. For components of the protocol these roles are called [Component Roles](https://docs.ensuro.co/ensuro-docs/contracts/accessmanager#component-roles) and a detailed description of each can be found in each contract's documentation:

* [EToken](https://docs.ensuro.co/ensuro-docs/contracts/etoken#component-roles)
* [RiskModule](https://docs.ensuro.co/ensuro-docs/contracts/riskmodule#component-roles)
* [TrustFullRiskModule](https://docs.ensuro.co/ensuro-docs/contracts/riskmodule/trustfulriskmodule#component-roles)
* [SignedQuoteRiskModule](https://docs.ensuro.co/ensuro-docs/contracts/riskmodule/signedquoteriskmodule#component-roles)
* [SignedBucketRiskModule](https://docs.ensuro.co/ensuro-docs/contracts/riskmodule/signedbucketriskmodule#component-roles)
* [PriceRiskModule](https://docs.ensuro.co/ensuro-docs/contracts/riskmodule/priceriskmodule#component-roles)
* [PremiumsAccount](https://docs.ensuro.co/ensuro-docs/contracts/premiumsaccount#component-roles)
* [AccessManager](https://docs.ensuro.co/ensuro-docs/contracts/accessmanager#component-roles)
* [LPManualWhiteList](https://docs.ensuro.co/ensuro-docs/contracts/ilpwhitelist/lpmanualwhitelist#component-roles)

## Common Operations

### Upgrade

Ensuro contracts are upgradeable, following the [UUPS](https://eips.ethereum.org/EIPS/eip-1822) pattern and implemented based on [OpenZeppelin implementation](https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable).&#x20;

Only users with the roles **LEVEL1\_ROLE** or **GUARDIAN\_ROLE** can execute upgrades. For global contracts such as PolicyPool and AccessManager, the role granted has to be global. For other components it can be a component role.

### Pause / Unpause

Also, most of the contracts support `pause()` and `unpause()` operations. The behavior changes from one contract to the other, but in general, most of the critical operations are rejected when the contract is paused. Check the source code for more details.

Only users with the role **GUARDIAN\_ROLE** can pause contracts. To resume (unpause) a contract, the transaction needs to be executed by a user with either **GUARDIAN\_ROLE** or **LEVEL1\_ROLE***.*

###
