You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// find the reward multiplier based on the user lock duration
uint256 durationRatio = ((duration - MIN_LOCK_DURATION) * UNIT) / (MAX_LOCK_DURATION - MIN_LOCK_DURATION);
uint256 userLockBonusRatio = minLockBonusRatio + (((maxLockBonusRatio - minLockBonusRatio) * durationRatio) / UNIT);
userCurrentBonusRatio[user] = userLockBonusRatio;
userBonusRatioDecrease[user] = (userLockBonusRatio - baseLockBonusRatio) / duration;
There is no need to peform this calculation twice as the value of the parameters dont change from one calculation to the other.
I recommend caching the calculation for userLockBonusRatio and durationRatio to be used when/if userCurrentBonusRatio[user] or userBonusRatioDecrease[user] need to be updated.
For example, the if statement would look something like:
QA & gas optimizations changes are done in the PR: PaladinFinance/Paladin-Tokenomics#6
(some changes/tips were implemented, others are noted but won't be applied)
GAS
Gas#1: Unnecessary on-chain computations to find the reward multiplier based on the user lock duration.
L1155-1160
L1210-1217
There is no need to peform this calculation twice as the value of the parameters dont change from one calculation to the other.
I recommend caching the calculation for
userLockBonusRatio
anddurationRatio
to be used when/ifuserCurrentBonusRatio[user]
oruserBonusRatioDecrease[user]
need to be updated.For example, the
if
statement would look something like:Gas#2: Assignment of state variable to default.
Please change emergency = false to:
Gas#3: Redundant
require
function.admin
transferOwnership
already has a zero address check for_admin
, making the above require function redundant.The text was updated successfully, but these errors were encountered: