-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: issue #145 - Deadline check is not effective allowing outdated s…
…lippage and allowing pending transactions to be unexpected executed
- Loading branch information
bwafflef
committed
May 17, 2023
1 parent
2d4e617
commit 2cf38fc
Showing
8 changed files
with
367 additions
and
19 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,239 @@ | ||
[ | ||
{ | ||
"inputs": [ | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "bytes", | ||
"name": "path", | ||
"type": "bytes" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "recipient", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "deadline", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "amountIn", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "amountOutMinimum", | ||
"type": "uint256" | ||
} | ||
], | ||
"internalType": "struct IUniswapV3Router.ExactInputParams", | ||
"name": "params", | ||
"type": "tuple" | ||
} | ||
], | ||
"name": "exactInput", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "amountOut", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "payable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "address", | ||
"name": "tokenIn", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "tokenOut", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "uint24", | ||
"name": "fee", | ||
"type": "uint24" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "recipient", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "deadline", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "amountIn", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "amountOutMinimum", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint160", | ||
"name": "sqrtPriceLimitX96", | ||
"type": "uint160" | ||
} | ||
], | ||
"internalType": "struct IUniswapV3Router.ExactInputSingleParams", | ||
"name": "params", | ||
"type": "tuple" | ||
} | ||
], | ||
"name": "exactInputSingle", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "amountOut", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "payable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "bytes", | ||
"name": "path", | ||
"type": "bytes" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "recipient", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "deadline", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "amountOut", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "amountInMaximum", | ||
"type": "uint256" | ||
} | ||
], | ||
"internalType": "struct IUniswapV3Router.ExactOutputParams", | ||
"name": "params", | ||
"type": "tuple" | ||
} | ||
], | ||
"name": "exactOutput", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "amountIn", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "payable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "address", | ||
"name": "tokenIn", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "tokenOut", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "uint24", | ||
"name": "fee", | ||
"type": "uint24" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "recipient", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "deadline", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "amountOut", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "amountInMaximum", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint160", | ||
"name": "sqrtPriceLimitX96", | ||
"type": "uint160" | ||
} | ||
], | ||
"internalType": "struct IUniswapV3Router.ExactOutputSingleParams", | ||
"name": "params", | ||
"type": "tuple" | ||
} | ||
], | ||
"name": "exactOutputSingle", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "amountIn", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "payable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "int256", | ||
"name": "amount0Delta", | ||
"type": "int256" | ||
}, | ||
{ | ||
"internalType": "int256", | ||
"name": "amount1Delta", | ||
"type": "int256" | ||
}, | ||
{ | ||
"internalType": "bytes", | ||
"name": "data", | ||
"type": "bytes" | ||
} | ||
], | ||
"name": "uniswapV3SwapCallback", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] |
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,75 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.16; | ||
|
||
import "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol"; | ||
|
||
/// @title Router token swapping functionality | ||
/// @notice Functions for swapping tokens via Uniswap V3 | ||
interface IUniswapV3Router 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); | ||
} |
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.