-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add PoolTicksCounter library * quoter exact input single * quoter test * return deltas instead * safe casting to correct types * QuoteExactInput skeleton * multiple entries * break handleRevert by type * quoteExactInput and unit tests * more QuoteExactInput tests * remove lgos * remove commented out struct * via-ir in ci * remove unused imports/functions * store iteration params locally instead of editing function input * pull out sqrtPriceLimit to its own function * PathKey to its own library * rename initializedTicksCrossed to initializedTicksLoaded * remove manual abi encoding in yul :p * fix linter warnings for Quoter * natspec for IQuoter * feat: update v4-core This commit updates v4 core to latest and fixes integration issues * fix: tests * style fixes * inheritdoc * ExactInSingleBatch * fix: update tests * fix: test router was borked * exact out * fix: alice comments * fix ExactOutput * add ExactOput unit tests * add quoteExactOutputBatch * remove solhint config * remove newline * add QuoteExactOutput in interface * refactor lockAcquired * move magic numbers to constants + doc * add more natspec * natspec * named imports * self-call branching * remove old code * remove console2 import * refactor PathKeyLib * amountOutCached * inherit ILockCallback * add base contracts and interfaces (#75) * remove unused errors * test lockAcquired reverts * remove ...Batch interface * REASON -> RESPONSE when valid * complete natspec * remove SwapInfo imports * rename to SwapParameters * move quoter structs into IQuoter interface * update to latest core * use prev values * change twamm to use pool getters * changes after merging main * use --via-ir in cli * fix formatting * fix FullRange/TWAMM hook * update ticks counter * update Quoter test * typo * typo * simplify handleRevertSingle * merge QuoteInput/OutputSingle structs * combine IQuoter structs * using ... ordering * update snapshots * move amountOutCached into inner call * using PathKeyLib for PathKey * fix amountOutCached * remove console2 import * resurface revert reason * clean up validateRevert * update natsppec * remove unused --------- Co-authored-by: Mark Toda <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: Sara Reynolds <[email protected]>
- Loading branch information
1 parent
0b46125
commit 63d64fc
Showing
37 changed files
with
1,251 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2771 | ||
2687 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
23377 | ||
22933 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
23624 | ||
23180 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2798 | ||
2738 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
22396 | ||
21892 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
22695 | ||
22191 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2130 | ||
2070 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
410761 | ||
407968 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
204683 | ||
201962 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
156432 | ||
153306 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
897565 | ||
1112212 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
200057 | ||
197519 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
386095 | ||
379147 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
114700 | ||
111940 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
154641 | ||
151523 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
254711 | ||
254660 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
245393 | ||
245360 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
54893 | ||
54869 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
45575 | ||
45569 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
72361 | ||
72316 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/OracleObserveBetweenOldestAndOldestPlusOne.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
6618 | ||
6492 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2130 | ||
2070 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2130 | ||
2070 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
88543 | ||
86878 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2130 | ||
2070 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2771 | ||
2687 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
6807 | ||
6684 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
6319 | ||
6193 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3466 | ||
3382 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
146158 | ||
145648 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.20; | ||
|
||
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol"; | ||
import {Currency} from "@uniswap/v4-core/src/types/Currency.sol"; | ||
import {PathKey} from "../libraries/PathKey.sol"; | ||
|
||
/// @title Quoter Interface | ||
/// @notice Supports quoting the delta amounts from exact input or exact output swaps. | ||
/// @notice For each pool also tells you the number of initialized ticks loaded and the sqrt price of the pool after the swap. | ||
/// @dev These functions are not marked view because they rely on calling non-view functions and reverting | ||
/// to compute the result. They are also not gas efficient and should not be called on-chain. | ||
interface IQuoter { | ||
error InvalidLockAcquiredSender(); | ||
error InvalidLockCaller(); | ||
error InvalidQuoteBatchParams(); | ||
error InsufficientAmountOut(); | ||
error LockFailure(); | ||
error NotSelf(); | ||
error UnexpectedRevertBytes(bytes revertData); | ||
|
||
struct PoolDeltas { | ||
int128 currency0Delta; | ||
int128 currency1Delta; | ||
} | ||
|
||
struct QuoteExactSingleParams { | ||
PoolKey poolKey; | ||
bool zeroForOne; | ||
address recipient; | ||
uint128 exactAmount; | ||
uint160 sqrtPriceLimitX96; | ||
bytes hookData; | ||
} | ||
|
||
struct QuoteExactParams { | ||
Currency exactCurrency; | ||
PathKey[] path; | ||
address recipient; | ||
uint128 exactAmount; | ||
} | ||
|
||
/// @notice Returns the delta amounts for a given exact input swap of a single pool | ||
/// @param params The params for the quote, encoded as `QuoteExactInputSingleParams` | ||
/// poolKey The key for identifying a V4 pool | ||
/// zeroForOne If the swap is from currency0 to currency1 | ||
/// recipient The intended recipient of the output tokens | ||
/// exactAmount The desired input amount | ||
/// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap | ||
/// hookData arbitrary hookData to pass into the associated hooks | ||
/// @return deltaAmounts Delta amounts resulted from the swap | ||
/// @return sqrtPriceX96After The sqrt price of the pool after the swap | ||
/// @return initializedTicksLoaded The number of initialized ticks that the swap loaded | ||
function quoteExactInputSingle(QuoteExactSingleParams calldata params) | ||
external | ||
returns (int128[] memory deltaAmounts, uint160 sqrtPriceX96After, uint32 initializedTicksLoaded); | ||
|
||
/// @notice Returns the delta amounts along the swap path for a given exact input swap | ||
/// @param params the params for the quote, encoded as 'QuoteExactInputParams' | ||
/// currencyIn The input currency of the swap | ||
/// path The path of the swap encoded as PathKeys that contains currency, fee, tickSpacing, and hook info | ||
/// recipient The intended recipient of the output tokens | ||
/// exactAmount The desired input amount | ||
/// @return deltaAmounts Delta amounts along the path resulted from the swap | ||
/// @return sqrtPriceX96AfterList List of the sqrt price after the swap for each pool in the path | ||
/// @return initializedTicksLoadedList List of the initialized ticks that the swap loaded for each pool in the path | ||
function quoteExactInput(QuoteExactParams memory params) | ||
external | ||
returns ( | ||
int128[] memory deltaAmounts, | ||
uint160[] memory sqrtPriceX96AfterList, | ||
uint32[] memory initializedTicksLoadedList | ||
); | ||
|
||
/// @notice Returns the delta amounts for a given exact output swap of a single pool | ||
/// @param params The params for the quote, encoded as `QuoteExactOutputSingleParams` | ||
/// poolKey The key for identifying a V4 pool | ||
/// zeroForOne If the swap is from currency0 to currency1 | ||
/// recipient The intended recipient of the output tokens | ||
/// exactAmount The desired input amount | ||
/// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap | ||
/// hookData arbitrary hookData to pass into the associated hooks | ||
/// @return deltaAmounts Delta amounts resulted from the swap | ||
/// @return sqrtPriceX96After The sqrt price of the pool after the swap | ||
/// @return initializedTicksLoaded The number of initialized ticks that the swap loaded | ||
function quoteExactOutputSingle(QuoteExactSingleParams calldata params) | ||
external | ||
returns (int128[] memory deltaAmounts, uint160 sqrtPriceX96After, uint32 initializedTicksLoaded); | ||
|
||
/// @notice Returns the delta amounts along the swap path for a given exact output swap | ||
/// @param params the params for the quote, encoded as 'QuoteExactOutputParams' | ||
/// currencyOut The output currency of the swap | ||
/// path The path of the swap encoded as PathKeys that contains currency, fee, tickSpacing, and hook info | ||
/// recipient The intended recipient of the output tokens | ||
/// exactAmount The desired output amount | ||
/// @return deltaAmounts Delta amounts along the path resulted from the swap | ||
/// @return sqrtPriceX96AfterList List of the sqrt price after the swap for each pool in the path | ||
/// @return initializedTicksLoadedList List of the initialized ticks that the swap loaded for each pool in the path | ||
function quoteExactOutput(QuoteExactParams memory params) | ||
external | ||
returns ( | ||
int128[] memory deltaAmounts, | ||
uint160[] memory sqrtPriceX96AfterList, | ||
uint32[] memory initializedTicksLoadedList | ||
); | ||
} |
Oops, something went wrong.