Platform: Code4rena
Start Date: 09/02/2024
Pot Size: $60,500 USDC
Total HM: 17
Participants: 283
Period: 12 days
Judge:
Id: 328
League: ETH
Rank: 237/283
Findings: 1
Award: $1.03
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: t0x1c
Also found by: 0rpse, 0xAadi, 0xBinChook, 0xCiphky, 0xDetermination, 14si2o_Flint, AC000123, Aamir, Abdessamed, Blank_Space, CodeWasp, DanielArmstrong, DarkTower, Draiakoo, Honour, Kalogerone, Krace, McToady, Merulez99, MidgarAudits, MrPotatoMagic, PedroZurdo, Silvermist, Tychai0s, VAD37, Velislav4o, VrONTg, WoolCentaur, YouCrossTheLineAlfie, ZanyBonzy, alexxander, aslanbek, btk, csanuragjain, d3e4, dimulski, djxploit, erosjohn, evmboi32, fnanni, forgebyola, forkforkdog, handsomegiraffe, immeas, israeladelaja, juancito, ktg, n0kto, neocrao, ni8mare, okolicodes, peanuts, petro_1912, shaflow2, shaka, swizz, ubermensch, ubl4nk, yotov721
1.0297 USDC - $1.03
The users Staking
factor fails to increase and as such remains same no matter their stake
amount.
In the projects documentation, the staking
factor helps to determine the amount of rewards
a user could receive for a given round
based on their staked amount
. According to the docs, "The more NRN a player stakes, the more Points their Challenger NFT can accumulates" tho as the user stake
increases the impact of the marginal NRN
staked decreases as more NRN
is staked. The issue here is that Based on the code implementation the staking
factor is calculated wrongly and would always return 1 no matter the amount an average user stakes
.
function _getStakingFactor( uint256 tokenId, uint256 stakeAtRisk) private view returns (uint256) { uint256 stakingFactor_ = FixedPointMathLib.sqrt( (amountStaked[tokenId] + stakeAtRisk) / 10**18 ); if (stakingFactor_ == 0) { stakingFactor_ = 1; } return stakingFactor_; } }
You can see that the calculation is given as the
squareroot of (amountStaked[tokenId] + stakeAtRisk) / 10**18
Lets assume that a Fighter
newly stakes 1000 NRN
and has no stake
at risk. The calculation will result to a zero
number which will return 1. Even if a fighter stakes 1,000,000 NRN
or 1,000,000,000 NRN
tokens, with the above formular, the square root will always return a zero number still and therefore return 1. This is a flawed implementation as: users staking factor won't grow and cannot yield them rewards as supposed.
Manual Review + Godspeed
The divisor is a very large number and should be reduced
Other
#0 - c4-pre-sort
2024-02-22T16:28:34Z
raymondfam marked the issue as insufficient quality report
#1 - raymondfam
2024-02-22T16:30:12Z
1 NRN is 1e18 wei. 100 * 1e18 NRN would yield a factor 10.
#2 - c4-pre-sort
2024-02-22T16:30:23Z
raymondfam marked the issue as duplicate of #38
#3 - c4-judge
2024-03-07T02:58:22Z
HickupHH3 changed the severity to 3 (High Risk)
#4 - c4-judge
2024-03-07T03:18:49Z
HickupHH3 marked the issue as partial-50