SystemConfig::updateReferrerInfo() reverts causing eventual loss of rewards given to the referrer
The testUpdateReferrerInfo function in the following contract is designed to test the initialization of uint256 basePlatformFeeRate = 5_000; and uint256 baseReferralRate = 300_000;, as well as the update of referrerRate using SystemConfig::updateReferrerInfo().
During the test, SystemConfig::updateReferrerInfo() reverts with the error [Revert] InvalidRate(300030 [3e5], 0, 300000 [3e5]). This error occurs because the function fails to meet the following condition:
uint256 _referrerRate = 300030;
uint256 _authorityRate = 0;
uint256 totalRate = 300000;
The problem seems to lie in the method used to calculate the total rate:
uint256 totalRate = baseReferralRate + referralExtraRate;
Currently, the calculation uses referralExtraRate instead of considering newReferrerRate and newAuthorityRate . It should be adjusted to:
uint256 totalRate = baseReferralRate + newReferrerRate + newAuthorityRate
Copy and paste the following contract into a new file within the test directory.
Then, execute the test using the following command: forge test --mt testUpdateReferrerInfo -vvv
Ensure that you have a Foundry project initialized before running this command.
Eventual loss of rewards given to the referrer and inability to update referral rate.
Manual review
Instead of using uint256 totalRate = baseReferralRate + referralExtraRate;
you should adjust it to: uint256 totalRate = baseReferralRate + newReferrerRate + newAuthorityRate
Valid medium, specific valid inputs by admin will still cause revert in updates to referral info due to incorrect totalRate computation and checks implemented. Note: Downgrade to low severity: This is a valid issue that highlights a valid inconsistency in the docs. In the docs, it was mentioned in the steps that referral rates can be adjusted up to a maximum of 30% as seen in [Step 4. ](https://tadle.gitbook.io/tadle/tadle-incentives-program/referral-program/create-and-manage-referral)but as of now, the minimum refferal rate is 30%. However, since refferals are entirely optional, if a minimum 30% refferal rate is established and the user deems it as too high, he can simply choose not to perform the refferal. Hence, I believe low severity to be appropriate.
Valid medium, specific valid inputs by admin will still cause revert in updates to referral info due to incorrect totalRate computation and checks implemented. Note: Downgrade to low severity: This is a valid issue that highlights a valid inconsistency in the docs. In the docs, it was mentioned in the steps that referral rates can be adjusted up to a maximum of 30% as seen in [Step 4. ](https://tadle.gitbook.io/tadle/tadle-incentives-program/referral-program/create-and-manage-referral)but as of now, the minimum refferal rate is 30%. However, since refferals are entirely optional, if a minimum 30% refferal rate is established and the user deems it as too high, he can simply choose not to perform the refferal. Hence, I believe low severity to be appropriate.
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.