Feature Tip: Add private address tag to any address under My Name Tag !
Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Multichain Info
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
DhaiSwapper
Compiler Version
v0.8.30+commit.73712a01
Optimization Enabled:
No with 200 runs
Other Settings:
prague EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
/// @notice Minimal interfaces for Uniswap v3 SwapRouter and WETH9 to avoid external deps
interface ISwapRouterV3 {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
}
interface IWETH9Minimal {
function deposit() external payable;
function approve(address spender, uint256 value) external returns (bool);
}
/// @title ETH->DAI Uniswap v3 Swapper
/// @notice Single-function contract: accepts native ETH, swaps for DAI via Uniswap v3, sends DAI to caller
contract DhaiSwapper {
ISwapRouterV3 public immutable swapRouter;
address public immutable WETH9;
address public immutable DAI;
uint24 public immutable poolFee;
event Swap(address indexed sender, uint256 amountIn, uint256 amountout);
constructor(address _swapRouter, address _weth9, address _dai, uint24 _poolFee) {
require(_swapRouter != address(0) && _weth9 != address(0) && _dai != address(0), "ZERO_ADDR");
swapRouter = ISwapRouterV3(_swapRouter);
WETH9 = _weth9;
DAI = _dai;
poolFee = _poolFee; // e.g. 500, 3000, or 10000
// set a one-time infinite approval so swaps don't waste gas re-approving
require(IWETH9Minimal(WETH9).approve(address(swapRouter), type(uint256).max), "APPROVE_INIT_FAIL");
}
/// @notice Swap exact ETH sent for DAI and send DAI to msg.sender
/// @param minDaiOut Minimum DAI expected (slippage protection)
/// @return amountOut The amount of DAI received
function swapExactEthForDai(uint256 minDaiOut) external payable returns (uint256 amountOut) {
amountOut = _swapExactEthForDaiTo(msg.sender, msg.value, minDaiOut);
}
/// @dev Internal helper used by both the explicit function and the receive() handler
function _swapExactEthForDaiTo(address recipient, uint256 amountIn, uint256 minOut)
internal
returns (uint256 amountOut)
{
require(amountIn > 0, "NO_ETH");
IWETH9Minimal(WETH9).deposit{value: amountIn}();
amountOut = swapRouter.exactInputSingle(
ISwapRouterV3.ExactInputSingleParams({
tokenIn: WETH9,
tokenOut: DAI,
fee: poolFee,
recipient: recipient,
deadline: block.timestamp,
amountIn: amountIn,
amountOutMinimum: minOut,
sqrtPriceLimitX96: 0
})
);
emit Swap(recipient, amountIn, amountOut);
}
/// @notice Auto-swap on plain ETH receives and send DAI back to the sender
receive() external payable {
if (msg.value == 0) return;
_swapExactEthForDaiTo(msg.sender, msg.value, 0);
}
}{
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"@uniswap/v4-core/=lib/v4-periphery/lib/v4-core/",
"ds-test/=lib/v4-core/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"hardhat/=lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"permit2/=lib/v4-periphery/lib/permit2/",
"solidity-bytes-utils/=lib/solidity-bytes-utils/contracts/",
"solmate/=lib/v4-core/lib/solmate/",
"v4-core/=lib/v4-core/src/",
"v4-periphery/=lib/v4-periphery/"
],
"optimizer": {
"enabled": false,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "prague",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_swapRouter","type":"address"},{"internalType":"address","name":"_weth9","type":"address"},{"internalType":"address","name":"_dai","type":"address"},{"internalType":"uint24","name":"_poolFee","type":"uint24"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountout","type":"uint256"}],"name":"Swap","type":"event"},{"inputs":[],"name":"DAI","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH9","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolFee","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"minDaiOut","type":"uint256"}],"name":"swapExactEthForDai","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"swapRouter","outputs":[{"internalType":"contract ISwapRouterV3","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
610100604052348015610010575f5ffd5b50604051610daa380380610daa8339818101604052810190610032919061033c565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415801561009a57505f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156100d257505f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b610111576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610108906103fa565b60405180910390fd5b8373ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508273ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff16815250508062ffffff1660e08162ffffff168152505060a05173ffffffffffffffffffffffffffffffffffffffff1663095ea7b36080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b815260040161021e92919061043f565b6020604051808303815f875af115801561023a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061025e919061049b565b61029d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161029490610510565b60405180910390fd5b5050505061052e565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6102d3826102aa565b9050919050565b6102e3816102c9565b81146102ed575f5ffd5b50565b5f815190506102fe816102da565b92915050565b5f62ffffff82169050919050565b61031b81610304565b8114610325575f5ffd5b50565b5f8151905061033681610312565b92915050565b5f5f5f5f60808587031215610354576103536102a6565b5b5f610361878288016102f0565b9450506020610372878288016102f0565b9350506040610383878288016102f0565b925050606061039487828801610328565b91505092959194509250565b5f82825260208201905092915050565b7f5a45524f5f4144445200000000000000000000000000000000000000000000005f82015250565b5f6103e46009836103a0565b91506103ef826103b0565b602082019050919050565b5f6020820190508181035f830152610411816103d8565b9050919050565b610421816102c9565b82525050565b5f819050919050565b61043981610427565b82525050565b5f6040820190506104525f830185610418565b61045f6020830184610430565b9392505050565b5f8115159050919050565b61047a81610466565b8114610484575f5ffd5b50565b5f8151905061049581610471565b92915050565b5f602082840312156104b0576104af6102a6565b5b5f6104bd84828501610487565b91505092915050565b7f415050524f56455f494e49545f4641494c0000000000000000000000000000005f82015250565b5f6104fa6011836103a0565b9150610505826104c6565b602082019050919050565b5f6020820190508181035f830152610527816104ee565b9050919050565b60805160a05160c05160e0516108266105845f395f81816102c701526103ef01525f818161028b015261045b01525f818161018a0152818161024f015261041301525f8181610207015261043701526108265ff3fe60806040526004361061004d575f3560e01c8063089fe6aa1461006d5780634aa4a4fc14610097578063c31c9c07146100c1578063e0bab4c4146100eb578063ee01720f1461011557610069565b36610069575f3403156100675761006533345f610145565b505b005b5f5ffd5b348015610078575f5ffd5b506100816103ed565b60405161008e91906104ad565b60405180910390f35b3480156100a2575f5ffd5b506100ab610411565b6040516100b89190610505565b60405180910390f35b3480156100cc575f5ffd5b506100d5610435565b6040516100e29190610579565b60405180910390f35b3480156100f6575f5ffd5b506100ff610459565b60405161010c9190610505565b60405180910390f35b61012f600480360381019061012a91906105c9565b61047d565b60405161013c9190610603565b60405180910390f35b5f5f8311610188576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161017f90610676565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0846040518263ffffffff1660e01b81526004015f604051808303818588803b1580156101ee575f5ffd5b505af1158015610200573d5f5f3e3d5ffd5b50505050507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663414bf3896040518061010001604052807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1681526020017f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1681526020017f000000000000000000000000000000000000000000000000000000000000000062ffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1681526020014281526020018681526020018581526020015f73ffffffffffffffffffffffffffffffffffffffff168152506040518263ffffffff1660e01b81526004016103549190610770565b6020604051808303815f875af1158015610370573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610394919061079e565b90508373ffffffffffffffffffffffffffffffffffffffff167f77f92a1b6a1a11de8ca49515ad4c1fad45632dd3442167d74b90b304a3c7a75884836040516103de9291906107c9565b60405180910390a29392505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b5f610489333484610145565b9050919050565b5f62ffffff82169050919050565b6104a781610490565b82525050565b5f6020820190506104c05f83018461049e565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6104ef826104c6565b9050919050565b6104ff816104e5565b82525050565b5f6020820190506105185f8301846104f6565b92915050565b5f819050919050565b5f61054161053c610537846104c6565b61051e565b6104c6565b9050919050565b5f61055282610527565b9050919050565b5f61056382610548565b9050919050565b61057381610559565b82525050565b5f60208201905061058c5f83018461056a565b92915050565b5f5ffd5b5f819050919050565b6105a881610596565b81146105b2575f5ffd5b50565b5f813590506105c38161059f565b92915050565b5f602082840312156105de576105dd610592565b5b5f6105eb848285016105b5565b91505092915050565b6105fd81610596565b82525050565b5f6020820190506106165f8301846105f4565b92915050565b5f82825260208201905092915050565b7f4e4f5f45544800000000000000000000000000000000000000000000000000005f82015250565b5f61066060068361061c565b915061066b8261062c565b602082019050919050565b5f6020820190508181035f83015261068d81610654565b9050919050565b61069d816104e5565b82525050565b6106ac81610490565b82525050565b6106bb81610596565b82525050565b6106ca816104c6565b82525050565b61010082015f8201516106e55f850182610694565b5060208201516106f86020850182610694565b50604082015161070b60408501826106a3565b50606082015161071e6060850182610694565b50608082015161073160808501826106b2565b5060a082015161074460a08501826106b2565b5060c082015161075760c08501826106b2565b5060e082015161076a60e08501826106c1565b50505050565b5f610100820190506107845f8301846106d0565b92915050565b5f815190506107988161059f565b92915050565b5f602082840312156107b3576107b2610592565b5b5f6107c08482850161078a565b91505092915050565b5f6040820190506107dc5f8301856105f4565b6107e960208301846105f4565b939250505056fea26469706673582212206874c650e81d012bfb409f4a7973d9bf45f810c0f4f7178afaa174b759662f7e64736f6c634300081e0033000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8
Deployed Bytecode
0x60806040526004361061004d575f3560e01c8063089fe6aa1461006d5780634aa4a4fc14610097578063c31c9c07146100c1578063e0bab4c4146100eb578063ee01720f1461011557610069565b36610069575f3403156100675761006533345f610145565b505b005b5f5ffd5b348015610078575f5ffd5b506100816103ed565b60405161008e91906104ad565b60405180910390f35b3480156100a2575f5ffd5b506100ab610411565b6040516100b89190610505565b60405180910390f35b3480156100cc575f5ffd5b506100d5610435565b6040516100e29190610579565b60405180910390f35b3480156100f6575f5ffd5b506100ff610459565b60405161010c9190610505565b60405180910390f35b61012f600480360381019061012a91906105c9565b61047d565b60405161013c9190610603565b60405180910390f35b5f5f8311610188576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161017f90610676565b60405180910390fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1663d0e30db0846040518263ffffffff1660e01b81526004015f604051808303818588803b1580156101ee575f5ffd5b505af1158015610200573d5f5f3e3d5ffd5b50505050507f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156473ffffffffffffffffffffffffffffffffffffffff1663414bf3896040518061010001604052807f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1681526020017f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f73ffffffffffffffffffffffffffffffffffffffff1681526020017f0000000000000000000000000000000000000000000000000000000000000bb862ffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1681526020014281526020018681526020018581526020015f73ffffffffffffffffffffffffffffffffffffffff168152506040518263ffffffff1660e01b81526004016103549190610770565b6020604051808303815f875af1158015610370573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610394919061079e565b90508373ffffffffffffffffffffffffffffffffffffffff167f77f92a1b6a1a11de8ca49515ad4c1fad45632dd3442167d74b90b304a3c7a75884836040516103de9291906107c9565b60405180910390a29392505050565b7f0000000000000000000000000000000000000000000000000000000000000bb881565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b7f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156481565b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f81565b5f610489333484610145565b9050919050565b5f62ffffff82169050919050565b6104a781610490565b82525050565b5f6020820190506104c05f83018461049e565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6104ef826104c6565b9050919050565b6104ff816104e5565b82525050565b5f6020820190506105185f8301846104f6565b92915050565b5f819050919050565b5f61054161053c610537846104c6565b61051e565b6104c6565b9050919050565b5f61055282610527565b9050919050565b5f61056382610548565b9050919050565b61057381610559565b82525050565b5f60208201905061058c5f83018461056a565b92915050565b5f5ffd5b5f819050919050565b6105a881610596565b81146105b2575f5ffd5b50565b5f813590506105c38161059f565b92915050565b5f602082840312156105de576105dd610592565b5b5f6105eb848285016105b5565b91505092915050565b6105fd81610596565b82525050565b5f6020820190506106165f8301846105f4565b92915050565b5f82825260208201905092915050565b7f4e4f5f45544800000000000000000000000000000000000000000000000000005f82015250565b5f61066060068361061c565b915061066b8261062c565b602082019050919050565b5f6020820190508181035f83015261068d81610654565b9050919050565b61069d816104e5565b82525050565b6106ac81610490565b82525050565b6106bb81610596565b82525050565b6106ca816104c6565b82525050565b61010082015f8201516106e55f850182610694565b5060208201516106f86020850182610694565b50604082015161070b60408501826106a3565b50606082015161071e6060850182610694565b50608082015161073160808501826106b2565b5060a082015161074460a08501826106b2565b5060c082015161075760c08501826106b2565b5060e082015161076a60e08501826106c1565b50505050565b5f610100820190506107845f8301846106d0565b92915050565b5f815190506107988161059f565b92915050565b5f602082840312156107b3576107b2610592565b5b5f6107c08482850161078a565b91505092915050565b5f6040820190506107dc5f8301856105f4565b6107e960208301846105f4565b939250505056fea26469706673582212206874c650e81d012bfb409f4a7973d9bf45f810c0f4f7178afaa174b759662f7e64736f6c634300081e0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8
-----Decoded View---------------
Arg [0] : _swapRouter (address): 0xE592427A0AEce92De3Edee1F18E0157C05861564
Arg [1] : _weth9 (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [2] : _dai (address): 0x6B175474E89094C44Da98b954EedeAC495271d0F
Arg [3] : _poolFee (uint24): 3000
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Arg [1] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [2] : 0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000bb8
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.