Skip to content

Commit e2f65b8

Browse files
committed
docs: certora documentation of authorization
1 parent 3d75282 commit e2f65b8

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

certora/README.md

+31-4
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,40 @@ invariant alwaysCollateralized(MorphoHarness.Id id, address borrower)
109109

110110
More generally, this means that the result of liquidating a position multiple times eventually lead to a healthy position (possibly empty).
111111

112-
## Safety
112+
## Authorization
113+
114+
Morpho Blue also defines primitive authorization system, where users can authorize an account to fully manage their position.
115+
This allows to rebuild more granular control of the position on top by authorizing an immutable contract with limited capabilities.
116+
The authorization is verified to be sound in the sense that no user can modify the position of another user without proper authorization (except when liquidating).
117+
118+
Let's detail the rule that makes sure that the supply side stays consistent.
119+
120+
```solidity
121+
rule userCannotLoseSupplyShares(env e, method f, calldataarg data)
122+
filtered { f -> !f.isView }
123+
{
124+
MorphoHarness.Id id;
125+
address user;
126+
127+
// Assume that the e.msg.sender is not authorized.
128+
require !isAuthorized(user, e.msg.sender);
129+
require user != e.msg.sender;
113130
114-
### Authorization
131+
mathint sharesBefore = supplyShares(id, user);
115132
116-
Morpho Blue also defines a sound authorization system where users cannot modify positions of other users without proper authorization (except when liquidating).
133+
f(e, data);
117134
118-
Positions of users are also independent, so loans cannot be impacted by loans from other users.
135+
mathint sharesAfter = supplyShares(id, user);
136+
137+
assert sharesAfter >= sharesBefore;
138+
}
139+
```
140+
141+
In the previous rule, an arbitrary function of Morpho Blue `f` is called with arbitrary `data`.
142+
Shares of `user` on the market identified by `id` are recorded before and after this call.
143+
In this way, it is checked that the supply shares are increasing when the caller of the function is neither the owner of those shares (`user != e.msg.sender`) nor authorized (`!isAuthorized(user, e.msg.sender)`).
144+
145+
## Safety
119146

120147
### Others
121148

0 commit comments

Comments
 (0)