Created
December 29, 2022 13:32
-
-
Save thexeromin/3ecda55342a440299464bab02356261a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.7; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
import "@openzeppelin/contracts/utils/math/SafeMath.sol"; | |
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | |
contract BridgeBSC is Ownable { | |
using SafeMath for uint256; | |
IERC20 briseToken = IERC20(0xB66651FE14178A10017053A2417565A88162eC17); | |
address public tokenReceiver = 0x7604cC735Baaf33283dc4f3372A7B4A14B93Ce10; | |
address public feeReceiver = 0x7604cC735Baaf33283dc4f3372A7B4A14B93Ce10; | |
uint256 public fee = 5; | |
uint256 public feeDenominator = 10000; | |
// Check token allowance | |
modifier checkAllowance(uint amount) { | |
require(briseToken.allowance(msg.sender, address(this)) >= amount, "Error"); | |
_; | |
} | |
function initiate(uint256 _amount) public payable checkAllowance(_amount) { | |
uint256 feeAmount = _amount.mul(fee).div(feeDenominator); | |
briseToken.transferFrom(msg.sender, feeReceiver, feeAmount); | |
briseToken.transferFrom(msg.sender, address(this), _amount - feeAmount); | |
emit Received(msg.sender, _amount - feeAmount); | |
} | |
function withdrawETH(uint256 _amount) public onlyOwner { | |
bool sent = payable(tokenReceiver).send(_amount); | |
require(sent, "Failed to send BRISE"); | |
emit Withdraw(tokenReceiver, _amount); | |
} | |
function withdrawBRISE(uint256 _amount) public onlyOwner { | |
briseToken.transfer(feeReceiver, _amount); | |
} | |
function transfer(address _to, uint256 _amount) public onlyOwner checkAllowance(_amount) { | |
briseToken.transferFrom(msg.sender, _to, _amount); | |
} | |
function updateTokenReceiver(address _receiver) public onlyOwner { | |
tokenReceiver = _receiver; | |
} | |
function updateFee(uint256 _fee, uint256 _feeDenominator) public onlyOwner { | |
fee = _fee; | |
feeDenominator = _feeDenominator; | |
} | |
function ethBalance() public view onlyOwner returns (uint256) { | |
return address(this).balance; | |
} | |
receive() external payable {} | |
event Received(address, uint); | |
event Withdraw(address, uint); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment