Rounding errors will assign smaller amount values in all tranches except in the last one where all owed tokens would be added up. A 3x100 tranche distribution [100, 100, 100] will look like [99, 99, 102]. This could lead to unintended behaviour and varying impact based on tranches.length and the value of the streamed token.
Whenever a MerkleLT recipient calls claim
, _calculateTranches
is invoked. Amount per tranche owed is calculated based on the total amount owed to the recipient multiplied by each tranche's assigned percentage. Tranche percentages are checked beforehand to amount to 100%.
Further down the code the devs have made sure that the recipient ends up receiving the entire owed amount, despite rounding errors, which are stated as possible in the natspec.
This mitigation, however, would disturb the inteded distribution by the sender. Given the freedom of working with any ERC20 token and to set tranche timestamps far in the future, a merkle stream recipient will be forced to wait for the tokens owed until the last tranche has passed. As per Sablier's website, Sablier intends to cater to businesses and assist in payroll handling. One could expect a scenario with an annual salary via MerkleLT (e.g 1200 tokens, 12x100 per month). A recipient would expect 12 equal payments looking as [100, 100, 100, ..., 100] but end up receiving it as [99, 99, 99, ..., 111]. Recipient would have to wait a year to receive their originally owed funds.
Despite the example being an abstract one, it points to a key issue - recipients will receive less than expected/owed and the difference is softlocked until the end of the stream.
Unexpected behaviour
Manual review
Add the option in createMerkleLT
to input tranche amounts manually in cases where working with percentages is not optimal.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.