being referred discount is calculated wrongly #322
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-542
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L708-L718
https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L786-L792
https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L954-L967
Vulnerability details
Impact
If user is referred, referral fees will be sent to the referral and a discount will be deducted on the trading fees of user. However, the amount for the discount is the same as the referral fees in the calculation, causing user to pay lesser fees than they should if they are referred.
Proof of Concept
In
handleOpenFees
, you can see that if referrer is present, it will mint referralFees for the referrer. The next step is to deduct the referral fees and discount from user fees that they will pay, instead of deducting discount which is 10% of trade fees separately, referralFees is being used instead as the amount for the discount for referred user.According to https://docs.tigris.trade/protocol/trading-and-fees and https://docs.tigris.trade/protocol/referrals, The discount should be 10% of 0.1% trading fees for commodities and crypto, which is significantly lesser than 0.05% that referrer will get according to the docs. User will pay lesser fees, dao will get lesser fees and therefore GovNFT holders will lose out on fees.
Tools Used
Manual Review
Recommended Mitigation Steps
Few places need to be rewritten to calculate the discount standalone instead of using referral fees as the discount
https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L708-L718
https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L788-L792
https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L954-L967
The text was updated successfully, but these errors were encountered: