code-423n4 / 2022-03-sublime-findings

0 stars 0 forks source link

Gas Optimizations #66

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago
  1. considered using uint128 can save gas

Proof of Concept: https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L86 https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/LenderPool.sol#L64

Recommended Mitigation Steps:

struct Limits {
        uint128 min;
        uint128 max;
    }

========================================================================

  1. More efficient gas usage by removing && operator

Proof of Concept: https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L406 https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L418 https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L430 https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L442 https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L478 https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L642

Recommended Mitigation Steps:

require(!(borrowLimitLimits.min == _min, 'UBLL2');
require(!(borrowLimitLimits.max == _max), 'UBLL2');

========================================================================

ritik99 commented 2 years ago

Suggestions given by the warden are valid