Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"EPICswap/demo1.sol": {
"content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.20;\r
\r
interface IV4Quoter {\r
struct PoolKey {\r
address currency0;\r
address currency1;\r
uint24 fee;\r
int24 tickSpacing;\r
address hooks;\r
}\r
\r
struct QuoteExactSingleParams {\r
PoolKey poolKey;\r
bool zeroForOne;\r
uint128 exactAmount;\r
bytes hookData;\r
}\r
\r
function quoteExactInputSingle(QuoteExactSingleParams memory params)\r
external\r
returns (uint256 amountOut, uint256 gasEstimate);\r
}\r
\r
interface IV3Quoter {\r
function quoteExactInputSingle(\r
address tokenIn,\r
address tokenOut,\r
uint24 fee,\r
uint256 amountIn,\r
uint160 sqrtPriceLimitX96\r
) external returns (uint256 amountOut);\r
}\r
\r
contract UniQuoteChecker {\r
address public constant TOKEN_SELL = 0x94314a14Df63779c99C0764a30e0CD22fA78fC0E; // 要卖出的代币\r
address public constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\r
address public constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;\r
address public constant ETH = 0x0000000000000000000000000000000000000000;\r
\r
address public constant V4_QUOTER = 0x52F0E24D1c21C8A0cB1e5a5dD6198556BD9E1203;\r
address public constant V3_QUOTER = 0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6;\r
\r
/// @notice 传入卖出数量 (sellAmount) 和 USDT 基准值 (usdtBaseline),并附带 ETH\r
function check(uint256 sellAmount) external returns(uint256 usdtOut) {\r
// 1. V4 查询 TOKEN_SELL -> ETH\r
IV4Quoter.QuoteExactSingleParams memory params = IV4Quoter.QuoteExactSingleParams({\r
poolKey: IV4Quoter.PoolKey({\r
currency0: ETH,\r
currency1: TOKEN_SELL,\r
fee: 3000, // 0.3%\r
tickSpacing: 60,\r
hooks: address(0)\r
}),\r
zeroForOne: false, // TOKEN_SELL -> ETH\r
exactAmount: uint128(sellAmount),\r
hookData: ""\r
});\r
\r
(uint256 ethAmount, ) = IV4Quoter(V4_QUOTER).quoteExactInputSingle(params);\r
\r
// 2. V3 查询 ETH -> USDT\r
usdtOut = IV3Quoter(V3_QUOTER).quoteExactInputSingle(\r
WETH,\r
USDT,\r
100, // 0.01%\r
ethAmount,\r
0\r
);\r
\r
// 3. 判断差值,如果条件不满足则回滚\r
return usdtOut;\r
}\r
}\r
"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": []
}
}}
Submitted on: 2025-10-21 13:45:51
Comments
Log in to comment.
No comments yet.