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
_handleOpenFees
returns an incorrect value for _feePaid
. This directly impacts margin calculations
#367
Comments
GalloDaSballo marked the issue as duplicate of #476 |
GalloDaSballo changed the severity to 2 (Med Risk) |
GalloDaSballo marked the issue as satisfactory |
GalloDaSballo marked the issue as not a duplicate |
GalloDaSballo marked the issue as primary issue |
GalloDaSballo marked the issue as selected for report |
The warden has shown a mistake in how fees are calculated, the impact will cause a loss of yield to the protocol, however no convincing argument was made as to how this can cause a loss to depositors or users (loss of principal), for this reason, I believe Medium Severity to be the most appropriate |
Mitigation: code-423n4/2022-12-tigris#2 (comment) |
GainsGoblin marked the issue as sponsor confirmed |
Lines of code
https://github.com/code-423n4/2022-12-tigris/blob/588c84b7bb354d20cbca6034544c4faa46e6a80e/contracts/Trading.sol#L178
https://github.com/code-423n4/2022-12-tigris/blob/588c84b7bb354d20cbca6034544c4faa46e6a80e/contracts/Trading.sol#L734
Vulnerability details
Impact
Formula for
fee paid
in Line 734 is incorrect leading to incorrect margin calculations. Since this directly impacts the trader margin and associated fee calculations, I've marked as HIGH riskOn initiating a market order,
Margin
is adjusted for thefees
that is charged by protocol. This adjustment is in Line 178 of Trading. Fees computed by_handleOpenFees
is deducted from Initial margin posted by user.formula misses to account the
2*referralFee
component while calculaing_feePaid
Proof of Concept
Note that
_feePaid
as per formula in Line 734 is the sum of_daoFeesPaid', and sum of
burnerFee&
botFee.
_daoFeesPaidis calculated from
_fees.daoFeeswhich itself is calculated by subtracting
2*referralFeeand
botFee`.So when we add back
burnerFee
andbotFee
to_feePaid
, we are missing to add back the2*referralFee
which was earlier excluded when calculating_daoFeesPaid
. WhilebotFee
is added back correctly, same adjustment is not being done viz-a-viz referral fee.This results in under calculating the
_feePaid
and impacts the rewards paid to the protocol NFT holders.Tools Used
Recommended Mitigation Steps
Suggest replacing the formula in line 734 with below (adding back _fees.referralFees*2)
The text was updated successfully, but these errors were encountered: