You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Constant and immutable variables are named with SCREAMING\_SNAKE\_CASE. Internal and private constant and immutable variables are named with an underscore before the name, while public ones have no underscore. 
263
+
Constant and immutable variables are named with SCREAMING\_SNAKE\_CASE. Internal and private constant and immutable variables are named with an underscore before the name, while public ones have no underscore.
264
264
265
265
<Tabs>
266
266
<TabItemvalue="good"label="Good"default>
@@ -464,7 +464,7 @@ contract BadErrorMessages {
464
464
465
465
While we prioritize gas optimization in our code, readability remains equally important. As such, we don't engage in extreme optimization practices that could obscure code understanding or maintainability. To guide our approach, below are examples illustrating when optimization is necessary and when it's not.
466
466
467
-
#### 5.1 Unchecked 
467
+
#### 5.1 Unchecked
468
468
469
469
Use `unchecked` statements only to migrate code from older Solidity versions. Avoid using it for loop iterator variables as it reduces readability.
Sometimes, reaching 100% coverage can be challenging. For these situations, we recommend creating a contract within the `contracts/mock` folder. While mock contracts themselves are not included in the coverage metrics, they are highly beneficial. These can either inherit from the contract you're testing or provide specific functions to test a library. In tests, you can use these mock contracts to replace the original contract or library. 
32
+
<table>
33
+
<thead>
34
+
<tr>
35
+
<th>File</th>
36
+
<th>% Stmts</th>
37
+
<th>% Branch</th>
38
+
<th>% Funcs</th>
39
+
<th>% Lines</th>
40
+
</tr>
41
+
</thead>
42
+
<tbody>
43
+
<tr>
44
+
<td>All files</td>
45
+
<td>100</td>
46
+
<td>100</td>
47
+
<td>100</td>
48
+
<td>100</td>
49
+
</tr>
50
+
</tbody>
51
+
</table>
52
+
53
+
Sometimes, reaching 100% coverage can be challenging. For these situations, we recommend creating a contract within the `contracts/mock` folder. While mock contracts themselves are not included in the coverage metrics, they are highly beneficial. These can either inherit from the contract you're testing or provide specific functions to test a library. In tests, you can use these mock contracts to replace the original contract or library.
Copy file name to clipboardExpand all lines: docs/getting-started/guides/access/role-based-access-module-rbac.md
+57-3Lines changed: 57 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# 😎 Role Based Access Module (RBAC)
1
+
# 📚 Role Based Access Module (RBAC)
2
2
3
3
## Introduction
4
4
@@ -41,7 +41,32 @@ The `RBAC` contract comes with a pre-configured `MASTER` role. By default, the `
41
41
42
42
Functions for managing `Roles`:
43
43
44
-
<table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>grantRoles</code></td><td>Grants a set of <code>Roles</code> to the specified user</td></tr><tr><td><code>revokeRoles</code></td><td>Revokes a set of <code>Roles</code> from the specified user</td></tr><tr><td><code>addPermissionsToRole</code></td><td>Assigns a combination of <code>Resource</code> and its <code>Permissions</code> to a <code>Role</code> with an indicator to either allow or deny access</td></tr><tr><td><code>removePermissionsFromRole</code></td><td>Removes a combination of <code>Resource</code> and its <code>Permissions</code> from a <code>Role</code> with an indicator to either allow or deny access</td></tr></tbody></table>
44
+
<table>
45
+
<thead>
46
+
<tr>
47
+
<th>Function</th>
48
+
<th>Description</th>
49
+
</tr>
50
+
</thead>
51
+
<tbody>
52
+
<tr>
53
+
<td><code>grantRoles</code></td>
54
+
<td>Grants a set of <code>Roles</code> to the specified user</td>
55
+
</tr>
56
+
<tr>
57
+
<td><code>revokeRoles</code></td>
58
+
<td>Revokes a set of <code>Roles</code> from the specified user</td>
59
+
</tr>
60
+
<tr>
61
+
<td><code>addPermissionsToRole</code></td>
62
+
<td>Assigns a combination of <code>Resource</code> and its <code>Permissions</code> to a <code>Role</code> with an indicator to either allow or deny access</td>
63
+
</tr>
64
+
<tr>
65
+
<td><code>removePermissionsFromRole</code></td>
66
+
<td>Removes a combination of <code>Resource</code> and its <code>Permissions</code> from a <code>Role</code> with an indicator to either allow or deny access</td>
67
+
</tr>
68
+
</tbody>
69
+
</table>
45
70
46
71
#### 4 Group (extension)
47
72
@@ -51,7 +76,36 @@ If the default group is enabled, it will automatically include every user. The i
51
76
52
77
Functions for managing `Group`:
53
78
54
-
<table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>addUserToGroups</code></td><td>Adds a user to specified groups</td></tr><tr><td><code>removeUserFromGroups</code></td><td>Removes a user from specific groups</td></tr><tr><td><code>grantGroupRoles</code></td><td>Assigns a list of <code>Roles</code> to the specific group</td></tr><tr><td><code>revokeGroupRoles</code></td><td>Removes a list of <code>Roles</code> from the specified group</td></tr><tr><td><code>toggleDefaultGroup</code></td><td>Toggles the default group state between enabled and disabled</td></tr></tbody></table>
79
+
<table>
80
+
<thead>
81
+
<tr>
82
+
<th>Function</th>
83
+
<th>Description</th>
84
+
</tr>
85
+
</thead>
86
+
<tbody>
87
+
<tr>
88
+
<td><code>addUserToGroups</code></td>
89
+
<td>Adds a user to specified groups</td>
90
+
</tr>
91
+
<tr>
92
+
<td><code>removeUserFromGroups</code></td>
93
+
<td>Removes a user from specific groups</td>
94
+
</tr>
95
+
<tr>
96
+
<td><code>grantGroupRoles</code></td>
97
+
<td>Assigns a list of <code>Roles</code> to the specific group</td>
98
+
</tr>
99
+
<tr>
100
+
<td><code>revokeGroupRoles</code></td>
101
+
<td>Removes a list of <code>Roles</code> from the specified group</td>
102
+
</tr>
103
+
<tr>
104
+
<td><code>toggleDefaultGroup</code></td>
105
+
<td>Toggles the default group state between enabled and disabled</td>
Copy file name to clipboardExpand all lines: docs/getting-started/guides/compound-rate-keeper/compound-rate-keeper.md
+61-3Lines changed: 61 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## Introduction
4
4
5
-
The Compound Rate Keeper module is designed to be employed in lending protocols to compute interest and borrow rates, as well as in staking contracts to determine users' rewards accrual with a fixed Annual Percentage Yield (APY). 
5
+
The Compound Rate Keeper module is designed to be employed in lending protocols to compute interest and borrow rates, as well as in staking contracts to determine users' rewards accrual with a fixed Annual Percentage Yield (APY).
6
6
7
7
## Implementation
8
8
@@ -22,11 +22,69 @@ Note, that the _compoundRate_ is calculated with the **precision** of `10**25`.
22
22
23
23
The `AbstractCompoundRateKeeper` contract defines the calculation of the compound rate and can serve as a base for implementing diverse lending or staking calculations. This contract includes the following public functions:
24
24
25
-
<table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>emergencyUpdateCompoundRate</code></td><td>Updates the compound rate. If overflows, sets <code>isMaxRateReached</code> to true</td></tr><tr><td><code>getCompoundRate</code></td><td>Returns current compound rate</td></tr><tr><td><code>getFutureCompoundRate</code></td><td>Returns future compound rate</td></tr><tr><td><code>getCapitalizationRate</code></td><td>Returns current capitalization rate</td></tr><tr><td><code>getCapitalizationPeriod</code></td><td>Returns current capitalization period</td></tr><tr><td><code>getLastUpdate</code></td><td>Returns timestamp of the last update</td></tr><tr><td><code>getIsMaxRateReached</code></td><td>Returns whether the max rate is reached</td></tr><tr><td><code>getCurrentRate</code></td><td>Returns current rate</td></tr></tbody></table>
25
+
<table>
26
+
<thead>
27
+
<tr>
28
+
<th>Function</th>
29
+
<th>Description</th>
30
+
</tr>
31
+
</thead>
32
+
<tbody>
33
+
<tr>
34
+
<td><code>emergencyUpdateCompoundRate</code></td>
35
+
<td>Updates the compound rate. If overflows, sets <code>isMaxRateReached</code> to true</td>
36
+
</tr>
37
+
<tr>
38
+
<td><code>getCompoundRate</code></td>
39
+
<td>Returns current compound rate</td>
40
+
</tr>
41
+
<tr>
42
+
<td><code>getFutureCompoundRate</code></td>
43
+
<td>Returns future compound rate</td>
44
+
</tr>
45
+
<tr>
46
+
<td><code>getCapitalizationRate</code></td>
47
+
<td>Returns current capitalization rate</td>
48
+
</tr>
49
+
<tr>
50
+
<td><code>getCapitalizationPeriod</code></td>
51
+
<td>Returns current capitalization period</td>
52
+
</tr>
53
+
<tr>
54
+
<td><code>getLastUpdate</code></td>
55
+
<td>Returns timestamp of the last update</td>
56
+
</tr>
57
+
<tr>
58
+
<td><code>getIsMaxRateReached</code></td>
59
+
<td>Returns whether the max rate is reached</td>
60
+
</tr>
61
+
<tr>
62
+
<td><code>getCurrentRate</code></td>
63
+
<td>Returns current rate</td>
64
+
</tr>
65
+
</tbody>
66
+
</table>
26
67
27
68
Additionally, there are a couple of internal functions to update the capitalization rate or capitalization period:
28
69
29
-
<table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>_setCapitalizationRate</code></td><td>Sets the capitalization rate</td></tr><tr><td><code>_setCapitalizationPeriod</code></td><td>Sets the capitalization period</td></tr></tbody></table>
70
+
<table>
71
+
<thead>
72
+
<tr>
73
+
<th>Function</th>
74
+
<th>Description</th>
75
+
</tr>
76
+
</thead>
77
+
<tbody>
78
+
<tr>
79
+
<td><code>_setCapitalizationRate</code></td>
80
+
<td>Sets the capitalization rate</td>
81
+
</tr>
82
+
<tr>
83
+
<td><code>_setCapitalizationPeriod</code></td>
84
+
<td>Sets the capitalization period</td>
85
+
</tr>
86
+
</tbody>
87
+
</table>
30
88
31
89
The core function containing the rate calculation logic is `getFutureCompoundRate`, which eventually returns the new rate.
Copy file name to clipboardExpand all lines: docs/getting-started/guides/contracts-registry/contracts-registry.md
+110-6Lines changed: 110 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# 🗒 Contracts Registry
1
+
# 🗒️ Contracts Registry
2
2
3
3
## Introduction
4
4
@@ -29,7 +29,40 @@ Behind the scenes, the `ContractRegistry` maintains a mapping of string contract
29
29
30
30
Functions featured by the `ContractsRegisry`:
31
31
32
-
<table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>injectDependencies</code>, <code>injectDependenciesWithData</code></td><td>Injects the dependencies into the given contract</td></tr><tr><td><code>upgradeContract</code>, <code>upgradeContractAndCall</code></td><td>Upgrades added proxy contract with a new implementation</td></tr><tr><td><code>addContract</code></td><td>Adds contracts that the system does not have direct upgradeability control over, or the contracts that are not upgradeable</td></tr><tr><td><code>addProxyContract</code>, <code>addProxyContractAndCall</code></td><td>Adds the contracts and deploys the proxy above them</td></tr><tr><td><code>justAddProxyContract</code></td><td>Adds the already deployed proxy</td></tr><tr><td><code>removeContact</code></td><td>Removes the contract</td></tr></tbody></table>
<td>Adds the contracts and deploys the proxy above them</td>
55
+
</tr>
56
+
<tr>
57
+
<td><code>justAddProxyContract</code></td>
58
+
<td>Adds the already deployed proxy</td>
59
+
</tr>
60
+
<tr>
61
+
<td><code>removeContact</code></td>
62
+
<td>Removes the contract</td>
63
+
</tr>
64
+
</tbody>
65
+
</table>
33
66
34
67
#### 2 Dependency Injection
35
68
@@ -41,17 +74,88 @@ To facilitate the deployment and management of pool contracts, the `PoolRegistry
41
74
42
75
Functions featured by the `PoolRegistry`:
43
76
44
-
<table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>setNewImplementations</code></td><td>Sets pools' implementations</td></tr><tr><td><code>injectDependenciesToExistingPools, injectDependenciesToExistingPoolsWithData</code></td><td>Injects dependencies to the pools</td></tr><tr><td><code>addProxyPool</code></td><td>Adds new pools</td></tr></tbody></table>
<table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>deploy</code></td><td>Deploys Beacon Proxy pointing to the pool implementation taken from the <code>PoolRegistry</code></td></tr><tr><td><code>deploy2</code></td><td>Deploys Beacon Proxy pointing to the pool implementation taken from the <code>PoolRegistry</code> using the create2 mechanism</td></tr><tr><td><code>register</code></td><td>Registers newly deployed pool in the <code>PoolRegistry</code></td></tr><tr><td><code>injectDependencies</code></td><td>Injects dependencies to the newly deployed pool and sets <code>PoolRegistry</code> as an injector</td></tr></tbody></table>
102
+
<table>
103
+
<thead>
104
+
<tr>
105
+
<th>Function</th>
106
+
<th>Description</th>
107
+
</tr>
108
+
</thead>
109
+
<tbody>
110
+
<tr>
111
+
<td><code>deploy</code></td>
112
+
<td>Deploys Beacon Proxy pointing to the pool implementation taken from the <code>PoolRegistry</code></td>
113
+
</tr>
114
+
<tr>
115
+
<td><code>deploy2</code></td>
116
+
<td>Deploys Beacon Proxy pointing to the pool implementation taken from the <code>PoolRegistry</code> using the create2 mechanism</td>
117
+
</tr>
118
+
<tr>
119
+
<td><code>register</code></td>
120
+
<td>Registers the newly deployed pool in the <code>PoolRegistry</code></td>
121
+
</tr>
122
+
<tr>
123
+
<td><code>injectDependencies</code></td>
124
+
<td>Injects dependencies into the newly deployed pool and sets <code>PoolRegistry</code> as an injector</td>
125
+
</tr>
126
+
</tbody>
127
+
</table>
49
128
50
129
#### 4 Presets
51
130
52
131
The Contracts Registry module includes several preset contracts to help you establish permissions.
53
132
54
-
<table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><a href="https://github.com/dl-solarity/solidity-lib/blob/master/contracts/contracts-registry/presets/OwnableContractsRegistry.sol">OwnableContractsRegistry</a></td><td>Only the owner can inject dependencies into, add, remove, and upgrade contracts</td></tr><tr><td><a href="https://github.com/dl-solarity/solidity-lib/blob/master/contracts/contracts-registry/presets/MultiOwnableContractsRegistry.sol">MultiOwnableContractsRegistry</a></td><td>Only multiple owners can inject dependencies into, add, remove, and upgrade contracts</td></tr><tr><td><a href="https://github.com/dl-solarity/solidity-lib/blob/master/contracts/contracts-registry/pools/presets/OwnablePoolContractsRegistry.sol">OwnablePoolContractsRegistry</a></td><td>Only the owner can call set pools' implementations and inject dependencies into existing pools</td></tr><tr><td><a href="https://github.com/dl-solarity/solidity-lib/blob/master/contracts/contracts-registry/pools/presets/MultiOwnablePoolContractsRegistry.sol">MultiOwnablePoolContractsRegistry</a></td><td>Only multiple owners can call set pools' implementations and inject dependencies into existing pools</td></tr></tbody></table>
<td>Only multiple owners can call set pools' implementations and inject dependencies into existing pools</td>
156
+
</tr>
157
+
</tbody>
158
+
</table>
55
159
56
160
## Example
57
161
@@ -97,7 +201,7 @@ contract SystemContract2 {
97
201
}
98
202
```
99
203
100
-
To initiate the migration process, begin by deploying and initializing the `ContractsRegistry` contract. Following this, deploy all system contracts and register them. In this example, `SystemContract1` is deployed under the transparent proxy managed by `ContractsRegistry`, while `SystemContract2` is added as is. Conclude by injecting dependencies into the `SystemContract1`. 
204
+
To initiate the migration process, begin by deploying and initializing the `ContractsRegistry` contract. Following this, deploy all system contracts and register them. In this example, `SystemContract1` is deployed under the transparent proxy managed by `ContractsRegistry`, while `SystemContract2` is added as is. Conclude by injecting dependencies into the `SystemContract1`.
0 commit comments