v4-core
v4-core copied to clipboard
optimise settle function can save gas
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()));
}