Sablier

Sablier
DeFiFoundry
53,440 USDC
View results
Submission Details
Severity: medium
Invalid

`_checkTranches` will revert when operating with more complex numbers

Summary

In manual tranche stream creation (with broker fee), it is possible that some specific tranche deposits would be impossible to craft due to _checkTranches reverting.

Vulnerability Details

Imagine the following: stream sender has 200 tokens (with 18 decimals so 200e18) to stream to recipient via 2 equivalent tranches (100, 100), broker is also involved, brokerFee = 10%. According to the natspec, the stream creator is responsible for accounting for all due sums in the params.totalAmount (tranche amounts sum + broker fee). If the sender intends to stream 200e18 (after fee) then we calculate the params.totalAmount (before fee) as 200e18 / (1 - brokerFee) = 222,222222e18. With this input, checkAndCalculateBrokerFee will calculate createAmounts.deposit as 222,222222e18 - 222,222222e18 * brokerFee = 199,999998e18. This amount is further checked in Helpers._checkTranches and will cause a revert since it does not amount to the intended 200 tokens stream.

if (depositAmount != trancheAmountsSum) { // 199,999998e18 != 200
revert Errors.SablierV2LockupTranched_DepositAmountNotEqualToTrancheAmountsSum(
depositAmount, trancheAmountsSum
);
}

Sender would be unable to stream their initially intended (and presumably owed to recipient) 200 token amount with the given parameters.

Impact

Unexpected behavior, broken core functionality

Tools Used

Manual Review

Recommendations

Instead of reverting the transaction, cover the difference between depositAmount and trancheAmountSum from the brokerFee when handling periodic numbers.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Too generic

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.