FREI-PI approach in _cancel
and _withdraw
#7
Replies: 0 comments 10 replies
-
FYI – example of how we use invariants in Aera with the Sablier commenting style: https://github.com/aera-finance/aera-contracts-public/blob/main/v2/AeraV2Factory.sol#L127 |
Beta Was this translation helpful? Give feedback.
-
@andreivladbrg could you please explore the possibility of using FREI-PI in the EOES implementation? |
Beta Was this translation helpful? Give feedback.
-
I just read the article and I say that I like the approach.
I don't get what you mean by "the balance withdrawn matches the initial balance minus the withdraw amount", the balance to withdraw should be less than or equal to the initial balance minus the withdrawn amount. I assume you mean the user-specific invariant, // Checks: the withdraw amount is not greater than the withdrawable amount.
if (amount > withdrawableAmount) {
revert Errors.SablierV2Lockup_Overdraw(streamId, amount, withdrawableAmount);
}
........ Also, my understanding is that in FREI-PI design, the invariant check is over the post-CEI states. That means our invariant should not have action input parameters and should only take into account the protocol states. What do you think of the following user level invariant?For a given stream Functions similar to Protocol level invariant?I can not think of any protocol level invariant that involves simplicity and is not very expensive to compute. Would love to have your thoughts on this. |
Beta Was this translation helpful? Give feedback.
-
I just read this article that introduces a new development principle called FREI-PI (Function Requirements, Effects, Interactions - Protocol Invariants):
You're writing require statements wrong
Which got me thinking: what if we added a
_verifyBalances
check at the end of the function execution in_withdraw
, which would check that the balance withdrawn matches the initial balance minus the withdraw amount?We could then add a similar check in
_cancel
.Beta Was this translation helpful? Give feedback.
All reactions