sablier-labs / v2-core

⏳ Core smart contracts of the Sablier V2 token distribution protocol
https://sablier.com
Other
288 stars 38 forks source link

Add assumption about the max value of `exponent` #921

Closed smol-ninja closed 4 weeks ago

smol-ninja commented 1 month ago

A Codehawk auditor asked a really good question about the max value of UD2x18.

Since its max value is capped by type(uint64).max, the exponent cannot represent a value bigger than 18.446744073709551615. Thus, we should add this in the Assumptions section of SECURITY.md:

In Lockup dynamic, the fixed-point representation of a segment's exponent does not exceed 18.446744073709551615.

PaulRBerg commented 1 month ago

Agree that we should document this as an assumption, but there should be no need for exponents that large.

When you get that to double-digit ranges and above, the streaming function is so slow that it becomes effectively equivalent to a timelock (within that segment).

From the docs:

[!WARNING] Because x is a percentage, the streaming rate is inversely proportional to the exponent. For example, if the exponent is 0.5, the rate is quadratically faster compared to the baseline when the exponent is 1. Conversely, if exponent is 2, the rate is quadratically slower compared to baseline.