v4-core icon indicating copy to clipboard operation
v4-core copied to clipboard

Optimise settle function

Open lxhyl opened this issue 1 year ago • 0 comments

Component

Pool Actions (swap, modifyPosition, donate, take, settle, mint)

Describe the suggested feature and problem it solves.

PoolManager.sol Settle() methods L371 get an new value and stored it. L372 read it. But we can use a temp variable to save one storage read.

Describe the desired implementation.

 function settle(Currency currency) external payable override noDelegateCall onlyByLocker returns (uint256 paid) {
        uint256 reservesBefore = reservesOf[currency];
        uint256 reservesNow = currency.balanceOfSelf();
        reservesOf[currency] = reservesNow;
        paid = reservesNow - reservesBefore;
        // subtraction must be safe
        _accountDelta(currency, -(paid.toInt128()));
   }

Describe alternatives.

No response

Additional context.

No response

lxhyl avatar Jun 17 '23 01:06 lxhyl