### #deficitOf()
Public function used on function like onBorrow, onForceReplenish... (state change functions)
- Exactly the same gas opt. as balanceOf()
### #totalSupply()
Public view function, not used in other functions, so not really important.
- replace:
```js
if (totalDueTokensAccrued > _totalSupply) return 0;
return _totalSupply - totalDueTokensAccrued;
exactly the same gas opt. as setLiquidationFactorBps()
setLiquidationIncentiveBps()
exactly the same gas opt. as setLiquidationFactorBps()
predictEscrow()
This is not really an gas optimization, but just for the style you can remove the memory variable which mstore the address(this),
and use the assembly opcode address() instead.
Gas Optimizations
DBR.sol
balanceOf()
Public function used on function like transfer, transferFrom, _burn (state change functions)
after:
after:
if (duTokensAccruedUser + accrued > balanceUser) return 0; return balanceUser - duTokensAccruedUser - accrued;
after:
accrueDueTokens()
Public function used on function like onBorrow, onRepay, onForceReplenish (state change functions)
after:
Fed.sol
contraction()
Public function
after:
Market.sol
setLiquidationFactorBps()
after:
setReplenismentIncentiveBps()
setLiquidationIncentiveBps()
predictEscrow()
after:
getCollateralValue()
Public function used on function like getCreditLimit, getLiquidatableDebt (view functions)
after:
getCollateralValueInternal()
Internal function used on function like getCreditLimitInternal, forceReplenish (state change functions)
getCreditLimit()
Public function used on function like getLiquidatableDebt (view functions)
after:
getCreditLimitInternal()
Internal function used on function like borrowInternal, liquidate (state change functions)
getWithdrawalLimitInternal()
Internal function used on function like withdrawInternal, withdraw (state change functions)
after:
after:
borrowInternal()
Internal function used on function like borrow, borrowOnBehalf (state change functions)
after:
withdrawInternal()
Internal function used on function like withdraw (state change functions)
after:
repay()
Public function used on function like repayAndWithdraw (state change functions)
after:
forceReplenish()
Public function (state change functions)
after:
getLiquidatableDebt()
Public view function
after:
Oracle.sol
getPrice()
Public function (state change function)
after:
after:
viewPrice()
That's all !! Thank you for this contest (my first one).
Ozy42