Open hats-bug-reporter[bot] opened 1 day ago
Adding to the submission, this will result in protocols that integrate with Thorn to revert, when token supply is 0.
Duplicate of #64
This submission does not "duplicate" #64. That submission fails to follow the guidelines given by Hats of what a valid submission is. No impact has been given, no root cause, not even a recommendation. Apart from the fact that those are missing, all those information are written first time here, since they are not present in #64 even at the time of writing this reply.
Let's leave it to @omega-audits to decide
@Giannis443 Your recommended changes doesn't resolve the issue. As the last line in calc_token_amount()
will still lead to revert as D0 will be 0 if LP supply is 0.
return (difference * token_amount) / D0;
Github username: -- Twitter username: -- Submission hash (on-chain): 0xd15db2859012b3353cdbabfe2b3a4cca69ef7907050c6234b593ece898633a9c Severity: low
Description: Description\
calc_token_amount
doesn't check that total supply is greater than 0. Thus, when calculating theD0
withget_D_mem
theD0
becomes 0 and at the return statement of thecalc_token_amount
division by 0 occurs.Attachments
Run the following test:
Check that the token supply is greater than zero. Else, calculate the return value similar to how
add_liquidity
works. The following should be added: