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
It is obvious that _collateralOwed - _fee will not be underflown since it has require(_collateralOwed > _fee, ...). Hence, can use unchecked directory,
Both _globalDepositAmount + _amount and _accountToNetDeposit[_sender] + _amount will not be overflown because it checks _amount + _globalDepositAmount <= _globalDepositCap and _amount + _accountToNetDeposit[_sender] <= _accountDepositCap before.
_globalDepositAmount - _amount and _accountToNetDeposit[_sender] - _amount will not be underflown since they are wrapped by the if statement _globalDepositAmount > _amount or _accountToNetDeposit[_sender] > _amount.
Excellent submission, well documented and clearly outlines gas savings.
This report and #5 will be referenced as the source submissions for common optimization duplicates.
unchecked direction can be used at
mintLongShortTokens
function inPrePOMarket.sol
Target codebase
mintLongShortTokens
function inPrePOMarket.sol
can use unchecked directory.https://github.com/code-423n4/2022-03-prepo/blob/main/contracts/core/PrePOMarket.sol#L122
It is obvious that
_amount - _fee
will not be underflown since it hasrequire(_amount > _fee, ...)
. Hence, can use unchecked directory,Proposed change
Gas changes with the proposed changes
Methods - average gas change
Deployments - average gas change
unchecked direction can be used at
redeem
function inPrePOMarket.sol
Target codebase
redeem
function inPrePOMarket.sol
can use unchecked directory.https://github.com/code-423n4/2022-03-prepo/blob/main/contracts/core/PrePOMarket.sol#L169
It is obvious that
_collateralOwed - _fee
will not be underflown since it hasrequire(_collateralOwed > _fee, ...)
. Hence, can use unchecked directory,Proposed change
Gas changes with the proposed changes
Methods - average gas change
Deployments - average gas change
Target codebase
Proposed change
Gas changes with the proposed changes
Methods - average gas change
Deployments - average gas change
Unchecked can be used at
deposit
function inCollateral.sol
Target codebase
https://github.com/code-423n4/2022-03-prepo/blob/main/contracts/core/Collateral.sol#L73
_amountToDeposit - _fee
will not be underflown sincerequire(_amountToDeposit > _fee, ...)
.Proposed change
Gas changes with the proposed changes
Methods - average gas change
Deployments - average gas change
uint256 _shares
does not need to be initialized with 0 atdeposit
function inCollateral.sol
Target codebase
https://github.com/code-423n4/2022-03-prepo/blob/main/contracts/core/Collateral.sol#L81
Proposed change
Gas changes with the proposed changes
Methods - average gas change
Deployments - average gas change
unchecked can be used at
withdraw
function atCollateral.sol
Target codebase
https://github.com/code-423n4/2022-03-prepo/blob/main/contracts/core/Collateral.sol#L171
It is obvious that
_amountWithdrawn - _fee
will not be underflown since it hasrequire(_amountWithdrawn > _fee, ...)
.Proposed change
Gas changes with the proposed changes
Methods - average gas change
Deployments - average gas change
Unchecked can be used at
recordDeposit
function inCollateralDepositRecord.sol
Target codebase
https://github.com/code-423n4/2022-03-prepo/blob/main/contracts/core/CollateralDepositRecord.sol#L37-L38
Both
_globalDepositAmount + _amount
and_accountToNetDeposit[_sender] + _amount
will not be overflown because it checks_amount + _globalDepositAmount <= _globalDepositCap
and_amount + _accountToNetDeposit[_sender] <= _accountDepositCap
before.Proposed change
Gas changes with the proposed changes
Methods - average gas change
Deployments - average gas change
Unchecked can be used at
recordWithdrawal
function inCollateralDepositRecord.sol
Target codebase
https://github.com/code-423n4/2022-03-prepo/blob/main/contracts/core/CollateralDepositRecord.sol#L47
https://github.com/code-423n4/2022-03-prepo/blob/main/contracts/core/CollateralDepositRecord.sol#L52
_globalDepositAmount - _amount
and_accountToNetDeposit[_sender] - _amount
will not be underflown since they are wrapped by the if statement_globalDepositAmount > _amount
or_accountToNetDeposit[_sender] > _amount
.Proposed change
Gas changes with the proposed changes
Methods - average gas change
Deployments - average gas change
Unchecked can be used at
allowAccounts
function inAccountAccessController.sol
Target codebase
https://github.com/code-423n4/2022-03-prepo/blob/main/contracts/core/AccountAccessController.sol#L44
Proposed change
Gas changes with the proposed changes
Methods - average gas change
Deployments - average gas change
Unchecked can be used at
blockAccounts
function inAccountAccessController.sol
Target codebase
https://github.com/code-423n4/2022-03-prepo/blob/main/contracts/core/AccountAccessController.sol#L55-L58
Proposed change
Gas changes with the proposed changes
Methods - average gas change
Deployments - average gas change
The text was updated successfully, but these errors were encountered: