Open deemru opened 2 years ago
_balanceDelta
newRewardPerTokenStored
newLastUpdateTime
currentTimestampSec()
addRewards()
ackRewards()
leftover
withdrawRewards()
_balanceDelta
is always 0. The code can be simplified in some places: https://github.com/Tsunami-Exchange/tsunami-contracts/blob/e761fd283558ee35caa73e34fb4c74653738263f/contracts/ride/rewards.ride#L126 https://github.com/Tsunami-Exchange/tsunami-contracts/blob/e761fd283558ee35caa73e34fb4c74653738263f/contracts/ride/rewards.ride#L139 https://github.com/Tsunami-Exchange/tsunami-contracts/blob/e761fd283558ee35caa73e34fb4c74653738263f/contracts/ride/rewards.ride#L144newRewardPerTokenStored
is alwaysnewRewardPerTokenStored
. The code can be simplified in some places: https://github.com/Tsunami-Exchange/tsunami-contracts/blob/e761fd283558ee35caa73e34fb4c74653738263f/contracts/ride/rewards.ride#L147newLastUpdateTime
is alwayscurrentTimestampSec()
. The code can be simplified in some places: https://github.com/Tsunami-Exchange/tsunami-contracts/blob/e761fd283558ee35caa73e34fb4c74653738263f/contracts/ride/rewards.ride#L146addRewards()
is full duplicate ofackRewards()
with payment. No reason to haveaddRewards()
at all or at least the code can be combined.ackRewards()
can be called automatically with other user functions to self update rewards distribution without backend interventions.leftover
= 0: https://github.com/Tsunami-Exchange/tsunami-contracts/blob/e761fd283558ee35caa73e34fb4c74653738263f/contracts/ride/rewards.ride#L312 https://github.com/Tsunami-Exchange/tsunami-contracts/blob/e761fd283558ee35caa73e34fb4c74653738263f/contracts/ride/rewards.ride#L316withdrawRewards()
can lead to user gets nothing in between): https://github.com/Tsunami-Exchange/tsunami-contracts/blob/e761fd283558ee35caa73e34fb4c74653738263f/contracts/ride/rewards.ride#L132 https://github.com/Tsunami-Exchange/tsunami-contracts/blob/e761fd283558ee35caa73e34fb4c74653738263f/contracts/ride/rewards.ride#L141