Created
April 13, 2021 12:10
-
-
Save novaknole/eefcb4a8d666a00362f94aba63813632 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.8; | |
contract Finance { | |
address owner; | |
constructor() public { | |
owner = msg.sender; | |
} | |
modifier onlyOwner() { | |
require(msg.sender == owner); | |
_; | |
} | |
receive() { | |
} | |
function transfer(address payable _to, address _token, uint256 _amount) onlyOwner external { | |
if (_token == address(0)) { | |
require(_to.send(_amount), ERROR_ETH_TRANSFER_FAILED); | |
} else { | |
require(IERC20(_token).safeTransfer(_to, _amount), ERROR_TOKEN_TRANSFER_FAILED); | |
} | |
} | |
function deposit(address _token, uint256 amount) onlyOwner payable external { | |
if (msg.value > 0) { | |
require(_token == address(0), ERROR_ETH_DEPOSIT_TOKEN_MISMATCH); | |
require(msg.value == _amount, ERROR_ETH_DEPOSIT_AMOUNT_MISMATCH); | |
} else { | |
require(isContract(_token), ERROR_TOKEN_NOT_CONTRACT); | |
require(IERC20(_token).safeTransferFrom(_from, address(this), _amount), ERROR_TOKEN_DEPOSIT_FAILED); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment