Skip to content
Verified contractPartial

WethHelper

Address0x3b5bdccdfa2a0a1911984f203c19628eeb6036e0
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.5.13

 

Same code

1 more contract

 

Details

Compiler
solc 0.5.13+commit.5b0b510c
Language
solidity
Optimization
Yes, 200 runs
License
Not stated
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
9,061,031
Creation transaction
0x09f4401e95…3eacd2f204
Main copy (most transactions)
0xbd47502c…07e40a34

WethHelper.sol

/**
 * Copyright 2017-2019, bZeroX, LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0.
 */

pragma solidity 0.5.13;


contract iERC20 {
  string public name;
  uint8 public decimals;
  string public symbol;
  function totalSupply() public view returns (uint256);
  function balanceOf(address _who) public view returns (uint256);
  function transfer(address _to, uint256 _value) public returns (bool);
  function allowance(address _owner, address _spender) public view returns (uint256);
  function transferFrom(address _from, address _to, uint256 _value) public returns (bool);
  function approve(address _spender, uint256 _value) public returns (bool);
  event Transfer(address indexed from, address indexed to, uint256 value);
  event Approval(address indexed owner, address indexed spender, uint256 value);
}

contract iWETH is iERC20 {
    function deposit() external payable;
    function withdraw(uint256 wad) external;
}

contract WethHelper {

    iWETH public weth = iWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);

    function()
        external
        payable
    {}

    function claimEther(
        address receiver,
        uint256 amount)
        external
        returns (uint256 claimAmount)
    {
        claimAmount = weth.balanceOf(address(this));
        if (claimAmount != 0) {
            weth.withdraw(claimAmount);
        }
        claimAmount = address(this).balance;

        if (amount != 0) {
            require (amount <= claimAmount,
                "balance too low"
            );
            claimAmount = amount;
        }

        (bool success,) = receiver.call.value(claimAmount)("");
        require(success,
            "transfer failed"
        );
    }

    function claimToken(
        address tokenAddress,
        address receiver,
        uint256 amount)
        external
        returns (uint256 claimAmount)
    {
        iERC20 token = iERC20(tokenAddress);
        claimAmount = token.balanceOf(address(this));

        if (amount != 0) {
            require (amount <= claimAmount,
                "balance too low"
            );
            claimAmount = amount;
        }

        require(token.transfer(
            receiver,
            claimAmount),
            "transfer failed"
        );
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.