Open hats-bug-reporter[bot] opened 1 month ago
Thank you for your submission.
new_stable(...)
and new_rated(...)
are the only constructors of this contract. new_pool(...)
cannot be used when deploying a new instance of this contract. Fees::new(...)
returns None
when fees are too high. Both constructors use new_pool(...)
which throws an error when fees
(Fees:new(...)
) is None
.
Github username: -- Twitter username: -- Submission hash (on-chain): 0x2520dad370e917e8c7302d0ffe802998aeba8bb017768567482b66373626ee77 Severity: medium
Description:
fn new
allows for settingtrade_fee
&protocol_fee
:A maximum limit is established to ensure that fees cannot exceed the cap.
This function is called inside
new_stable
&new_rated
:The problem however, is that it is not checked inside
new_pool
:Instead, it only verifies that the
fees
(trade_fee
andprotocol_fees
) are not zero. If they are zero, the transaction is reverted; otherwise, it proceeds.This means that users are able to bypass the set limits by calling
new_pool
directly.Recommendation
Ensure that the check is performed inside
new_pool
, allowing you to omit the checks within the stable and rated functions, as they already callnew_pool
.Additionally the 0 check can be implemented inside
fn new
.