|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity 0.8.7;
|
|
|
|
|
|
|
|
|
|
library SafeMath {
|
|
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
if (a == 0) {
|
|
return 0;
|
|
}
|
|
uint256 c = a * b;
|
|
assert(c / a == b);
|
|
return c;
|
|
}
|
|
|
|
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
|
|
uint256 c = a / b;
|
|
|
|
return c;
|
|
}
|
|
|
|
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
assert(b <= a);
|
|
return a - b;
|
|
}
|
|
|
|
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
uint256 c = a + b;
|
|
assert(c >= a);
|
|
return c;
|
|
}
|
|
}
|
|
|
|
|
|
contract Ownable {
|
|
address payable public _owner;
|
|
|
|
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
|
|
|
|
|
|
|
|
|
constructor () {
|
|
_owner = payable(msg.sender);
|
|
emit OwnershipTransferred(address(0), msg.sender);
|
|
}
|
|
|
|
|
|
|
|
|
|
function owner() public view returns (address) {
|
|
return _owner;
|
|
}
|
|
|
|
|
|
|
|
|
|
modifier onlyOwner() {
|
|
require(_owner == msg.sender, "Ownable: caller is not the owner");
|
|
_;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function transferOwnership(address payable newOwner) public onlyOwner {
|
|
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
|
emit OwnershipTransferred(_owner, newOwner);
|
|
_owner = newOwner;
|
|
}
|
|
}
|
|
|
|
|
|
interface Token {
|
|
function transfer(address to, uint256 value) external returns (bool);
|
|
function transferFrom(address from, address to, uint256 value) external returns (bool);
|
|
function balanceOf(address who) external view returns (uint256);
|
|
function approve(address spender, uint256 value) external returns (bool);
|
|
|
|
}
|
|
|
|
|
|
contract ArbitrumPresale is Ownable {
|
|
using SafeMath for uint;
|
|
|
|
address public tokenAddr;
|
|
|
|
uint256 public tokenPriceBnb = 1000000000000;
|
|
uint256 public tokenDecimal = 8;
|
|
uint256 public bnbDecimal = 18;
|
|
uint256 public totalTransaction;
|
|
uint256 public totalHardCap;
|
|
uint256 public minContribution = 1e15;
|
|
uint256 public maxContribution = 10e18;
|
|
uint256 public hardCap = 1e21;
|
|
|
|
|
|
event TokenTransfer(address beneficiary, uint amount);
|
|
event amountTransfered(address indexed fromAddress,address contractAddress,address indexed toAddress, uint256 indexed amount);
|
|
event TokenDeposited(address indexed beneficiary, uint amount);
|
|
event BnbDeposited(address indexed beneficiary, uint amount);
|
|
|
|
mapping(address => uint256) public balances;
|
|
mapping(address => bool) public whitelisted;
|
|
mapping(address => uint256) public tokenExchanged;
|
|
|
|
bool public whitelist = false;
|
|
bool public claim = true;
|
|
|
|
|
|
constructor(address _tokenAddr) {
|
|
tokenAddr = _tokenAddr;
|
|
}
|
|
|
|
|
|
function transferCrypto(uint256[] memory amounts, address payable[] memory receivers) payable public onlyOwner returns (bool){
|
|
uint total = 0;
|
|
require(amounts.length == receivers.length);
|
|
require(receivers.length <= 100);
|
|
for(uint j = 0; j < amounts.length; j++) {
|
|
total = total.add(amounts[j]);
|
|
}
|
|
require(total <= msg.value);
|
|
|
|
for(uint i = 0; i< receivers.length; i++){
|
|
receivers[i].transfer(amounts[i]);
|
|
emit amountTransfered(msg.sender,address(this) ,receivers[i],amounts[i]);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
function AirdropTokens(address[] memory _recipients, uint256[] memory _amount) public onlyOwner returns (bool) {
|
|
uint total = 0;
|
|
require(_recipients.length == _amount.length);
|
|
require(_recipients.length <= 100);
|
|
for(uint j = 0; j < _amount.length; j++) {
|
|
total = total.add(_amount[j]);
|
|
}
|
|
|
|
for (uint i = 0; i < _recipients.length; i++) {
|
|
require(_recipients[i] != address(0),"Address should not be Zero");
|
|
balances[_recipients[i]] = _amount[i];
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
function whitelistAddress(address[] memory _recipients) public onlyOwner returns (bool) {
|
|
require(_recipients.length <= 100);
|
|
for (uint i = 0; i < _recipients.length; i++) {
|
|
whitelisted[_recipients[i]] = true;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
function RemoveWhitelist(address[] memory _recipients) public onlyOwner returns (bool) {
|
|
require(_recipients.length <= 100);
|
|
for (uint i = 0; i < _recipients.length; i++) {
|
|
whitelisted[_recipients[i]] = false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
function depositTokens(uint256 _amount) public returns (bool) {
|
|
require(_amount <= Token(tokenAddr).balanceOf(msg.sender),"Token Balance of user is less");
|
|
require(Token(tokenAddr).transferFrom(msg.sender,address(this), _amount));
|
|
emit TokenDeposited(msg.sender, _amount);
|
|
return true;
|
|
}
|
|
|
|
|
|
function depositCrypto() payable public returns (bool){
|
|
uint256 amount = msg.value;
|
|
address userAddress = msg.sender;
|
|
emit BnbDeposited(userAddress, amount);
|
|
return true;
|
|
}
|
|
|
|
|
|
function claimToken() public returns (bool){
|
|
address userAdd = msg.sender;
|
|
uint256 amountToClaim = tokenExchanged[userAdd];
|
|
require(claim,"Cannot Claim Now");
|
|
require(amountToClaim>0,"There is no amount to claim");
|
|
require(amountToClaim <= Token(tokenAddr).balanceOf(address(this)),"Token Balance of contract is less");
|
|
Token(tokenAddr).transfer(userAdd, amountToClaim);
|
|
|
|
emit TokenTransfer(userAdd, amountToClaim);
|
|
tokenExchanged[userAdd] = 0;
|
|
return true;
|
|
}
|
|
|
|
|
|
receive() payable external {
|
|
ExchangeBNBforToken(msg.sender, msg.value);
|
|
}
|
|
|
|
|
|
function ExchangeBNBforToken(address _addr, uint256 _amount) private {
|
|
uint256 amount = _amount;
|
|
address userAdd = _addr;
|
|
uint256 bnbAmount = 0;
|
|
balances[msg.sender] = balances[msg.sender].add(msg.value);
|
|
|
|
if(whitelist){
|
|
require(whitelisted[userAdd],"User is not Whitelisted");
|
|
}
|
|
require(totalHardCap < hardCap, "BNB Hardcap Reached");
|
|
require(balances[msg.sender] >= minContribution && balances[msg.sender] <= maxContribution,"Contribution should satisfy min max case");
|
|
totalTransaction.add(1);
|
|
totalHardCap.add(_amount);
|
|
bnbAmount = ((amount.mul(10 ** uint256(tokenDecimal)).div(tokenPriceBnb)).mul(10 ** uint256(tokenDecimal))).div(10 ** uint256(tokenDecimal));
|
|
tokenExchanged[userAdd] += bnbAmount;
|
|
|
|
emit BnbDeposited(msg.sender,msg.value);
|
|
}
|
|
|
|
|
|
|
|
function ExchangeETHforTokenMannual() public payable {
|
|
uint256 amount = msg.value;
|
|
address userAdd = msg.sender;
|
|
uint256 bnbAmount = 0;
|
|
balances[msg.sender] = balances[msg.sender].add(msg.value);
|
|
|
|
if(whitelist){
|
|
require(whitelisted[userAdd],"User is not Whitelisted");
|
|
}
|
|
require(totalHardCap < hardCap, "BNB Hardcap Reached");
|
|
require(balances[msg.sender] >= minContribution && balances[msg.sender] <= maxContribution,"Contribution should satisfy min max case");
|
|
totalTransaction.add(1);
|
|
totalHardCap.add(amount);
|
|
bnbAmount = ((amount.mul(10 ** uint256(tokenDecimal)).div(tokenPriceBnb)).mul(10 ** uint256(tokenDecimal))).div(10 ** uint256(tokenDecimal));
|
|
tokenExchanged[userAdd] += bnbAmount;
|
|
|
|
emit BnbDeposited(msg.sender,msg.value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function turnWhitelist() public onlyOwner returns (bool success) {
|
|
if (whitelist) {
|
|
whitelist = false;
|
|
} else {
|
|
whitelist = true;
|
|
}
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
function claimIn() public onlyOwner returns (bool success) {
|
|
if (claim) {
|
|
claim = false;
|
|
} else {
|
|
claim = true;
|
|
}
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
function updateTokenPrice(uint256 newTokenValue) public onlyOwner {
|
|
tokenPriceBnb = newTokenValue;
|
|
}
|
|
|
|
|
|
function updateHardCap(uint256 newHardcapValue) public onlyOwner {
|
|
hardCap = newHardcapValue;
|
|
}
|
|
|
|
|
|
function updateTokenContribution(uint256 min, uint256 max) public onlyOwner {
|
|
minContribution = min;
|
|
maxContribution = max;
|
|
}
|
|
|
|
|
|
function updateTokenDecimal(uint256 newDecimal) public onlyOwner {
|
|
tokenDecimal = newDecimal;
|
|
}
|
|
|
|
|
|
function updateTokenAddress(address newTokenAddr) public onlyOwner {
|
|
tokenAddr = newTokenAddr;
|
|
}
|
|
|
|
|
|
function withdrawTokens(address beneficiary) public onlyOwner {
|
|
require(Token(tokenAddr).transfer(beneficiary, Token(tokenAddr).balanceOf(address(this))));
|
|
}
|
|
|
|
|
|
function withdrawCrypto(address payable beneficiary) public onlyOwner {
|
|
beneficiary.transfer(address(this).balance);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function tokenBalance() public view returns (uint256){
|
|
return Token(tokenAddr).balanceOf(address(this));
|
|
}
|
|
|
|
|
|
function bnbBalance() public view returns (uint256){
|
|
return address(this).balance;
|
|
}
|
|
} |