Skip to content

Commit

Permalink
fix: bug with cancelling
Browse files Browse the repository at this point in the history
Would allow the `owner` to be able to "steal" the unvested funds of a stream being cancelled
  • Loading branch information
fubuloubu authored Apr 25, 2024
1 parent b9db3fb commit b1b2249
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contracts/StreamManager.vy
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,14 @@ def cancel_stream(
reason: Bytes[MAX_REASON_SIZE] = b"",
creator: address = msg.sender,
) -> uint256:
assert msg.sender in [creator, self.owner]
assert msg.sender == creator or msg.sender == self.owner
assert self.streams[creator][stream_id].start_time + MIN_STREAM_LIFE <= block.timestamp

funded_amount: uint256 = self.streams[creator][stream_id].funded_amount
amount_locked: uint256 = funded_amount - self._amount_unlocked(creator, stream_id)

token: ERC20 = self.streams[creator][stream_id].token
assert token.transfer(msg.sender, amount_locked, default_return_value=True)
assert token.transfer(creator, amount_locked, default_return_value=True)

self.streams[creator][stream_id].funded_amount = funded_amount - amount_locked

Expand Down

0 comments on commit b1b2249

Please sign in to comment.