Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View-only quoter #296

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

View-only quoter #296

wants to merge 4 commits into from

Conversation

Jun1on
Copy link
Contributor

@Jun1on Jun1on commented Aug 8, 2024

Related Issue

Current quoter simulates a swap and reverts, using a lot of gas.

Description of changes

This view-only quoter aims to quote a v4 pool cheaper by removing the revert and the unused state updates. Currently, this can only quote swaps without hook executions that change the output of a swap.

This code is adapted from view-quoter-v3.

@saucepoint saucepoint mentioned this pull request Aug 13, 2024
8 tasks
Comment on lines +32 to +38
function nextInitializedTickWithinOneWord(
IPoolManager poolManager,
PoolId poolId,
int24 tickSpacing,
int24 tick,
bool lte
) internal view returns (int24 next, bool initialized) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it bothers me that we need to re-implement this again in periphery. Here's a draft PR on core which makes the library usable by periphery

Uniswap/v4-core#832

src/libraries/QuoterMath.sol Outdated Show resolved Hide resolved
Comment on lines +11 to +20
/// @param poolKey The poolKey identifying the pool traded against
/// currency0
/// currency1
/// fee
/// tickSpacing
/// hooks
/// @param swapParams The parameters used for the swap
/// zeroForOne
/// amountSpecified
/// sqrtPriceLimitX96
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have we conventionally done natspec like this for struct params :thonk:

src/libraries/QuoterMath.sol Outdated Show resolved Hide resolved
src/libraries/QuoterMath.sol Outdated Show resolved Hide resolved
function quote(IPoolManager poolManager, PoolKey calldata poolKey, IPoolManager.SwapParams calldata swapParams)
internal
view
returns (int256 amount0, int256 amount1, uint160 sqrtPriceAfterX96, uint32 initializedTicksCrossed)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional but I like the idea of making the return type a BalanceDelta 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants