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
#6 Unnecessary rewardLastUpdate[user] == block.timestamp https://github.com/code-423n4/2022-03-paladin/blob/main/contracts/HolyPaladinToken.sol#L861
The only way to update rewardLastUpdate[user]is in the same function (_updateUserReward()). Therefore, the condition rewardLastUpdate[user] == block.timestamp is an edge case (its quite hard to have exact the same block.timestamp since it is updated per second), and have no security risk.
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
#1 Unnecessary
require()
https://github.com/code-423n4/2022-03-paladin/blob/main/contracts/HolyPaladinToken.sol#L183
transferOwnership()
function was validating that_admin
!= address(0). I recommend to remove L183 or call_transferOwnerShip()
instead oftransferOwnership
#2 != is more effective than >
https://github.com/code-423n4/2022-03-paladin/blob/main/contracts/HolyPaladinToken.sol#L229
Using != 0 is more gas effective > 0
#3 Using
SafeERC20
Lib for pal tokenhttps://github.com/code-423n4/2022-03-paladin/blob/main/contracts/HolyPaladinToken.sol#L13
Using
SafeERC20.function
for pal token is unnecessary. Using justtransfer
andtransferFrom
from ERC20.function is gas saving#4 Unnecessary
burnAmountx
variable declaration in_unstake
functionhttps://github.com/code-423n4/2022-03-paladin/blob/main/contracts/HolyPaladinToken.sol#L1090
Instead of using ternary operation, using if() statement can save gas, then just store the value amount to burn to
amount
var:#5 Declaration bool with default value
https://github.com/code-423n4/2022-03-paladin/blob/main/contracts/HolyPaladinToken.sol#L103
By not declaring that
emergency
= false, the value will still == false. So delete the value set at L103#6 Unnecessary
rewardLastUpdate[user]
== block.timestamphttps://github.com/code-423n4/2022-03-paladin/blob/main/contracts/HolyPaladinToken.sol#L861
The only way to update
rewardLastUpdate[user]
is in the same function (_updateUserReward()). Therefore, the conditionrewardLastUpdate[user]
== block.timestamp is an edge case (its quite hard to have exact the same block.timestamp since it is updated per second), and have no security risk.#7 Using if() statement instead of ternary operation
https://github.com/code-423n4/2022-03-paladin/blob/main/contracts/HolyPaladinToken.sol#L1206
By using if() statement, MSTORE when the condition == false will prevented and also reducing gas cost
#8 Prevent too many SLOAD and using if instead of ternary operation
https://github.com/code-423n4/2022-03-paladin/blob/main/contracts/HolyPaladinToken.sol#L388
By chacing
claimableReward[msg.sender]
toclaimAmount
and using if condition to setclaimAmount
=amount
(also prevent MSTORE) can be a lot efficient:#9 Gas improvement on calling
SafeERC20.function
https://github.com/code-423n4/2022-03-paladin/blob/main/contracts/HolyPaladinToken.sol#L13
In case SafeERC20 is used. By removing L13 and call
SafeERC20.function
directly in line can save 15 gas per call.For instance:
#10 Using
storage
instead ofmemory
to declare structhttps://github.com/code-423n4/2022-03-paladin/blob/main/contracts/HolyPaladinToken.sol#L650
Instead of chasing
UserLock
in memory, read it directly from storage can save gas (if struct var amount > how many time it was called, better using storage pointer)#11 Unnecessary
votes
variable declarationhttps://github.com/code-423n4/2022-03-paladin/blob/main/contracts/HolyPaladinToken.sol#L646
votes
is merely called once in thegetPastVotes
function. Avoiding unnecessary MSTORE and pass it directly to L645 can save gas:The text was updated successfully, but these errors were encountered: