-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from terminal-fi/univ3fix2
uniswapv3 major rewrite and fixes for the pair
- Loading branch information
Showing
48 changed files
with
578 additions
and
1,349 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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.6.8; | ||
pragma experimental ABIEncoderV2; | ||
|
||
/// @title QuoterV2 Interface | ||
/// @notice Supports quoting the calculated amounts from exact input or exact output swaps. | ||
/// @notice For each pool also tells you the number of initialized ticks crossed 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 IQuoterV2 { | ||
struct QuoteExactInputSingleParams { | ||
address tokenIn; | ||
address tokenOut; | ||
uint256 amountIn; | ||
uint24 fee; | ||
uint160 sqrtPriceLimitX96; | ||
} | ||
|
||
/// @notice Returns the amount out received for a given exact input but for a swap of a single pool | ||
/// @param params The params for the quote, encoded as `QuoteExactInputSingleParams` | ||
/// tokenIn The token being swapped in | ||
/// tokenOut The token being swapped out | ||
/// fee The fee of the token pool to consider for the pair | ||
/// amountIn The desired input amount | ||
/// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap | ||
/// @return amountOut The amount of `tokenOut` that would be received | ||
/// @return sqrtPriceX96After The sqrt price of the pool after the swap | ||
/// @return initializedTicksCrossed The number of initialized ticks that the swap crossed | ||
/// @return gasEstimate The estimate of the gas that the swap consumes | ||
function quoteExactInputSingle(QuoteExactInputSingleParams calldata params) | ||
external | ||
returns ( | ||
uint256 amountOut, | ||
uint160 sqrtPriceX96After, | ||
uint32 initializedTicksCrossed, | ||
uint256 gasEstimate | ||
); | ||
|
||
struct QuoteExactOutputSingleParams { | ||
address tokenIn; | ||
address tokenOut; | ||
uint256 amount; | ||
uint24 fee; | ||
uint160 sqrtPriceLimitX96; | ||
} | ||
|
||
/// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool | ||
/// @param params The params for the quote, encoded as `QuoteExactOutputSingleParams` | ||
/// tokenIn The token being swapped in | ||
/// tokenOut The token being swapped out | ||
/// fee The fee of the token pool to consider for the pair | ||
/// amountOut The desired output amount | ||
/// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap | ||
/// @return amountIn The amount required as the input for the swap in order to receive `amountOut` | ||
/// @return sqrtPriceX96After The sqrt price of the pool after the swap | ||
/// @return initializedTicksCrossed The number of initialized ticks that the swap crossed | ||
/// @return gasEstimate The estimate of the gas that the swap consumes | ||
function quoteExactOutputSingle(QuoteExactOutputSingleParams calldata params) | ||
external | ||
returns ( | ||
uint256 amountIn, | ||
uint160 sqrtPriceX96After, | ||
uint32 initializedTicksCrossed, | ||
uint256 gasEstimate | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.