sablier-labs / flow

🍃 Smart contracts of the Sablier Flow protocol.
Other
10 stars 2 forks source link

Implement `FlowAdminHandler` & invariants to test against admin functions #241

Closed smol-ninja closed 1 month ago

smol-ninja commented 2 months ago

Discussed in https://github.com/sablier-labs/flow/discussions/239

Context

Given that now we have two admin related functions: recover and collectProtocolRevenue, implement invariants that make sure that any of the admin functions don't lead to an unexpected behaviour.

Implementation

  1. contract FlowAdminHandler
  2. functions collectRevenue and recover in FlowAdminHandler
  3. variables mapping (IERC20 token => uint256) protocolRevenue and mapping (IERC20 token => uint256) aggregateBalance in FlowStore
  4. functions token.transfer so that invariant can make random deposits to Flow contract

Invariants

  1. $\text{all stream balance sum} + \text{revenue} = \text{aggregate balance}$
  2. $\text{aggregate balance} \le \text{token balance}$