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

FullRange hook could benefit from some gas optimizations

Open atiselsts opened this issue 2 years ago • 0 comments

Component

Gas Optimization, General design optimization (improving efficiency, cleanliness, or developer experience)

Describe the suggested feature and problem it solves.

The FullRange hook would be very useful to emulate v2-pool behavior, but it's code needs some love.

Describe the desired implementation.

  • use larger tick spacing to make swaps slightly cheaper
  • precompute the sqrtRatioX96 where possible
  • simplify logic

Describe alternatives.

The current tick spacing for the full range pool is set to 60, probably to match 0.3% pools in v3. Other than familiarity with this number, there's no particular reason to do so – at least not one that I know of. If there are some reasons related to Uniswap integrations, let me know. In contrast, the most gas efficient approach would be to set a single tick range for the whole pool. That is clearly not possible at the moment, as the max tick range is limited by a maximal value of a 16-bit integer. However, even changing from 60 to a number closer to 30000 should give noticable gas savings for swappers, on the aggregate.

Additional context.

No response

atiselsts avatar Dec 10 '23 17:12 atiselsts