-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address audit findings 3, 5, and 11 #1131
Conversation
refactor: remove unchecked in calculateStreamedPercentage docs: add assumptions in VestingMath function docs: improve explanatory comments
bff7b65
to
43cf223
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @andreivladbrg. Only one comment below:
chore: remove MAX_COUNT assumption
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work Andrei. Left few comments below. I also realized that we do not have anything like the following in calculateLockupTranchedStreamedAmount
while we have it in LL and LD calculations.
// Although the streamed amount should never exceed the deposited amount, this condition is checked
// without asserting to avoid locking tokens in case of a bug. If this situation occurs, the withdrawn
// amount is considered to be the streamed amount, and the stream is effectively frozen.
if (streamedAmount > depositedAmount) {
return withdrawnAmount;
}
returns (uint128) | ||
{ | ||
uint256 blockTimestamp = block.timestamp; | ||
// If the start time is in the future, return zero. | ||
if (timestamps.start > blockTimestamp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if block is redundant. We already have the following logic in this function:
if (tranches[0].timestamp > blockTimestamp) {
return 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s correct—in our case, this check can be removed. However, I left it intentionally because if someone calls this function with an incorrect set of tranches but the correct start time, it would return 0.
Our example for abort
functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"start time" does not exist in the context of tranched streams. So, one solution could be to only pass timestamps.end
as the input parameter but then I suppose, for the API consistencies, you decided to pass timestamps
struct, which is good choice.
How about that, instead of reverting on invalid timestamps.start
value, we add it as an assumption i.e. this function does not check for timestamps.start
value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shw from cantina also recommended something similar: https://cantina.xyz/code/52d6aa1e-6aa4-4e73-96ed-6077652cf0f1/findings/5#comment-1583e631-54c2-45b8-aff3-4422bba95142
Correct. The reason we have these checks in linear/dynamic is because they involve math-sensitive operations in Solidity, the use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lil feedback below
e502409
to
2e815ce
Compare
Changes
Addresses these audit findings: