编译器
0.8.17+commit.8df45f5f
文件 1 的 7:Errors.sol
pragma solidity 0.8.17;
library Errors {
error InvalidMsgValue();
error ETHTransferFailed();
}
文件 2 的 7:EthReceiver.sol
pragma solidity ^0.8.0;
pragma abicoder v1;
abstract contract EthReceiver {
error EthDepositRejected();
receive() external payable {
_receive();
}
function _receive() internal virtual {
if (msg.sender == tx.origin) revert EthDepositRejected();
}
}
文件 3 的 7:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
文件 4 的 7:IPostInteractionNotificationReceiver.sol
pragma solidity 0.8.17;
pragma abicoder v1;
interface IPostInteractionNotificationReceiver {
function fillOrderPostInteraction(
bytes32 orderHash,
address maker,
address taker,
uint256 makingAmount,
uint256 takingAmount,
uint256 remainingAmount,
bytes memory interactionData
) external;
}
文件 5 的 7:IWETH.sol
pragma solidity ^0.8.0;
pragma abicoder v1;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IWETH is IERC20 {
function deposit() external payable;
function withdraw(uint256 amount) external;
}
文件 6 的 7:OnlyWethReceiver.sol
pragma solidity ^0.8.0;
pragma abicoder v1;
import "./EthReceiver.sol";
abstract contract OnlyWethReceiver is EthReceiver {
address private immutable _WETH;
constructor(address weth) {
_WETH = address(weth);
}
function _receive() internal virtual override {
if (msg.sender != _WETH) revert EthDepositRejected();
}
}
文件 7 的 7:WethUnwrapper.sol
pragma solidity 0.8.17;
pragma abicoder v1;
import "@1inch/solidity-utils/contracts/OnlyWethReceiver.sol";
import "@1inch/solidity-utils/contracts/interfaces/IWETH.sol";
import "../interfaces/IPostInteractionNotificationReceiver.sol";
import "../libraries/Errors.sol";
contract WethUnwrapper is OnlyWethReceiver, IPostInteractionNotificationReceiver {
IWETH private immutable _WETH;
uint256 private constant _RAW_CALL_GAS_LIMIT = 5000;
constructor(IWETH weth) OnlyWethReceiver(address(weth)) {
_WETH = weth;
}
function fillOrderPostInteraction(
bytes32 ,
address maker,
address ,
uint256 ,
uint256 takingAmount,
uint256 ,
bytes calldata
) external override {
_WETH.withdraw(takingAmount);
(bool success, ) = maker.call{value: takingAmount, gas: _RAW_CALL_GAS_LIMIT}("");
if (!success) revert Errors.ETHTransferFailed();
}
}
{
"compilationTarget": {
"contracts/helpers/WethUnwrapper.sol": "WethUnwrapper"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 1000000
},
"remappings": []
}
[{"inputs":[{"internalType":"contract IWETH","name":"weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ETHTransferFailed","type":"error"},{"inputs":[],"name":"EthDepositRejected","type":"error"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"takingAmount","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"fillOrderPostInteraction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]