Skip to content

Commit

Permalink
refactor: remove unnecessary min and rename claim_amount
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Sep 5, 2024
1 parent 74b991c commit e727bce
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions contracts/StreamManager.vy
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,15 @@ def cancel_stream(

@external
def claim(creator: address, stream_id: uint256) -> uint256:
funded_amount: uint256 = self.streams[creator][stream_id].funded_amount
claimed_amount: uint256 = min(
self._amount_unlocked(creator, stream_id),
funded_amount,
)

claim_amount: uint256 = self._amount_unlocked(creator, stream_id)
token: ERC20 = self.streams[creator][stream_id].token
assert token.transfer(self.owner, claimed_amount, default_return_value=True)

self.streams[creator][stream_id].funded_amount = funded_amount - claimed_amount
assert token.transfer(self.owner, claim_amount, default_return_value=True)

funded_amount: uint256 = self.streams[creator][stream_id].funded_amount
self.streams[creator][stream_id].funded_amount = funded_amount - claim_amount
self.streams[creator][stream_id].last_pull = block.timestamp

log Claimed(creator, stream_id, funded_amount == claimed_amount, claimed_amount)
log Claimed(creator, stream_id, funded_amount == claim_amount, claim_amount)

return claimed_amount
return claim_amount

0 comments on commit e727bce

Please sign in to comment.