# PermissionManager

## PermissionManager

The `PermissionManager` contract implements the basic whitelisting functions for the actors in the permissioned market aka Aave Arc.

The source code can be found on Github [here](https://github.com/aave/protocol-v2/blob/feat/permissioned-market/contracts/protocol/configuration/PermissionManager.sol).

## Protocol Actors

### Whitelister

Only certain entities have permission to '**whitelist'** wallet addresses. These are the `permissionAdmins` that can add/remove permission to wallet address to participate in Aave Arc. Whitelisters are responsible for conducting KYC/AML diligence on the entities or individuals associated with the wallet addresses seeking to interact with the Aave Arc market.

{% hint style="info" %}
A new whitelister can be added only by the Owner of the PermissionManager contract i.e. Aave Governance executor.
{% endhint %}

### Users

Only those individuals/entities with Ethereum wallet addresses that have been “whitelisted” to act in one or more valid role (enumerated👇🏻) have permission to participate in Aave Arc pool.

#### **Permission-ed Roles**

* `0: Depositor`
* `1: Borrower`
* `2: Liquidator`
* `3: Stable Rate Manager`

***

## Methods

### Write Methods

#### addPermissionAdmins

Adds a new whitelister for the permission-ed market.

{% hint style="info" %}
`msg.sender` must be the owner of the contract.
{% endhint %}

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="address[]" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>admins</td><td><span data-option="51dc3fc6f5ea415183f089a71bc24275">address[]</span></td><td>Addresses to be added as market's PermissionAdmin aka whitelisters</td></tr></tbody></table>

#### removePermissionAdmins

Removes an existing whitelister of the permission-ed market.

{% hint style="info" %}
`msg.sender` must be the owner of the contract.
{% endhint %}

<table><thead><tr><th width="192.33333333333331">Param</th><th width="150">Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="address[]" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>admins</td><td><span data-option="51dc3fc6f5ea415183f089a71bc24275">address[]</span></td><td>Addresses to be removed as market's PermissionAdmin aka whitelisters</td></tr></tbody></table>

#### addPermissions

Allows permission admins to whitelist a set of addresses for various permission-ed roles.

{% hint style="info" %}
Few conditions for whitelister:

* `msg.sender` must be a `PermissionAdmin` aka whitelister
* user  **must not be already whitelisted** by some other `PermssionAdmin`
* `roles.length` must be same as `users.length`
{% endhint %}

<table><thead><tr><th width="192.33333333333331">Param</th><th width="150">Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="address[]" color="blue"></option><option value="3570b98a4fae475f9ed12603697a5734" label="uint256[]" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>roles</td><td><span data-option="3570b98a4fae475f9ed12603697a5734">uint256[]</span></td><td>List of permissioned roles to be added for corresponding user addresses</td></tr><tr><td>users</td><td><span data-option="51dc3fc6f5ea415183f089a71bc24275">address[]</span></td><td>User addresses to be whitelisted. This needs to contain the same number of elements as <code>roles</code></td></tr></tbody></table>

#### removePermissions

Allows owner to remove permissions on a set of addresses for varous permission-ed roles.

{% hint style="info" %}
Few conditions for whitelister:&#x20;

* `msg.sender` must be a `PermissionAdmin` aka whitelister
* user **must have beed whitelisted** by same `PermssionAdmin`
* `roles.length` must be same as `users.length`
{% endhint %}

<table><thead><tr><th width="192.33333333333331">Param</th><th width="150">Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="address[]" color="blue"></option><option value="3570b98a4fae475f9ed12603697a5734" label="uint256[]" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>roles</td><td><span data-option="3570b98a4fae475f9ed12603697a5734">uint256[]</span></td><td>List of permissioned roles to be removed for corresponding user addresses</td></tr><tr><td>users</td><td><span data-option="51dc3fc6f5ea415183f089a71bc24275">address[]</span></td><td>User addresses to be removed from whitelisted roles. This needs to contain the same number of elements as <code>roles</code></td></tr></tbody></table>

### View Methods

#### getUserPermissions

Returns the permissions configuration for a specific account.

Call Params

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="address" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>user</td><td><span data-option="51dc3fc6f5ea415183f089a71bc24275">address</span></td><td>address of the user</td></tr></tbody></table>

Return Values

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="uint256" color="blue"></option><option value="f8d26337c5ad4608853049646708361b" label="uint256[]" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>roles</td><td><span data-option="f8d26337c5ad4608853049646708361b">uint256[]</span></td><td>List of roles for which user address has permission</td></tr><tr><td>rolesCount</td><td><span data-option="51dc3fc6f5ea415183f089a71bc24275">uint256</span></td><td>Total number of roles for which user address has permission</td></tr></tbody></table>

#### isInRole

Used to query if a certain account has permission for the given role.

Call Params

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="address" color="blue"></option><option value="841cb72d6aaf4d7eb3ced9054ee01413" label="uint256" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>user</td><td><span data-option="51dc3fc6f5ea415183f089a71bc24275">address</span></td><td>address of the user</td></tr><tr><td>role</td><td><span data-option="841cb72d6aaf4d7eb3ced9054ee01413">uint256</span></td><td><p>whitelisted role</p><p>0: Depositor</p><p>1: Borrower</p><p>2: Liquidator</p><p>3: Stable Rate Manager</p></td></tr></tbody></table>

Return Values

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="uint256" color="blue"></option><option value="f8d26337c5ad4608853049646708361b" label="bool" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>inRole</td><td><span data-option="f8d26337c5ad4608853049646708361b">bool</span></td><td>true if account has permissions for the specified role, else false</td></tr></tbody></table>

#### isInAllRoles

Used to query if a certain account has permission for all of the roles passed as parameter.

Call Params

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="address" color="blue"></option><option value="841cb72d6aaf4d7eb3ced9054ee01413" label="uint256[]" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>user</td><td><span data-option="51dc3fc6f5ea415183f089a71bc24275">address</span></td><td>address of the user</td></tr><tr><td>roles</td><td><span data-option="841cb72d6aaf4d7eb3ced9054ee01413">uint256[]</span></td><td><p>set of whitelisted roles</p><p>0: Depositor</p><p>1: Borrower</p><p>2: Liquidator</p><p>3: Stable Rate Manager</p></td></tr></tbody></table>

Return Values

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="uint256" color="blue"></option><option value="f8d26337c5ad4608853049646708361b" label="bool" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>inRole</td><td><span data-option="f8d26337c5ad4608853049646708361b">bool</span></td><td>true if account has permissions for all the specified roles, else false</td></tr></tbody></table>

#### isInAnyRole

Used to query if a certain account has permission for any of the roles passed as parameter.

Call Params

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="address" color="blue"></option><option value="841cb72d6aaf4d7eb3ced9054ee01413" label="uint256[]" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>user</td><td><span data-option="51dc3fc6f5ea415183f089a71bc24275">address</span></td><td>address of the user</td></tr><tr><td>roles</td><td><span data-option="841cb72d6aaf4d7eb3ced9054ee01413">uint256[]</span></td><td><p>set of whitelisted roles</p><p>0: Depositor</p><p>1: Borrower</p><p>2: Liquidator</p><p>3: Stable Rate Manager</p></td></tr></tbody></table>

Return Values

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="uint256" color="blue"></option><option value="f8d26337c5ad4608853049646708361b" label="bool" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>inRole</td><td><span data-option="f8d26337c5ad4608853049646708361b">bool</span></td><td>true if account has permissions for any of the specified roles, else false</td></tr></tbody></table>

#### isPermissionsAdmin

Returns `true` if the the account has permission to whitelist ie. account is `PermissionAdmin`.

Call Params

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="address" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>admin</td><td><span data-option="51dc3fc6f5ea415183f089a71bc24275">address</span></td><td>address to be verified</td></tr></tbody></table>

Return Values

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="uint256" color="blue"></option><option value="f8d26337c5ad4608853049646708361b" label="bool" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>isPermissionAdmin</td><td><span data-option="f8d26337c5ad4608853049646708361b">bool</span></td><td>true if the account is a PermissionAdmin aka whitelister, else false</td></tr></tbody></table>

#### getUserPermissionAdmin

Returns address of the `PermissionAdmin` that whitelisted (added role for) the given user.

Call Params

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="address" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>user</td><td><span data-option="51dc3fc6f5ea415183f089a71bc24275">address</span></td><td>address of the user</td></tr></tbody></table>

Return Values

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="uint256" color="blue"></option><option value="f8d26337c5ad4608853049646708361b" label="address" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>permissionAdmin</td><td><span data-option="f8d26337c5ad4608853049646708361b">address</span></td><td>address of the whitelister aka PermissionAdmin</td></tr></tbody></table>

#### isUserPermissionAdminValid

Used to query if `PermissionAdmin` that whitelisted given user is still valid and has not been removed from the list of whitelister.

Call Params

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="address" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>user</td><td><span data-option="51dc3fc6f5ea415183f089a71bc24275">address</span></td><td>address of the user whose PermissionAdmin is being validated</td></tr></tbody></table>

Return Values

<table><thead><tr><th width="192.33333333333331">Param</th><th>Type<select><option value="51dc3fc6f5ea415183f089a71bc24275" label="uint256" color="blue"></option><option value="f8d26337c5ad4608853049646708361b" label="bool" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td>isValidPermissionAdmin</td><td><span data-option="f8d26337c5ad4608853049646708361b">bool</span></td><td>true if PermissionAdmin associated with the user address is valid, else false</td></tr></tbody></table>
