[G-04] Consider shortening some string to avoid extra gas
./src/DBR.sol
L63: require(newReplenishmentPriceBps_ > 0, "replenishment price must be over 0");
L326: require(markets[msg.sender], "Only markets can call onForceReplenish");
./src/Market.sol
L76: require(_replenishmentIncentiveBps < 10000, "Replenishment incentive must be less than 100%");
L214: require(msg.sender == pauseGuardian || msg.sender == gov, "Only pause guardian or governance can pause");
[G-08] If a function is not open to any user, it can be marked as payable to save gas
Description: Under the hood the compiler checks if a function is payable. The check is skipped if it is marked as such by the developer
./src/escrows/INVEscrow.sol
L59: function pay(address recipient, uint amount) public {
L90: function delegate(address delegatee) public {
./src/Oracle.sol
L66: function claimOperator() public {
./src/escrows/SimpleERC20Escrow.sol
L36: function pay(address recipient, uint amount) public {
./src/Market.sol
L203: function recall(uint amount) public {
L212: function pauseBorrows(bool _value) public {
./src/escrows/GovTokenEscrow.sol
L43: function pay(address recipient, uint amount) public {
L66: function delegate(address delegatee) public {
./src/Fed.sol
L48: function changeGov(address _gov) public {
L66: function changeChair(address _chair) public {
L75: function resign() public {
L86: function expansion(IMarket market, uint amount) public {
L103: function contraction(IMarket market, uint amount) public {
./src/DBR.sol
L70: function claimOperator() public {
[G-09] Spread the require() conditions to multiple require() statements to save gas from &&
GAS ISSUES FOR 2022-10-INVERSE
[G-01] There is no need to compare boolean variable to boolean literals
Description: if (var == true) => if (var)
./src/DBR.sol
[G-02] Re-arrange storage variable so they use less contract storage slots and use less gas this way
Description: Currently storage variables in Market.sol are packed in 15 slots, but could fit in 14
[G-03] A < B + 1 is cheaper than A <= B
./src/DBR.sol
./src/Market.sol
./src/Fed.sol
[G-04] Consider shortening some string to avoid extra gas
./src/DBR.sol
./src/Market.sol
[G-05]
!= 0
comparison is cheaper than> 0
./src/Market.sol
./src/Fed.sol
./src/Oracle.sol
./src/escrows/INVEscrow.sol
./src/DBR.sol
[G-06] Use
uint265
for boolean values (e.g. true => 1 and false => 2)./src/Market.sol
[G-07] Cache variables that are read multiple times in a single fuction or loop
./src/Market.sol
./src/Oracle.sol
[G-08] If a function is not open to any user, it can be marked as
payable
to save gasDescription: Under the hood the compiler checks if a function is payable. The check is skipped if it is marked as such by the developer
./src/escrows/INVEscrow.sol
./src/Oracle.sol
./src/escrows/SimpleERC20Escrow.sol
./src/Market.sol
./src/escrows/GovTokenEscrow.sol
./src/Fed.sol
./src/DBR.sol
[G-09] Spread the
require()
conditions to multiplerequire()
statements to save gas from&&
./src/DBR.sol
./src/Market.sol
[G-10] Use custom errors to save gas
./src/escrows/SimpleERC20Escrow.sol
./src/Market.sol
./src/BorrowController.sol
./src/escrows/GovTokenEscrow.sol
./src/escrows/INVEscrow.sol
./src/Fed.sol
./src/Oracle.sol
./src/DBR.sol
[G-11] A=A+B costs less gas than A+=B if A and B are located in storage
./src/Market.sol
./src/Fed.sol
./src/DBR.sol