Closed sherlock-admin closed 9 months ago
1 comment(s) were left on this issue during the judging contest.
0xLogos commented:
dup of #43
It's not a bug. The fees are divided into lpFee and mtFee. The lpFee is implicitly included in the calculation of bidUpPrice and askDownPrice, and the outer swapFee is only used for recording events. The mtFee is calculated and transferred at the outermost level.
Escalate
This is an update contest. I don't understand how changing this to this, but keeping the record the same (previous, current) is not a bug. Either one of them must be incorrect.
Thanks.
You've created a valid escalation!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
@Attens1423 @traceurl To my knowledge, there is no issues with how fees are charged based on your comments here. You might want to shed some light on the mechanisms around how swap fee and mt fees are charged to clear watsons doubt.
@osmanozdemir1 I'm not getting your point in the escalation, please explain your logic in more detail. Otherwise, I will be rejecting the escalation and leaving the issue as is.
Please note that you are to check the current system, so while diff may be useful when searching for bugs, be careful when arguing about the validity of the report that way.
Hi @Czar102 I escalated this issue because it was the primary one. My original submission #9 explains why I considered this diff as a bug.
In summary, protocol changed the receiveToAmount
return variable in the querySellTokens
function but didn't change the corresponding swap record. #9 explains it in detail.
Given comments on #10, planning to reject the escalation and leave the issue as is.
Result: Invalid Has duplicates
Krace
high
Users don't need to pay for swapFee when selling or buying tokens
Summary
The
D3Trading
contract only charges themtFee
and ignores theswapFee
in functionquerySellTokens
andqueryBuyTokens
. This results in users obtaining moreto
tokens with the same amount offrom
tokens or expending fewerfrom
tokens to acquire the same amount ofto
tokens.Vulnerability Detail
queriySellTokens
should return the amount ofto
tokens that user should receive, which should excludemtFee
andswapFee
, but it only returnsreceiveToAmount - mtFee
.The same logic is also implemented in funtion
queryBuyTokens
Impact
Users don't need to pay for
swapFee
when selling or buying tokensCode Snippet
https://github.com/sherlock-audit/2023-12-dodo/blob/ea7f786161113144562a900dbff31457ff7025ef/dodo-v3/contracts/DODOV3MM/D3Pool/D3Trading.sol#L206 https://github.com/sherlock-audit/2023-12-dodo/blob/ea7f786161113144562a900dbff31457ff7025ef/dodo-v3/contracts/DODOV3MM/D3Pool/D3Trading.sol#L229
Tool used
Manual Review
Recommendation
It is recommended to subtract
swapFee
fromreceiveToAmount
in functionquerySellTokens
and addswapFee
totoAmountWithFee
in functionqueryBuyTokens
.