Skip to content

Commit 7e039a0

Browse files
committed
chore: 👕
1 parent a450c4d commit 7e039a0

File tree

4 files changed

+134
-165
lines changed

4 files changed

+134
-165
lines changed

Governance/Access Control Manager.md

Lines changed: 28 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
Access control plays a crucial role in the Venus governance model. It is used to restrict functions so that they can only be called from one account or list of accounts (EOA or Contract Accounts).
44

55
# Access Control Manager
6+
67
The implementation of [AccessControlManager](https://github.com/VenusProtocol/isolated-pools/blob/main/contracts/Governance/AccessControlManager.sol) inherits the [Open Zeppelin AccessControl](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControl.sol) contract as a base for role management logic. There are two role types: admin and granular permissions.
78

89
### Granular Roles
910

1011
Granular roles are built by hashing the contract address and its function signature.
1112
For example, Given Contract Foo with function Foo.bar() which is guarded by ACM,
1213
calling `giveRolePermission` for account B do the following:
14+
1315
1. Compute `keccak256(contractFooAddress,functionSignatureBar)`
1416
2. Add the computed role to the roles of account B
1517
3. Account B now can call `ContractFoo.bar()`
@@ -18,14 +20,16 @@ calling `giveRolePermission` for account B do the following:
1820

1921
Admin roles allow for an address to call a function signature on any contract guarded by the AccessControlManager. This is particularly useful for contracts created by factories.
2022

21-
For Admin roles a null address is hashed in place of the contract address (`keccak256(0x0000000000000000000000000000000000000000,functionSignatureBar)`.
23+
For Admin roles a null address is hashed in place of the contract address (`keccak256(0x0000000000000000000000000000000000000000,functionSignatureBar)`.
2224

2325
In the previous example, giving account B the admin role, account B will have permissions to call the bar() function on any contract that is guarded by ACM, not only contract A.
2426

2527
### Protocol Integration
26-
All restricted functions in Venus Protocol use a hook to ACM in order to check if the caller has the right permission to call the guarded function. They call ACM's external method `isAllowedToCall(address caller, string functionSig)`.
27-
Here is an example of how `_setCollateralFactor` function in `Comptroller` is integrated with ACM:
28-
```
28+
29+
All restricted functions in Venus Protocol use a hook to ACM in order to check if the caller has the right permission to call the guarded function. They call ACM's external method `isAllowedToCall(address caller, string functionSig)`.
30+
Here is an example of how `_setCollateralFactor` function in `Comptroller` is integrated with ACM:
31+
32+
```
2933
bool isAllowedToCall = AccessControlManager(accessControl)
3034
.isAllowedToCall(
3135
msg.sender,
@@ -35,136 +39,87 @@ In the previous example, giving account B the admin role, account B will have pe
3539
if (!isAllowedToCall) {
3640
revert Unauthorized();
3741
}
38-
```
39-
42+
```
4043

4144
# Solidity API
4245

43-
44-
4546
## AccessControlManager
4647

47-
48-
4948
This contract is a wrapper of OpenZeppelin AccessControl extending it in a way to standardise access control within Venus Smart Contract Ecosystem.
5049

51-
52-
5350
### constructor
5451

55-
56-
5752
```solidity
5853
5954
constructor() public
6055
6156
```
6257

63-
64-
6558
### isAllowedToCall
6659

67-
68-
6960
```solidity
7061
7162
function isAllowedToCall(address caller, string functionSig) public view returns (bool)
7263
7364
```
7465

75-
76-
7766
Verifies if the given account can call a praticular contract's function
7867

79-
80-
8168
_Since the contract is calling itself this function, we can get contracts address with msg.sender_
8269

83-
84-
8570
#### Parameters
8671

87-
88-
89-
| Name | Type | Description |
90-
| ---- | ---- | ----------- |
91-
| caller | address | contract for which call permissions will be checked |
92-
| functionSig | string | signature e.g. "functionName(uint,bool)" |
93-
94-
72+
| Name | Type | Description |
73+
| ----------- | ------- | --------------------------------------------------- |
74+
| caller | address | contract for which call permissions will be checked |
75+
| functionSig | string | signature e.g. "functionName(uint,bool)" |
9576

9677
#### Return Values
9778

98-
99-
100-
| Name | Type | Description |
101-
| ---- | ---- | ----------- |
102-
| [0] | bool | false if the user account cannot call the particular contract function |
103-
104-
79+
| Name | Type | Description |
80+
| ---- | ---- | ---------------------------------------------------------------------- |
81+
| [0] | bool | false if the user account cannot call the particular contract function |
10582

10683
### giveCallPermission
10784

108-
109-
11085
```solidity
11186
11287
function giveCallPermission(address contractAddress, string functionSig, address accountToPermit) public
11388
11489
```
11590

116-
117-
11891
Gives a function call permission to one single account
11992

120-
121-
122-
_this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE
123-
124-
May emit a {RoleGranted} event._
93+
\_this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE
12594

126-
95+
May emit a {RoleGranted} event.\_
12796

12897
#### Parameters
12998

130-
131-
132-
| Name | Type | Description |
133-
| ---- | ---- | ----------- |
99+
| Name | Type | Description |
100+
| --------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
134101
| contractAddress | address | address of contract for which call permissions will be granted NOTE: if contractAddress is zero address, we give the account DEFAULT_ADMIN_ROLE, meaning that this account can access the certain function on ANY contract managed by this ACL |
135-
| functionSig | string | signature e.g. "functionName(uint,bool)" |
136-
| accountToPermit | address | account that will be given access to the contract function |
137-
138-
102+
| functionSig | string | signature e.g. "functionName(uint,bool)" |
103+
| accountToPermit | address | account that will be given access to the contract function |
139104

140105
### revokeCallPermission
141106

142-
143-
144107
```solidity
145108
146109
function revokeCallPermission(address contractAddress, string functionSig, address accountToRevoke) public
147110
148111
```
149112

150-
151-
152113
Revokes an account's permission to a particular function call
153114

154-
115+
\_this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE
155116

156-
_this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE
157-
158-
May emit a {RoleRevoked} event._
159-
160-
117+
May emit a {RoleRevoked} event.\_
161118

162119
#### Parameters
163120

164-
165-
166-
| Name | Type | Description |
167-
| ---- | ---- | ----------- |
121+
| Name | Type | Description |
122+
| --------------- | ------- | -------------------------------------------------------------- |
168123
| contractAddress | address | address of contract for which call permissions will be revoked |
169-
| functionSig | string | signature e.g. "functionName(uint,bool)" |
170-
| accountToRevoke | address | |
124+
| functionSig | string | signature e.g. "functionName(uint,bool)" |
125+
| accountToRevoke | address | |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Venus Protocol V4
1+
# Venus Protocol V4

SUMMARY.md

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,98 +2,97 @@
22

33
## Getting Started
44

5-
* [V4 Overview](README.md)
6-
* [Contracts Overview](getting-started/contracts-overview.md)
7-
* [V4 Whitepaper]()
5+
- [V4 Overview](README.md)
6+
- [Contracts Overview](getting-started/contracts-overview.md)
7+
- [V4 Whitepaper]()
88

99
## What's New?
1010

11-
* [Isolated Lending](whats-new/isolated-lending.md)
12-
* [Stable Rate Borrowing](whats-new/stable-rate-borrowing.md)
13-
* [VAI Sustainability](whats-new/vai-sustainability.md)
14-
* [Governance](whats-new/governance.md)
15-
* [Supply Borrow Caps](whats-new/supply-borrow-caps.md)
16-
* [Integrated Swap](whats-new/integrated-swap.md)
11+
- [Isolated Lending](whats-new/isolated-lending.md)
12+
- [Stable Rate Borrowing](whats-new/stable-rate-borrowing.md)
13+
- [VAI Sustainability](whats-new/vai-sustainability.md)
14+
- [Governance](whats-new/governance.md)
15+
- [Supply Borrow Caps](whats-new/supply-borrow-caps.md)
16+
- [Integrated Swap](whats-new/integrated-swap.md)
1717

1818
## Guides
1919

20-
* [Supplying](guides/supplying.md)
21-
* [Borrowing](guides/borrowing.md)
22-
* [Governance](guides/governance-guide/README.md)
23-
* [Venus Improvement Proposal](guides/governance-guide/vip.md)
24-
* [Voting](guides/governance-guide/voting.md)
25-
* [Delegating](guides/governance-guide/delegating.md)
26-
* [Contributing](guides/contributing/README.md)
27-
* [Setting up a development environment](guides/contributing/development-environment.md)
28-
* [Testing Guide](guides/contributing/testing-guide.md)
29-
* [Protocol Math](guides/protocol-math.md)
30-
20+
- [Supplying](guides/supplying.md)
21+
- [Borrowing](guides/borrowing.md)
22+
- [Governance](guides/governance-guide/README.md)
23+
- [Venus Improvement Proposal](guides/governance-guide/vip.md)
24+
- [Voting](guides/governance-guide/voting.md)
25+
- [Delegating](guides/governance-guide/delegating.md)
26+
- [Contributing](guides/contributing/README.md)
27+
- [Setting up a development environment](guides/contributing/development-environment.md)
28+
- [Testing Guide](guides/contributing/testing-guide.md)
29+
- [Protocol Math](guides/protocol-math.md)
3130

3231
## Core Pool
3332

34-
* [Comptroller](core-pool/comptroller.md)
35-
* [VTokens](core-pool/vtokens.md)
36-
* [Lens](core-pool/lens.md)
37-
* [Liquidator](core-pool/liquidator.md)
38-
* [Interest Rate Model](core-pool/interest-rate-model.md)
39-
* [Jump Model](core-pool/jump-model.md)
40-
* [Maximillion](core-pool/maximillion.md)
41-
* [Reservoir](core-pool/reservoir.md)
42-
* [VTreasury](core-pool/vtreasury.md)
33+
- [Comptroller](core-pool/comptroller.md)
34+
- [VTokens](core-pool/vtokens.md)
35+
- [Lens](core-pool/lens.md)
36+
- [Liquidator](core-pool/liquidator.md)
37+
- [Interest Rate Model](core-pool/interest-rate-model.md)
38+
- [Jump Model](core-pool/jump-model.md)
39+
- [Maximillion](core-pool/maximillion.md)
40+
- [Reservoir](core-pool/reservoir.md)
41+
- [VTreasury](core-pool/vtreasury.md)
4342

4443
## Isolated Lending
4544

46-
* [Pool Registry](isolated-lending/pool-registry.md)
47-
* [Pool](isolated-lending/pool.md)
48-
* [Liquidations](isolated-lending/liquidations.md)
49-
* [Rewards Distributor](isolated-lending/rewards-distributor.md)
50-
* [Lens](isolated-lending/lens.md)
51-
* [Risk Fund](isolated-lending/risk-fund/README.md)
52-
* [Protocol Share Reserve](isolated-lending/risk-fund/protocol-share-reserve.md)
53-
* [Shortfall](isolated-lending/risk-fund/shortfall.md)
54-
* [Factories](isolated-lending/factories/README.md)
55-
* [VBep20 Immutable Proxy Factory](isolated-lending/factories/VBep20-mmutable-proxy-factory.md)
56-
* [Jump Rate Model](isolated-lending/factories/jump-rate-model.md)
57-
* [White Paper Interest Rate Model Factory](isolated-lending/factories/white-paper-interest-rate-model-factory.md)
45+
- [Pool Registry](isolated-lending/pool-registry.md)
46+
- [Pool](isolated-lending/pool.md)
47+
- [Liquidations](isolated-lending/liquidations.md)
48+
- [Rewards Distributor](isolated-lending/rewards-distributor.md)
49+
- [Lens](isolated-lending/lens.md)
50+
- [Risk Fund](isolated-lending/risk-fund/README.md)
51+
- [Protocol Share Reserve](isolated-lending/risk-fund/protocol-share-reserve.md)
52+
- [Shortfall](isolated-lending/risk-fund/shortfall.md)
53+
- [Factories](isolated-lending/factories/README.md)
54+
- [VBep20 Immutable Proxy Factory](isolated-lending/factories/VBep20-mmutable-proxy-factory.md)
55+
- [Jump Rate Model](isolated-lending/factories/jump-rate-model.md)
56+
- [White Paper Interest Rate Model Factory](isolated-lending/factories/white-paper-interest-rate-model-factory.md)
5857

5958
## Oracles
6059

61-
* [Resilient Oracle](oracles/resilient-oracle.md)
62-
* [Bound Validator](oracles/bound-validator.md)
63-
* [Chainlink](oracles/chainlink.md)
64-
* [Pyth](oracles/pyth.md)
65-
* [Binance](oracles/binance.md)
66-
* [TWAP](oracles/twap.md)
60+
- [Resilient Oracle](oracles/resilient-oracle.md)
61+
- [Bound Validator](oracles/bound-validator.md)
62+
- [Chainlink](oracles/chainlink.md)
63+
- [Pyth](oracles/pyth.md)
64+
- [Binance](oracles/binance.md)
65+
- [TWAP](oracles/twap.md)
6766

6867
## Governance
6968

70-
* [Bravo](governance/bravo.md)
71-
* [Proposals](governance/proposals.md)
72-
* [Voting](governance/voting.md)
73-
* [Delegating](governance/delegating.md)
74-
* [Routes](governance/routes.md)
75-
* [Access Control Manager](governance/access-control-manager.md)
69+
- [Bravo](governance/bravo.md)
70+
- [Proposals](governance/proposals.md)
71+
- [Voting](governance/voting.md)
72+
- [Delegating](governance/delegating.md)
73+
- [Routes](governance/routes.md)
74+
- [Access Control Manager](governance/access-control-manager.md)
7675

7776
## Vaults
7877

79-
* [XVS Vault](vaults/xvs-vault.md)
80-
* [VAI Vault](vaults/vai-vault.md)
81-
* [VRT Vault](vaults/vrt-vault.md)
78+
- [XVS Vault](vaults/xvs-vault.md)
79+
- [VAI Vault](vaults/vai-vault.md)
80+
- [VRT Vault](vaults/vrt-vault.md)
8281

8382
## Tokens
8483

85-
* [VAI](tokens/vai.md)
86-
* [XVS](tokens/xvs.md)
87-
* [VRT](tokens/vrt.md)
88-
84+
- [VAI](tokens/vai.md)
85+
- [XVS](tokens/xvs.md)
86+
- [VRT](tokens/vrt.md)
8987

9088
## Deployed Contracts
9189

92-
* [V4 Testnet](deployed-coxntracts/v4-testnet.md)
93-
* [V4 Mainnet](deployed-contracts/v4-mainnet/README.md)
94-
* [Deployed Contracts](deployed-contracts/deployed-contracts.md)
90+
- [V4 Testnet](deployed-coxntracts/v4-testnet.md)
91+
- [V4 Mainnet](deployed-contracts/v4-mainnet/README.md)
92+
- [Deployed Contracts](deployed-contracts/deployed-contracts.md)
9593

9694
## Links
97-
* [Security & Audits](security-and-audits.md)
98-
* [FAQ]()
99-
* [Bug Bounty]()
95+
96+
- [Security & Audits](security-and-audits.md)
97+
- [FAQ]()
98+
- [Bug Bounty]()

0 commit comments

Comments
 (0)