sablier-labs / flow

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

Fix the bug in `deposit` #151

Closed andreivladbrg closed 4 months ago

andreivladbrg commented 4 months ago

Linked issues

Changelog

Src

Test


Question: should we add independent tests for Helpers.calculateNormalizedAmount and Helpers.calculateTransferAmount?

andreivladbrg commented 4 months ago

Also, I think we should start using unchecked wherever its safe to do so inspite of it reducing readability. We should save gas on mathematical operations.

I changed my mind, and I added the unchecked blocks in the calculation functions. It wasn’t about readability; rather, I was concerned that something might break, so I thought it was safer not to use unchecked. Also, the gas savings are not high.

smol-ninja commented 4 months ago

Unfortunately, we cannot unchecked the whole block. (amount * (10 ** normalizingFactor)).toUint128() can overflow.

andreivladbrg commented 4 months ago

@smol-ninja updated the PR with not allowing assets with more than 18 decimals