sablier-labs / flow

🍃 Smart contracts of the Sablier Flow protocol.
Other
8 stars 0 forks source link

Rules for emitted events #164

Closed smol-ninja closed 4 months ago

smol-ninja commented 4 months ago

I think there are a few inconsistencies among the events emitted. So I decided to make rules for them.

Rules

  1. All events must contain streamId and asset as the first two entries.
  2. streamId must always be indexed so that it can be used to track down actions for that stream Id.
  3. If there is a transfer of asset, the asset must be indexed.
  4. If there is a transfer of asset, the counterparty, which is sending/receiving the asset, must be indexed.
  5. As an exception, create must have sender and recipient indexed.
  6. No indexing otherwise.

Here is the revised version:

event AdjustFlowStream(
    uint256 indexed streamId, uint128 amountOwed, uint128 newRatePerSecond, uint128 oldRatePerSecond
);

event CreateFlowStream(
    uint256 indexed streamId,
    IERC20 asset,
    address indexed recipient,
    address indexed sender,
    uint40 lastTimeUpdate,
    uint128 ratePerSecond
);

event DepositFlowStream(
    uint256 indexed streamId, IERC20 indexed asset, address indexed funder, uint128 depositAmount
);

event PauseFlowStream(
    uint256 indexed streamId, IERC20 asset, address recipient, address sender, uint128 amountOwed
);

event RefundFromFlowStream(
    uint256 indexed streamId, IERC20 indexed asset, address indexed sender, uint128 refundAmount
);

event RestartFlowStream(
    uint256 indexed streamId, IERC20 asset, address recipient, address sender, uint128 ratePerSecond
);

event WithdrawFromFlowStream(
    uint256 indexed streamId, IERC20 indexed asset, address indexed to, uint128 withdrawnAmount
);

RFC @andreivladbrg.