A precision error in the calculation of bonuses for referrers and authorities leads to potential loss of their rewards.
When users call PreMarkets::createOffer
to create stock, they are charged a platformFee
using the platformFeeRate
. The platformFeeRate
is always <= PLATFORM_FEE_DECIMAL_SCALER
, as enforced in SystemConfig::updateUserPlatformFeeRate
:
The platformFee
is shared between the platform, referrer, and authority. While the role of the authority is not clearly defined in Tadle's documentation, the referrer is described as follows:
"Users can share their referral link and refer their friends and peers to trade on Tadle. Once the peers have signed up and completed a trade on Tadle, the referrer will earn a 30% commission on their referred peers’ transaction fees."
– Tadle Referral Program
The way referrerReferralBonus
and authorityReferralBonus
are calculated can lead to situations where these actors receive zero fees due to precision issues.
Note that referralInfo.referrerRate
is always less than REFERRAL_RATE_DECIMAL_SCALER
, as enforced in SystemConfig::updateReferrerInfo
.
This Proof of Concept (PoC) demonstrates how referrers and authorities can miss out on their bonuses due to precision errors.
Consider a scenario where a user makes a 1,000 wei trade. Let's assume:
depositAmount
: 1,000 wei
platformFeeRate
: 500,000
referralRate
: 300,000 (30%)
The platformFee
would be calculated as follows:
Since the platformFee
is 0 wei, the referrerReferralBonus
and authorityReferralBonus
would also be 0 wei:
This results in the referrer and authority receiving no bonuses.
Referrers lose their rewards. Although the loss per transaction is small, the frequency of this issue makes it significant.
Manual
Scale all variables in the calculation to the same decimal precision to avoid precision errors.
Valid medium, this will indeed cause a leakage (albeit requires relatively small amount of collateral transacted, and is most significant for lower decimal tokens (does not break ERC20 specifications), resulting in platFormFee rounding to zero and creater of offers not sending fees to capitalPool when `_depositTokenWhenCreateTaker` is invoked. For issues noting rounding directions, it will be low severity given the impact is not proven sufficiently with a PoC/numerical example and most rounding will not result in significant losses. I believe the most appropriate solution here is to increase scale of platFormFees scalar, but to make sure that overflows are considered for higher decimal tokens.
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.