The contracts don't enforce a minimum amount to be deposited or withdrawn. This allows users to send batched deposits/withdraws for small amounts to escape paying fees by playing with the required amounts to make the computation of fees to be 0 and netAmount to be equals to the full specified amount.
Fees are charged when withdrawing (protocol fees) and when depositing via a broker (broker fee). The Helpers.calculateAmountsFromFee() function
is in charged to compute the fees and the netAmount the users would withdraw/deposit.
There is not a minimum amount to deposit or withdraw, the requests are processed as long as the amount is != 0. This opens up the doors for users to escape paying fees by depositing / withdrawing small amounts.
For tokens with low decimals the users can deposit/withdraw more USD value in each execution. For example, the stablecoin GUSD
, which uses 2 decimals.
1 GUSD is expressed as 1e2 (100).
For example, a protocolFee of 1% for the GUSD token would allow users to withdraw 99 unit of GUSD (0.99 USD) without paying fees.
To demonstrate the problem, find below a coded PoC that shows how by setting totalAmount == 99
, and the fee at 1%, the computed feeAmount is 0
.
Create a new file under the tests/ folder
and add the next PoC. Run it with the command forge test --match-test test_calculateAmountsFromFee -vvvv
The next PoC demonstrates how the computation of fees for a small amount of GUSD allows users to skip paying fees.
feeAmount is computed as 0
netAmount is the same as the totalAmount, even though the fee is configured.
Note: The fee could be set to a higher value than 1%, the only difference will be that the total amount to deposit / withdraw would need to be lower.
Users can escape paying fees, causing the protocol to not collect fees when processing withdrawals, and brokers to not earn fees when processing deposits.
Manual Audits && Foundry.
In the Helpers.calculateAmountsFromFee()
, check if fee > 0
, if so, enforce that feeAmount != 0
, otherwise, revert the tx with an error about totalAmount
not being above the minimum allowed deposit/withdrawal.
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.