Gas Optimizations #18
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
In processWithdrawals function at VUSD.sol#L64, modify i+=1 to ++i
In processWithdrawals function at VUSD.sol#L63, use unchecked at reserve -= withdrawal.amount; since we already know that reserve > withdrawal.amount
In withdraw function at VUSD.sol#L48, add a check require(amount!=0, "Invalid amount");
In mintWithReserve function at VUSD.sol#L43, add below require
In deposit function at InsuranceFund.sol#L39, add a condition require(amount!=0, "Invalid amount")
In withdraw function at InsuranceFund.sol#L62, add a check require( _shares!=0,"Invalid shares");
In liquidate function at ClearingHouse.sol#L140, updatePositions function is not required since this is already called in _liquidateMaker and _liquidateTaker function
In addMarginFor function at MarginAccount.sol#L149, add new check
In removeMargin function at MarginAccount.sol#L177, margin[idx][trader] -= amount.toInt256(); can be unchecked since contract has already checked margin[idx][trader] >= amount.toInt256()
In removeMargin function at MarginAccount.sol#L168, add a check require(amount!=0,"Invalid amount");
In settleBadDebt function at MarginAccount.sol#L362, modify require(vusdBal < 0, "Nothing to repay"); to require(vusdBal <= 0, "Nothing to repay"); since if vusdBal is 0 then also there is nothing to repay
In weightedAndSpotCollateral function at MarginAccount.sol#L524 add a check to see margin[i][trader]==0 as shown below
The text was updated successfully, but these errors were encountered: