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
AABoard.sol
—————— (1) setAdministrationRate() — does not impact tax income calculation
and _customAdministrationRate is not effectively used. Thus, both can be removed.
(3) In the likely situation when parentOwner == addresss(0), the collected copyrightFee will be permanently locked in the contract, and there is no way to withdraw.
(4) In the unlikely case of rounding issues, any minor mis-calculation of allTaxIncome could potentially lock all ETHs inside the contract.
/**
* @dev Withdraw all the tax income
*/
function withdrawTaxIncome() public onlyPauser {
require(allTaxIncome > 0);
uint256 total = allTaxIncome;
allTaxIncome = 0;
administrator.transfer(total);
}
==>
/**
* @dev Withdraw all the tax income
*/
function withdrawTaxIncome(uint256 amount) public onlyPauser {
require(allTaxIncome > 0);
if (amount == 0) amount = allTaxIncome;
if (amount <= allTaxIncome) {
allTaxIncome = allTaxIncome.sub(amount);
administrator.transfer(amount);
}
}
(5) Refactor withdrawDeposit for better encapsulation and readability
Harberger-Taxes-Billboards Quck-Audit
AABoard.sol
——————
(1)
setAdministrationRate()
— does not impact tax income calculationand _customAdministrationRate is not effectively used. Thus, both can be removed.
(2) Remove unnecessary checks for saved Gas usage
==>
(3) In the likely situation when
parentOwner == addresss(0)
, the collected copyrightFee will be permanently locked in the contract, and there is no way to withdraw.Suggestion:
==>
(4) In the unlikely case of rounding issues, any minor mis-calculation of allTaxIncome could potentially lock all ETHs inside the contract.
==>
(5) Refactor
withdrawDeposit
for better encapsulation and readability==>
(6) Add necessary sanity checks for risk parameters
==>
(7)
==>
(8) Follow the best-practice checks-effects-interactions pattern:
8.1
==>
8.2
==>
8.3
function withdrawDeposit(uint256 adId, uint256 amount) public adBoardExists(adId)
(9) Remove unnecessary checks for saved Gas usage.
9.1
buyAdBoard():
require(currentOwner != address(0) && msg.sender != currentOwner)
==>require(msg.sender != currentOwner);
9.2
createAdBoard():
require(msg.sender != address(0))
is redundant and can be removedrequire(parentId >= 0)
is redundant and can be removedrequire(price >= 0, "createAdBoard: Price should be greater than or eaqual to 0")
is redundant and can be removed9.3
changePrice():
require(price >= 0, "changePrice: Incorrect Price")
is redundant and can be removed9.4
_taxOwed():
require(price >= 0 && lastTaxPayTimestamp > 0) ==> require(lastTaxPayTimestamp > 0);
(10) Enhanced event generation
event CreateEvent(uint256 indexed adId)
==>
event ChangePriceEvent(uint256 indexed adId)
==>
event ChangePriceEvent(uint256 indexed adId, uint256 price)
event ChangeContentEvent(uint256 indexed adId)
==>
event ChangeContentEvent(uint256 indexed adId, string content)
event AddDepositEvent(uint256 indexed adId)
==>
event AddDepositEvent(uint256 indexed adId, uint256 depositToAdd)
event WithdrawDepositEvent(uint256 indexed adId)
==>
event WithdrawDepositEvent(uint256 indexed adId, uint256 amount)
==>
The text was updated successfully, but these errors were encountered: