Submitted by cmichel
The NFTXInventoryStaking contract distributes new rewards to all previous stakers when the owner calls the receiveRewards function.
This allows an attacker to frontrun this receiveRewards transaction when they see it in the mem pool with a deposit function.
The attacker will receive the rewards pro-rata to their deposits.
The deposit will be locked for 2 seconds only (DEFAULT_LOCKTIME) after which the depositor can withdraw their initial deposit & the rewards again for a profit.
The rewards can be gamed this way and one does not actually have to stake, only be in the staking contract at the time of reward distribution for 2 seconds.
The rest of the time they can be used for other purposes.
Distribute the rewards equally over time to the stakers instead of in a single chunk on each receiveRewards call.
This is more of a streaming rewards approach.
0xKiwi (NFTX) confirmed and commented:
