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

optimise settle function can save gas

Open lxhyl opened this issue 1 year ago • 0 comments

Related Issue

Which issue does this pull request resolve?

https://github.com/Uniswap/v4-core/issues/268

Description of changes

Use

https://github.com/Uniswap/v4-core/blob/d8c1ceed2a029cef8a9249f799c2a996bfa27107/contracts/PoolManager.sol#L369-L376

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

lxhyl avatar Jun 17 '23 01:06 lxhyl