Transaction Hash:
Block:
16549960 at Feb-03-2023 06:10:23 PM +UTC
Transaction Fee:
0.027260380421402403 ETH
$81.11
Gas Used:
644,313 Gas / 42.309219931 Gwei
Account State Difference:
Address | Before | After | State Difference | ||
---|---|---|---|---|---|
0x0A9f824C...3a872Dff4 | (Layer Zero: Swappable Bridge) |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| ||
0x5e9Bf1dD...b08eA3d3c | (LayerZero: Deployer) |
1.47149469683105085 Eth
Nonce: 5
|
1.444234316409648447 Eth
Nonce: 6
| 0.027260380421402403 | |
0xDAFEA492...692c98Bc5
Miner
| (Flashbots: Builder) | 1.258748115364333057 Eth | 1.259587430376754837 Eth | 0.00083931501242178 |
Execution Trace
SwappableBridge.60e06040( )
12345678910111213141516171819202122232425// SPDX-License-Identifier: MITpragma solidity ^0.8.0;import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";import "@layerzerolabs/solidity-examples/contracts/token/oft/IOFTCore.sol";import "./INativeOFT.sol";contract SwappableBridge {IOFTCore public immutable oft;INativeOFT public immutable nativeOft;IUniswapV2Router02 public immutable uniswapRouter;constructor(address _oft, address _nativeOft, address _uniswapRouter) {require(_oft != address(0), "SwappableBridge: invalid OFT address");require(_nativeOft != address(0), "SwappableBridge: invalid Native OFT address");require(_uniswapRouter != address(0), "SwappableBridge: invalid Uniswap Router address");oft = IOFTCore(_oft);nativeOft = INativeOFT(_nativeOft);uniswapRouter = IUniswapV2Router02(_uniswapRouter);}function swapAndBridge(uint amountIn, uint amountOutMin, uint16 dstChainId, address to, address payable refundAddress, address zroPaymentAddress,bytes calldata adapterParams) external payable {require(to != address(0), "SwappableBridge: invalid to address");require(msg.value >= amountIn, "SwappableBridge: not enough value sent");address[] memory path = new address[](2);path[0] = uniswapRouter.WETH();path[1] = address(oft);uint[] memory amounts = uniswapRouter.swapExactETHForTokens{value: amountIn}(amountOutMin, path, address(this), block.timestamp);oft.sendFrom{value: msg.value - amountIn}(address(this), dstChainId, abi.encodePacked(to), amounts[1], refundAddress, zroPaymentAddress,adapterParams);