-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: rewards * feat: add univ3
- Loading branch information
Showing
7 changed files
with
311 additions
and
231 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
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,95 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity 0.8.14; | ||
|
||
/// @title Callback for IUniswapV3PoolActions#swap | ||
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface | ||
interface IUniswapV3SwapCallback { | ||
/// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. | ||
/// @dev In the implementation you must pay the pool tokens owed for the swap. | ||
/// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. | ||
/// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. | ||
/// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by | ||
/// the end of the swap. If positive, the callback must send that amount of token0 to the pool. | ||
/// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by | ||
/// the end of the swap. If positive, the callback must send that amount of token1 to the pool. | ||
/// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call | ||
function uniswapV3SwapCallback( | ||
int256 amount0Delta, | ||
int256 amount1Delta, | ||
bytes calldata data | ||
) external; | ||
} | ||
|
||
/// @title Router token swapping functionality | ||
/// @notice Functions for swapping tokens via Uniswap V3 | ||
interface ISwapRouter is IUniswapV3SwapCallback { | ||
struct ExactInputSingleParams { | ||
address tokenIn; | ||
address tokenOut; | ||
uint24 fee; | ||
address recipient; | ||
uint256 deadline; | ||
uint256 amountIn; | ||
uint256 amountOutMinimum; | ||
uint160 sqrtPriceLimitX96; | ||
} | ||
|
||
/// @notice Swaps `amountIn` of one token for as much as possible of another token | ||
/// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata | ||
/// @return amountOut The amount of the received token | ||
function exactInputSingle( | ||
ExactInputSingleParams calldata params | ||
) external payable returns (uint256 amountOut); | ||
|
||
struct ExactInputParams { | ||
bytes path; | ||
address recipient; | ||
uint256 deadline; | ||
uint256 amountIn; | ||
uint256 amountOutMinimum; | ||
} | ||
|
||
/// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path | ||
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata | ||
/// @return amountOut The amount of the received token | ||
function exactInput( | ||
ExactInputParams calldata params | ||
) external payable returns (uint256 amountOut); | ||
|
||
struct ExactOutputSingleParams { | ||
address tokenIn; | ||
address tokenOut; | ||
uint24 fee; | ||
address recipient; | ||
uint256 deadline; | ||
uint256 amountOut; | ||
uint256 amountInMaximum; | ||
uint160 sqrtPriceLimitX96; | ||
} | ||
|
||
/// @notice Swaps as little as possible of one token for `amountOut` of another token | ||
/// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata | ||
/// @return amountIn The amount of the input token | ||
function exactOutputSingle( | ||
ExactOutputSingleParams calldata params | ||
) external payable returns (uint256 amountIn); | ||
|
||
struct ExactOutputParams { | ||
bytes path; | ||
address recipient; | ||
uint256 deadline; | ||
uint256 amountOut; | ||
uint256 amountInMaximum; | ||
} | ||
|
||
/// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) | ||
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata | ||
/// @return amountIn The amount of the input token | ||
function exactOutput( | ||
ExactOutputParams calldata params | ||
) external payable returns (uint256 amountIn); | ||
|
||
// Taken from https://soliditydeveloper.com/uniswap3 | ||
// Manually added to the interface | ||
function refundETH() external payable; | ||
} |
Oops, something went wrong.