Verified contractPartialMIT
DontBetMe
Address0x8da54868b56b5eadcbc9b90348e46bbd89f4869b
- Balance
0 ETH
- Transactions
7
- Compiler
solc 0.8.19
- Same code
Only this contract
Details
- Compiler
- solc 0.8.19+commit.7dd6d404
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- paris
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 20,019,600
- Creation transaction
- 0x4880017fef…0da4ffc291
DontBetMe.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
/**
Name: DontBetMe
Ticker: DB
✅Telegram: https://t.me/Dont_bet
🕊Twitter: https://x.com/dontbetme
🌐Website: https://dont.bet/
**/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, 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 sender,
address recipient,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
library MerkleProof {
/**
*@dev The multiproof provided is not valid.
*/
error MerkleProofInvalidMultiproof();
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Calldata version of {verify}
*/
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Calldata version of {processProof}
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Calldata version of {multiProofVerify}
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofLen = proof.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
if (leavesLen + proofLen != totalHashes + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
if (proofPos != proofLen) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[totalHashes - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Calldata version of {processMultiProof}.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofLen = proof.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
if (leavesLen + proofLen != totalHashes + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
if (proofPos != proofLen) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[totalHashes - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Sorts the pair (a, b) and hashes the result.
*/
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
/**
* @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
*/
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
library SafeMath {
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
interface IUniswapV2Factory {
event PairCreated(
address indexed token0,
address indexed token1,
address pair,
uint256
);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB)
external
view
returns (address pair);
function allPairs(uint256) external view returns (address pair);
function allPairsLength() external view returns (uint256);
function createPair(address tokenA, address tokenB)
external
returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
interface IUniswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
contract DontBetMe is ERC20, Ownable {
using SafeMath for uint256;
uint256 public depositEndDate;
uint256 public subscription;
address[] public participants;
mapping(address => uint) public deposits;
mapping(address => bool) public automatedMarketMakerPairs;
mapping(address => bool) private _isExcludedFromFees;
mapping(bytes32 => bool) private claimedMap;
bytes32 public fairLaunchRoot;
bytes32 public referralRoot;
bytes32 public refundRoot;
uint public overEth;
uint public referralTokensClaimed;
uint public idoTokensClaimed;
uint public ethRefunded;
address public betSwapRouter;
bool public tradingOpen = false;
bool public claimOpen = false;
bool public claimReferralOpen = false;
uint256 _totalSupply = 1_000_000_000 * 1e18;
uint256 private _taxSwapThreshold = _totalSupply * 1 / 10000;
uint256 private _maxTaxSwap = _totalSupply * 1 / 1000;
bool public inSwap = false;
uint256 public cap = 200 ether;
uint256 public immutable timeout = 86400;
uint256 public immutable ticketPrice = 0.1 ether;
uint256 public immutable sellTax = 2;
uint256 public immutable buyTax = 2;
uint public immutable fairLaunchAllocation;
uint public immutable liquidityAllocation;
uint public immutable referralAllocation;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public immutable marketMaker;
event Deposited(
address indexed depositor,
uint amountETHdeposited,
uint totalSubscription
);
event ClaimedWithProof(uint256 _amount, address indexed _account);
event ClaimedReferralWithProof(uint256 _amount, address indexed _account);
event RefundWithProof(uint256 _amount, address indexed _account);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor(
address _uniswapRouter,
address _betSwapRouter,
address _marketMaker,
string memory _name,
string memory _symbol
) ERC20(_name, _symbol) {
uniswapV2Router = IUniswapV2Router02(_uniswapRouter);
betSwapRouter = _betSwapRouter;
marketMaker = _marketMaker;
uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory())
.createPair(address(this), uniswapV2Router.WETH());
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(marketMaker, true);
fairLaunchAllocation = (60 * _totalSupply) / 100;
liquidityAllocation = (30 * _totalSupply) / 100;
referralAllocation = (10 * _totalSupply) / 100;
super._mint(address(this), fairLaunchAllocation);
super._mint(address(this), referralAllocation);
super._mint(address(this), liquidityAllocation);
}
receive() external payable {}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
}
function isExcludedFromFees(address account) public view returns (bool) {
return _isExcludedFromFees[account];
}
function setBetSwapRouter(address _betSwapRouter) external onlyOwner {
betSwapRouter = _betSwapRouter;
}
function setFairLaunchRoot(bytes32 _root) external onlyOwner {
fairLaunchRoot = _root;
}
function setReferralRoot(bytes32 _root) external onlyOwner {
referralRoot = _root;
}
function setRefundRoot(bytes32 _root) external onlyOwner {
refundRoot = _root;
}
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
require(
pair != uniswapV2Pair,
"The pair cannot be removed from automatedMarketMakerPairs"
);
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
}
function deposit(uint256 tickets) external payable {
require(msg.sender == tx.origin, "Can not mint to contract.");
require(depositEndDate != 0, "fairLaunch not started.");
require(block.timestamp < depositEndDate, "fairLaunch ended.");
require(tickets > 0, "wrong tickets.");
require(ticketPrice * tickets == msg.value, "invalid value");
require(!tradingOpen, "trading is already open");
if (deposits[msg.sender] == 0) {
participants.push(msg.sender);
}
subscription += msg.value;
deposits[msg.sender] += msg.value;
emit Deposited(msg.sender, msg.value, subscription);
}
function getParticipants(uint start, uint length) external view returns (address[] memory addrs){
addrs = new address[](length);
for(uint i; i < length; i++){
addrs[i] = participants[start+i];
}
}
function getParticipants() external view returns (address[] memory addrs){
uint length = participants.length;
addrs = new address[](length);
for(uint i; i<length; i++){
addrs[i] = participants[i];
}
}
function fairLaunch() external onlyOwner {
require(depositEndDate == 0, "Already launched");
depositEndDate = block.timestamp + timeout;
}
function stopSale() external onlyOwner {
require(depositEndDate != 0, "Not launched yet");
depositEndDate = 0;
}
function toggleClaim() external onlyOwner {
claimOpen = !claimOpen;
}
function toggleClaimReferral() external onlyOwner {
claimReferralOpen = !claimReferralOpen;
}
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(amount > 0, "Transfer amount must be greater than zero");
uint256 taxAmount = 0;
if (automatedMarketMakerPairs[from] && !_isExcludedFromFees[to] && !_isExcludedFromFees[from]) {
taxAmount = amount.mul(buyTax).div(100);
}
if (automatedMarketMakerPairs[to] && !_isExcludedFromFees[to] && !_isExcludedFromFees[from]) {
taxAmount = amount.mul(sellTax).div(100);
}
if (taxAmount > 0) {
super._transfer(from, address(this), taxAmount);
amount -= taxAmount;
}
if (!_isExcludedFromFees[from] && !_isExcludedFromFees[to]) {
require(tradingOpen, "trading not open yet");
uint256 contractTokenBalance = balanceOf(address(this));
if (!automatedMarketMakerPairs[from] && !inSwap && contractTokenBalance > _taxSwapThreshold) {
swapTokensForEth(min(amount, min(contractTokenBalance, _maxTaxSwap)));
}
}
super._transfer(from, to, amount);
}
function min(uint256 a, uint256 b) internal pure returns (uint256){
return (a > b) ? b : a;
}
function reCap(uint256 _amount) external onlyOwner {
cap = _amount;
}
function claim(
uint256 _amount,
bytes32[] memory _merkleProof
) external {
require(claimOpen, "claim not open yet");
_treeClaim(_amount, fairLaunchRoot, _merkleProof);
}
function refund(
uint256 _amount,
bytes32[] memory _merkleProof
) external {
require(claimOpen, "refund not open yet");
_treeClaim(_amount, refundRoot, _merkleProof);
}
function claimReferral(
uint256 _amount,
bytes32[] memory _merkleProof
) external {
require(claimReferralOpen, "claim referral not open yet");
_treeClaim(_amount, referralRoot, _merkleProof);
}
function isClaimed(bytes32 _hash) public view returns (bool) {
return claimedMap[_hash];
}
function _treeClaim(
uint256 _amount,
bytes32 _root,
bytes32[] memory _merkleProof
) internal {
if (overEth == 0 && subscription > cap) {
overEth = subscription - cap;
}
uint rootId;
if (_root == referralRoot) {
require(
referralTokensClaimed + _amount <= referralAllocation,
"all referral allocation is claimed"
);
rootId = 1;
} else if (_root == fairLaunchRoot) {
require(
idoTokensClaimed + _amount <= fairLaunchAllocation,
"all fairLaunch allocation is claimed"
);
rootId = 2;
} else {
require(_root == refundRoot, "wrong root");
require(
ethRefunded + _amount <= overEth,
"all extra eth is refunded"
);
rootId = 3;
}
bytes32 leaf = keccak256(
abi.encodePacked(msg.sender, _amount, rootId)
);
require(!isClaimed(leaf), "already claimed with proof");
require(
MerkleProof.verify(_merkleProof, _root, leaf),
"invalid proof"
);
claimedMap[leaf] = true;
if (_root == refundRoot) {
payable(msg.sender).transfer(_amount);
ethRefunded += _amount;
emit RefundWithProof(_amount, msg.sender);
} else {
this.transfer(msg.sender, _amount);
if (_root == referralRoot) {
referralTokensClaimed += _amount;
emit ClaimedReferralWithProof(_amount, msg.sender);
} else {
idoTokensClaimed += _amount;
emit ClaimedWithProof(_amount, msg.sender);
}
}
}
function openTrading() external onlyOwner {
require(!tradingOpen, "trading is already open");
_approve(address(this), address(uniswapV2Router), type(uint256).max);
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
tradingOpen = true;
uint256 totalETH = min(subscription, cap);
uint256 liquidityEth = totalETH * 20 / 100;
uint256 initialBoostEth = totalETH * 20 / 100;
uint256 marketMakerEth = totalETH * 10 / 100;
uint256 betEth = totalETH * 50 / 100;
sendETHToFee(betEth, betSwapRouter);
sendETHToFee(marketMakerEth, marketMaker);
uniswapV2Router.addLiquidityETH{value : liquidityEth}(address(this), liquidityAllocation, 0, 0, owner(), block.timestamp);
swapEthForTokens(initialBoostEth);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
betSwapRouter,
block.timestamp
);
}
function swapEthForTokens(uint256 ethAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = uniswapV2Router.WETH();
path[1] = address(this);
uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value : ethAmount}(
0,
path,
marketMaker,
block.timestamp
);
}
function manualSwap() external onlyOwner {
uint256 tokenBalance = balanceOf(address(this));
if (tokenBalance > 0) {
swapTokensForEth(tokenBalance);
}
uint256 ethBalance = address(this).balance;
if (ethBalance > 0) {
sendETHToFee(ethBalance, owner());
}
}
function sendETHToFee(uint256 amount, address beneficial) private {
payable(beneficial).transfer(amount);
}
function getStuckTokens(address tkn) external onlyOwner {
if (tkn == address(0)) {
bool success;
(success, ) = address(msg.sender).call{value: address(this).balance}(
""
);
} else {
require(IERC20(tkn).balanceOf(address(this)) > 0, "No tokens");
uint256 amount = IERC20(tkn).balanceOf(address(this));
IERC20(tkn).transfer(msg.sender, amount);
}
}
}Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "paris",
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.