Skip to content

Commit 961b927

Browse files
authored
Cosmetic & Added finance/Vesting (#23)
1 parent 1bdea83 commit 961b927

21 files changed

+688
-49
lines changed

docs/getting-started/contribution/solidity.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ interface IBadEventParameterNames {
260260

261261
#### 2.6 Constant and immutable variables
262262

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. 
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.
264264

265265
<Tabs>
266266
<TabItem value="good" label="Good" default>
@@ -464,7 +464,7 @@ contract BadErrorMessages {
464464

465465
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.
466466

467-
#### 5.1 Unchecked &#x20;
467+
#### 5.1 Unchecked
468468

469469
Use `unchecked` statements only to migrate code from older Solidity versions. Avoid using it for loop iterator variables as it reduces readability.
470470

docs/getting-started/contribution/tests.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,28 @@ $ npm run coverage
2929

3030
Expected output.
3131

32-
<table><thead><tr><th>File</th><th>% Stmts</th><th>% Branch</th><th>% Funcs</th><th>% Lines</th></tr></thead><tbody><tr><td>All files</td><td>100</td><td>100</td><td>100</td><td>100</td></tr></tbody></table>
33-
34-
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.&#x20;
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.
3554

3655
```solidity
3756
contract PriorityQueueMock {

docs/getting-started/guides/access/merkle-whitelisted.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 🤠 Merkle Whitelisted
1+
# 📗 Merkle Whitelisted
22

33
## Introduction
44

docs/getting-started/guides/access/role-based-access-module-rbac.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 😎 Role Based Access Module (RBAC)
1+
# 📚 Role Based Access Module (RBAC)
22

33
## Introduction
44

@@ -41,7 +41,32 @@ The `RBAC` contract comes with a pre-configured `MASTER` role. By default, the `
4141

4242
Functions for managing `Roles`:
4343

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>
4570

4671
#### 4 Group (extension)
4772

@@ -51,7 +76,36 @@ If the default group is enabled, it will automatically include every user. The i
5176

5277
Functions for managing `Group`:
5378

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>
106+
</tr>
107+
</tbody>
108+
</table>
55109

56110
## Example
57111

docs/getting-started/guides/compound-rate-keeper/compound-rate-keeper.md

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Introduction
44

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).&#x20;
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).
66

77
## Implementation
88

@@ -22,11 +22,69 @@ Note, that the _compoundRate_ is calculated with the **precision** of `10**25`.
2222

2323
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:
2424

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>
2667

2768
Additionally, there are a couple of internal functions to update the capitalization rate or capitalization period:
2869

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>
3088

3189
The core function containing the rate calculation logic is `getFutureCompoundRate`, which eventually returns the new rate.
3290

docs/getting-started/guides/contracts-registry/contracts-registry.md

Lines changed: 110 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 🗒 Contracts Registry
1+
# 🗒 Contracts Registry
22

33
## Introduction
44

@@ -29,7 +29,40 @@ Behind the scenes, the `ContractRegistry` maintains a mapping of string contract
2929

3030
Functions featured by the `ContractsRegisry`:
3131

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>
32+
<table>
33+
<thead>
34+
<tr>
35+
<th>Function</th>
36+
<th>Description</th>
37+
</tr>
38+
</thead>
39+
<tbody>
40+
<tr>
41+
<td><code>injectDependencies</code>, <code>injectDependenciesWithData</code></td>
42+
<td>Injects the dependencies into the given contract</td>
43+
</tr>
44+
<tr>
45+
<td><code>upgradeContract</code>, <code>upgradeContractAndCall</code></td>
46+
<td>Upgrades added proxy contract with a new implementation</td>
47+
</tr>
48+
<tr>
49+
<td><code>addContract</code></td>
50+
<td>Adds contracts that the system does not have direct upgradeability control over, or the contracts that are not upgradeable</td>
51+
</tr>
52+
<tr>
53+
<td><code>addProxyContract</code>, <code>addProxyContractAndCall</code></td>
54+
<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>
3366

3467
#### 2 Dependency Injection
3568

@@ -41,17 +74,88 @@ To facilitate the deployment and management of pool contracts, the `PoolRegistry
4174

4275
Functions featured by the `PoolRegistry`:
4376

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>
77+
<table>
78+
<thead>
79+
<tr>
80+
<th>Function</th>
81+
<th>Description</th>
82+
</tr>
83+
</thead>
84+
<tbody>
85+
<tr>
86+
<td><code>setNewImplementations</code></td>
87+
<td>Sets pools' implementations</td>
88+
</tr>
89+
<tr>
90+
<td><code>injectDependenciesToExistingPools, injectDependenciesToExistingPoolsWithData</code></td>
91+
<td>Injects dependencies to the pools</td>
92+
</tr>
93+
<tr>
94+
<td><code>addProxyPool</code></td>
95+
<td>Adds new pools</td>
96+
</tr>
97+
</tbody>
98+
</table>
4599

46100
Functions featured by the `PoolFactory`:
47101

48-
<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>
49128

50129
#### 4 Presets
51130

52131
The Contracts Registry module includes several preset contracts to help you establish permissions.
53132

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>
133+
<table>
134+
<thead>
135+
<tr>
136+
<th>Function</th>
137+
<th>Description</th>
138+
</tr>
139+
</thead>
140+
<tbody>
141+
<tr>
142+
<td><a href="https://github.com/dl-solarity/solidity-lib/blob/master/contracts/contracts-registry/presets/OwnableContractsRegistry.sol">OwnableContractsRegistry</a></td>
143+
<td>Only the owner can inject dependencies into, add, remove, and upgrade contracts</td>
144+
</tr>
145+
<tr>
146+
<td><a href="https://github.com/dl-solarity/solidity-lib/blob/master/contracts/contracts-registry/presets/MultiOwnableContractsRegistry.sol">MultiOwnableContractsRegistry</a></td>
147+
<td>Only multiple owners can inject dependencies into, add, remove, and upgrade contracts</td>
148+
</tr>
149+
<tr>
150+
<td><a href="https://github.com/dl-solarity/solidity-lib/blob/master/contracts/contracts-registry/pools/presets/OwnablePoolContractsRegistry.sol">OwnablePoolContractsRegistry</a></td>
151+
<td>Only the owner can call set pools' implementations and inject dependencies into existing pools</td>
152+
</tr>
153+
<tr>
154+
<td><a href="https://github.com/dl-solarity/solidity-lib/blob/master/contracts/contracts-registry/pools/presets/MultiOwnablePoolContractsRegistry.sol">MultiOwnablePoolContractsRegistry</a></td>
155+
<td>Only multiple owners can call set pools' implementations and inject dependencies into existing pools</td>
156+
</tr>
157+
</tbody>
158+
</table>
55159

56160
## Example
57161

@@ -97,7 +201,7 @@ contract SystemContract2 {
97201
}
98202
```
99203

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`.&#x20;
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`.
101205

102206
```solidity
103207
function migration() external {

0 commit comments

Comments
 (0)