Token 10X: Africa's First Cryptocurrency Hub
MARVIN ROCKET Token
%uD83D%uDE80 Marvin is going to Mars on his Rocket! %uD83D%uDE80
Marvin Rocket is a continuously growing community built upon respect, kindness, and charity.
DOUBLE REWARDS // AUDIT %uD83D%uDD10
HUGE MARKETING PRE / POST LAUNCH %uD83D%uDCCA
FAIR LAUNCH // PINKSALE %u2B50%...
About MARVIN ROCKET
%uD83D%uDE80 Marvin is going to Mars on his Rocket! %uD83D%uDE80
Marvin Rocket is a continuously growing community built upon respect, kindness, and charity.
DOUBLE REWARDS // AUDIT %uD83D%uDD10
HUGE MARKETING PRE / POST LAUNCH %uD83D%uDCCA
FAIR LAUNCH // PINKSALE %u2B50%uFE0F
%u2705 PRE SALE FAIR LAUNCH // 29th April - 2nd May
%u2705 LAUNCH // 2nd - 3rd May
TOKENOMICS
SUPPLY 10MIL
63% FAIRLAUNCH
28% LOCKED FOR STAKING OPENING
9% UNLOCKED FOR NFTS PURPOSE
Marvin Rocket is a continuously growing community built upon respect, kindness, and charity.
DOUBLE REWARDS // AUDIT %uD83D%uDD10
HUGE MARKETING PRE / POST LAUNCH %uD83D%uDCCA
FAIR LAUNCH // PINKSALE %u2B50%uFE0F
%u2705 PRE SALE FAIR LAUNCH // 29th April - 2nd May
%u2705 LAUNCH // 2nd - 3rd May
TOKENOMICS
SUPPLY 10MIL
63% FAIRLAUNCH
28% LOCKED FOR STAKING OPENING
9% UNLOCKED FOR NFTS PURPOSE
102 total visits
Token information and links
Circulating Supply
10000000000000000000000000
Token Contract (BSC Chain)
0X678D1187BC37928B0D1F4EE37FB4F5D90CA9B312
Contract license: MIT
Launch Date
In 7 Days
KYC Information
No
Audit Information
None
Team Information
Team leader: None
Team leader contact: None
Contract source code
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
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(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
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);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
interface IPinkAntiBot {
function setTokenOwner(address owner) external;
function onPreTransferCheck(
address from,
address to,
uint256 amount
) external;
}
contract MarvinToken is Ownable, IERC20, ReentrancyGuard {
string private _name = "Marvin Rocket";
string private _symbol = "MARVINR";
uint256 private _totalSupply;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 public buyMarketingFeeBPS = 300;
uint256 public buyDevFeeBPS = 300;
uint256 public buyRewardFeeBPS = 300;
uint256 public buyTotalFeeBPS = 900;
uint256 public buyMaxTotalFeeBPS = 1500;
uint256 public sellMarketingFeeBPS = 400;
uint256 public sellDevFeeBPS = 400;
uint256 public sellRewardFeeBPS = 400;
uint256 public sellTotalFeeBPS = 1200;
uint256 public sellMaxTotalFeeBPS = 1500;
address public marketingWallet;
address public devWallet;
uint256 public swapTokensAtAmount = 100 * (10**18);
uint256 public lastSwapTime;
uint256 public swapNativeMinimum = 500000000000000;
uint256 public swapNativeMaximum;
// reward tracking config
uint256 constant private magnitude = 2**128;
uint256 public minimumBalanceForRewards = 25 * (10**18);
uint256 public magnifiedRewardPerShare;
uint256 public totalRewardsDistributed;
uint256 public totalRewardsWithdrawn;
uint256 private _totalRewardHoldingSupply;
mapping (address => bool) private _isExcludedFromRewards;
mapping (address => int256) private magnifiedRewardCorrections;
mapping (address => uint256) private _rewardHoldingBalance;
mapping (address => uint256) private rewardsWithdrawn;
mapping (address => uint256) private lastClaimTimes;
bool private swapping;
bool public swapEnabled = true;
bool public taxEnabled = true;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
IPinkAntiBot public pinkAntiBot;
bool public antiBotEnabled;
mapping(address => bool) private _isExcludedFromFees;
constructor() {
// setup the DEX
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E);
address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = _uniswapV2Pair;
// exclude special addresses from reward earnings
excludeFromRewards(owner(), true);
excludeFromRewards(address(this), true);
excludeFromRewards(address(uniswapV2Router), true);
excludeFromRewards(address(uniswapV2Pair), true);
// exclude special addresses from fees
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
// mint our initial supply
_mint(owner(), 10000000 * (10**18));
// setup the pink antibot
pinkAntiBot = IPinkAntiBot(0x8EFDb3b642eb2a20607ffe0A56CFefF6a95Df002);
pinkAntiBot.setTokenOwner(msg.sender);
antiBotEnabled = true;
}
receive() external payable {
}
function setDevWallet(address _address) public onlyOwner {
devWallet = _address;
}
function setMarketingWallet(address _address) public onlyOwner {
marketingWallet = _address;
}
function setSwapEnabled(bool _enabled) external onlyOwner {
swapEnabled = _enabled;
}
function setTaxEnabled(bool _enabled) external onlyOwner {
taxEnabled = _enabled;
}
function setAntiBotEnabled(bool _enabled) external onlyOwner {
antiBotEnabled = _enabled;
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
}
function isExcludedFromFees(address account) public view returns (bool) {
return _isExcludedFromFees[account];
}
function setBuyMarketingFeeBPS(uint256 bps) public onlyOwner {
require(buyTotalFeeBPS - buyMarketingFeeBPS bps <= buyMaxTotalFeeBPS, "Total buy fee BPS is too high");
buyTotalFeeBPS -= buyMarketingFeeBPS;
buyMarketingFeeBPS = bps;
buyTotalFeeBPS = buyMarketingFeeBPS;
}
function setBuyDevFeeBPS(uint256 bps) public onlyOwner {
require(buyTotalFeeBPS - buyDevFeeBPS bps <= buyMaxTotalFeeBPS, "Total buy fee BPS is too high");
buyTotalFeeBPS -= buyDevFeeBPS;
buyDevFeeBPS = bps;
buyTotalFeeBPS = buyDevFeeBPS;
}
function setBuyRewardFeeBPS(uint256 bps) public onlyOwner {
require(buyTotalFeeBPS - buyRewardFeeBPS bps <= buyMaxTotalFeeBPS, "Total buy fee BPS is too high");
buyTotalFeeBPS -= buyRewardFeeBPS;
buyRewardFeeBPS = bps;
buyTotalFeeBPS = buyRewardFeeBPS;
}
function setSellMarketingFeeBPS(uint256 bps) public onlyOwner {
require(sellTotalFeeBPS - sellMarketingFeeBPS bps <= sellMaxTotalFeeBPS, "Total sell fee BPS is too high");
sellTotalFeeBPS -= sellMarketingFeeBPS;
sellMarketingFeeBPS = bps;
sellTotalFeeBPS = sellMarketingFeeBPS;
}
function setSellDevFeeBPS(uint256 bps) public onlyOwner {
require(sellTotalFeeBPS - sellDevFeeBPS bps <= sellMaxTotalFeeBPS, "Total sell fee BPS is too high");
sellTotalFeeBPS -= sellDevFeeBPS;
sellDevFeeBPS = bps;
sellTotalFeeBPS = sellDevFeeBPS;
}
function setSellRewardFeeBPS(uint256 bps) public onlyOwner {
require(sellTotalFeeBPS - sellRewardFeeBPS bps <= sellMaxTotalFeeBPS, "Total sell fee BPS is too high");
sellTotalFeeBPS -= sellRewardFeeBPS;
sellRewardFeeBPS = bps;
sellTotalFeeBPS = sellRewardFeeBPS;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public pure 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 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 increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "MARVINR: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, 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, "MARVINR: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "MARVINR: transfer from the zero address");
require(recipient != address(0), "MARVINR: transfer to the zero address");
if(antiBotEnabled) {
pinkAntiBot.onPreTransferCheck(sender, recipient, amount);
}
require(_balances[sender] >= amount, "MARVINR: transfer amount exceeds balance");
// handle our swapping logic
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if(swapEnabled &&
canSwap &&
!swapping &&
sender != address(uniswapV2Pair) && // no swap on remove liquidity step 1 or DEX buy
sender != address(uniswapV2Router) && // no swap on remove liquidity step 2
sender != owner() &&
recipient != owner()
) {
swapping = true;
_executeSwap(contractTokenBalance);
lastSwapTime = block.timestamp;
swapping = false;
}
bool takeFee;
if(sender == address(uniswapV2Pair) || recipient == address(uniswapV2Pair)) {
takeFee = true;
}
if(_isExcludedFromFees[sender] || _isExcludedFromFees[recipient]) {
takeFee = false;
}
if(swapping || !taxEnabled) {
takeFee = false;
}
if(takeFee) {
uint256 fees;
// DEX BUY
if(sender == address(uniswapV2Pair) && recipient != address(uniswapV2Router)) {
fees = amount * buyTotalFeeBPS / 10000;
}
// DEX SELL or ADD LIQUIDITY
if(recipient == address(uniswapV2Pair)) {
fees = amount * sellTotalFeeBPS / 10000;
}
if(fees > 0) {
amount -= fees;
_executeTransfer(sender, address(this), fees);
}
}
_executeTransfer(sender, recipient, amount);
setRewardHoldingBalance(sender, balanceOf(sender));
setRewardHoldingBalance(recipient, balanceOf(recipient));
}
function _executeTransfer(address sender, address recipient, uint256 amount) private {
require(sender != address(0), "MARVINR: transfer from the zero address");
require(recipient != address(0), "MARVINR: transfer to the zero address");
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "MARVINR: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] = amount;
emit Transfer(sender, recipient, amount);
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "MARVINR: approve from the zero address");
require(spender != address(0), "MARVINR: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _mint(address account, uint256 amount) private {
require(account != address(0), "MARVINR: mint to the zero address");
_totalSupply = amount;
_balances[account] = amount;
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) private {
require(account != address(0), "MARVINR: burn from the zero address");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "MARVINR: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function _executeSwap(uint256 tokens) private {
if(tokens <= 0) {
return;
}
// calculate our overall fee split
uint256 devFeeBPS;
uint256 marketingFeeBPS;
uint256 rewardFeeBPS;
uint256 totalFeeBPS;
rewardFeeBPS = buyRewardFeeBPS sellRewardFeeBPS;
totalFeeBPS = totalFeeBPS rewardFeeBPS;
if(address(devWallet) != address(0)) {
devFeeBPS = buyDevFeeBPS sellDevFeeBPS;
totalFeeBPS = totalFeeBPS devFeeBPS;
}
if(address(marketingWallet) != address(0)) {
marketingFeeBPS = buyMarketingFeeBPS sellMarketingFeeBPS;
totalFeeBPS = totalFeeBPS marketingFeeBPS;
}
swapTokensForNative(tokens);
//uint256 nativeBalance = address(this).balance;
uint256 unclaimedRewards = totalRewardsDistributed - totalRewardsWithdrawn;
uint256 nativeBalance = address(this).balance - unclaimedRewards;
if(nativeBalance == 0 || nativeBalance < swapNativeMinimum) {
return;
}
if(swapNativeMaximum > 0 && nativeBalance > swapNativeMaximum) {
nativeBalance = swapNativeMaximum;
}
// calculate native BNB amounts
uint256 nativeDev = nativeBalance * devFeeBPS / totalFeeBPS;
uint256 nativeMarketing = nativeBalance * marketingFeeBPS / totalFeeBPS;
uint256 nativeReward = nativeBalance - nativeDev - nativeMarketing;
if(nativeDev > 0) {
payable(devWallet).transfer(nativeDev);
}
if(nativeMarketing > 0) {
payable(marketingWallet).transfer(nativeMarketing);
}
if(nativeReward > 0) {
distributeRewards(nativeReward);
}
}
function swapTokensForNative(uint256 tokens) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokens);
try uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokens,
0, // accept any amount of native
path,
address(this),
block.timestamp
) {
// success
} catch Error(string memory /*err*/) {
// failure
}
}
function setRewardHoldingBalance(address account, uint256 balance) private {
if(_isExcludedFromRewards[account]) {
return;
}
if(balance >= minimumBalanceForRewards) {
_setRewardHoldingBalance(account, balance);
} else {
_setRewardHoldingBalance(account, 0);
}
}
function _setRewardHoldingBalance(address account, uint256 balance) private {
require(account != address(0));
uint256 currentBalance = _rewardHoldingBalance[account];
if(balance > currentBalance) {
uint256 addAmount = balance - currentBalance;
_totalRewardHoldingSupply = addAmount;
_rewardHoldingBalance[account] = addAmount;
magnifiedRewardCorrections[account] = magnifiedRewardCorrections[account]
- int256(magnifiedRewardPerShare * addAmount);
} else {
uint256 subAmount = currentBalance - balance;
require(currentBalance >= subAmount);
_totalRewardHoldingSupply -= subAmount;
_rewardHoldingBalance[account] -= subAmount;
magnifiedRewardCorrections[account] = magnifiedRewardCorrections[account]
int256(magnifiedRewardPerShare * subAmount);
}
}
function distributeRewards(uint256 amount) private {
if(amount > 0 && _totalRewardHoldingSupply > 0) {
magnifiedRewardPerShare = magnifiedRewardPerShare
((amount * magnitude) / _totalRewardHoldingSupply);
totalRewardsDistributed = amount;
}
}
function excludeFromRewards(address account, bool excluded) public onlyOwner {
_isExcludedFromRewards[account] = excluded;
if(excluded) {
_setRewardHoldingBalance(account, 0);
} else {
setRewardHoldingBalance(account, balanceOf(account));
}
}
function isExcludedFromRewards(address account) public view returns (bool) {
return _isExcludedFromRewards[account];
}
function accumulativeRewards(address account) public view returns (uint256) {
int256 a = int256(magnifiedRewardPerShare * _rewardHoldingBalance[account]);
int256 b = magnifiedRewardCorrections[account];
return uint256(a b) / magnitude;
}
function withdrawableRewards(address account) public view returns (uint256) {
return accumulativeRewards(account) - rewardsWithdrawn[account];
}
function withdrawnRewards(address account) public view returns (uint256) {
return rewardsWithdrawn[account];
}
function getRewardInfo(address account) public view returns (uint256, uint256, uint256) {
return (
withdrawableRewards(account),
withdrawnRewards(account),
lastClaimTimes[account]
);
}
function claimRewards() public nonReentrant {
address account = _msgSender();
uint256 amount = withdrawableRewards(account);
if(amount > 0) {
rewardsWithdrawn[account] = amount;
totalRewardsWithdrawn = amount;
payable(account).transfer(amount);
lastClaimTimes[account] = block.timestamp;
}
}
}
pragma solidity ^0.8.9;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
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(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
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);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
interface IPinkAntiBot {
function setTokenOwner(address owner) external;
function onPreTransferCheck(
address from,
address to,
uint256 amount
) external;
}
contract MarvinToken is Ownable, IERC20, ReentrancyGuard {
string private _name = "Marvin Rocket";
string private _symbol = "MARVINR";
uint256 private _totalSupply;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 public buyMarketingFeeBPS = 300;
uint256 public buyDevFeeBPS = 300;
uint256 public buyRewardFeeBPS = 300;
uint256 public buyTotalFeeBPS = 900;
uint256 public buyMaxTotalFeeBPS = 1500;
uint256 public sellMarketingFeeBPS = 400;
uint256 public sellDevFeeBPS = 400;
uint256 public sellRewardFeeBPS = 400;
uint256 public sellTotalFeeBPS = 1200;
uint256 public sellMaxTotalFeeBPS = 1500;
address public marketingWallet;
address public devWallet;
uint256 public swapTokensAtAmount = 100 * (10**18);
uint256 public lastSwapTime;
uint256 public swapNativeMinimum = 500000000000000;
uint256 public swapNativeMaximum;
// reward tracking config
uint256 constant private magnitude = 2**128;
uint256 public minimumBalanceForRewards = 25 * (10**18);
uint256 public magnifiedRewardPerShare;
uint256 public totalRewardsDistributed;
uint256 public totalRewardsWithdrawn;
uint256 private _totalRewardHoldingSupply;
mapping (address => bool) private _isExcludedFromRewards;
mapping (address => int256) private magnifiedRewardCorrections;
mapping (address => uint256) private _rewardHoldingBalance;
mapping (address => uint256) private rewardsWithdrawn;
mapping (address => uint256) private lastClaimTimes;
bool private swapping;
bool public swapEnabled = true;
bool public taxEnabled = true;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
IPinkAntiBot public pinkAntiBot;
bool public antiBotEnabled;
mapping(address => bool) private _isExcludedFromFees;
constructor() {
// setup the DEX
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E);
address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = _uniswapV2Pair;
// exclude special addresses from reward earnings
excludeFromRewards(owner(), true);
excludeFromRewards(address(this), true);
excludeFromRewards(address(uniswapV2Router), true);
excludeFromRewards(address(uniswapV2Pair), true);
// exclude special addresses from fees
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
// mint our initial supply
_mint(owner(), 10000000 * (10**18));
// setup the pink antibot
pinkAntiBot = IPinkAntiBot(0x8EFDb3b642eb2a20607ffe0A56CFefF6a95Df002);
pinkAntiBot.setTokenOwner(msg.sender);
antiBotEnabled = true;
}
receive() external payable {
}
function setDevWallet(address _address) public onlyOwner {
devWallet = _address;
}
function setMarketingWallet(address _address) public onlyOwner {
marketingWallet = _address;
}
function setSwapEnabled(bool _enabled) external onlyOwner {
swapEnabled = _enabled;
}
function setTaxEnabled(bool _enabled) external onlyOwner {
taxEnabled = _enabled;
}
function setAntiBotEnabled(bool _enabled) external onlyOwner {
antiBotEnabled = _enabled;
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
}
function isExcludedFromFees(address account) public view returns (bool) {
return _isExcludedFromFees[account];
}
function setBuyMarketingFeeBPS(uint256 bps) public onlyOwner {
require(buyTotalFeeBPS - buyMarketingFeeBPS bps <= buyMaxTotalFeeBPS, "Total buy fee BPS is too high");
buyTotalFeeBPS -= buyMarketingFeeBPS;
buyMarketingFeeBPS = bps;
buyTotalFeeBPS = buyMarketingFeeBPS;
}
function setBuyDevFeeBPS(uint256 bps) public onlyOwner {
require(buyTotalFeeBPS - buyDevFeeBPS bps <= buyMaxTotalFeeBPS, "Total buy fee BPS is too high");
buyTotalFeeBPS -= buyDevFeeBPS;
buyDevFeeBPS = bps;
buyTotalFeeBPS = buyDevFeeBPS;
}
function setBuyRewardFeeBPS(uint256 bps) public onlyOwner {
require(buyTotalFeeBPS - buyRewardFeeBPS bps <= buyMaxTotalFeeBPS, "Total buy fee BPS is too high");
buyTotalFeeBPS -= buyRewardFeeBPS;
buyRewardFeeBPS = bps;
buyTotalFeeBPS = buyRewardFeeBPS;
}
function setSellMarketingFeeBPS(uint256 bps) public onlyOwner {
require(sellTotalFeeBPS - sellMarketingFeeBPS bps <= sellMaxTotalFeeBPS, "Total sell fee BPS is too high");
sellTotalFeeBPS -= sellMarketingFeeBPS;
sellMarketingFeeBPS = bps;
sellTotalFeeBPS = sellMarketingFeeBPS;
}
function setSellDevFeeBPS(uint256 bps) public onlyOwner {
require(sellTotalFeeBPS - sellDevFeeBPS bps <= sellMaxTotalFeeBPS, "Total sell fee BPS is too high");
sellTotalFeeBPS -= sellDevFeeBPS;
sellDevFeeBPS = bps;
sellTotalFeeBPS = sellDevFeeBPS;
}
function setSellRewardFeeBPS(uint256 bps) public onlyOwner {
require(sellTotalFeeBPS - sellRewardFeeBPS bps <= sellMaxTotalFeeBPS, "Total sell fee BPS is too high");
sellTotalFeeBPS -= sellRewardFeeBPS;
sellRewardFeeBPS = bps;
sellTotalFeeBPS = sellRewardFeeBPS;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public pure 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 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 increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "MARVINR: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, 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, "MARVINR: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "MARVINR: transfer from the zero address");
require(recipient != address(0), "MARVINR: transfer to the zero address");
if(antiBotEnabled) {
pinkAntiBot.onPreTransferCheck(sender, recipient, amount);
}
require(_balances[sender] >= amount, "MARVINR: transfer amount exceeds balance");
// handle our swapping logic
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if(swapEnabled &&
canSwap &&
!swapping &&
sender != address(uniswapV2Pair) && // no swap on remove liquidity step 1 or DEX buy
sender != address(uniswapV2Router) && // no swap on remove liquidity step 2
sender != owner() &&
recipient != owner()
) {
swapping = true;
_executeSwap(contractTokenBalance);
lastSwapTime = block.timestamp;
swapping = false;
}
bool takeFee;
if(sender == address(uniswapV2Pair) || recipient == address(uniswapV2Pair)) {
takeFee = true;
}
if(_isExcludedFromFees[sender] || _isExcludedFromFees[recipient]) {
takeFee = false;
}
if(swapping || !taxEnabled) {
takeFee = false;
}
if(takeFee) {
uint256 fees;
// DEX BUY
if(sender == address(uniswapV2Pair) && recipient != address(uniswapV2Router)) {
fees = amount * buyTotalFeeBPS / 10000;
}
// DEX SELL or ADD LIQUIDITY
if(recipient == address(uniswapV2Pair)) {
fees = amount * sellTotalFeeBPS / 10000;
}
if(fees > 0) {
amount -= fees;
_executeTransfer(sender, address(this), fees);
}
}
_executeTransfer(sender, recipient, amount);
setRewardHoldingBalance(sender, balanceOf(sender));
setRewardHoldingBalance(recipient, balanceOf(recipient));
}
function _executeTransfer(address sender, address recipient, uint256 amount) private {
require(sender != address(0), "MARVINR: transfer from the zero address");
require(recipient != address(0), "MARVINR: transfer to the zero address");
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "MARVINR: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] = amount;
emit Transfer(sender, recipient, amount);
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "MARVINR: approve from the zero address");
require(spender != address(0), "MARVINR: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _mint(address account, uint256 amount) private {
require(account != address(0), "MARVINR: mint to the zero address");
_totalSupply = amount;
_balances[account] = amount;
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) private {
require(account != address(0), "MARVINR: burn from the zero address");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "MARVINR: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function _executeSwap(uint256 tokens) private {
if(tokens <= 0) {
return;
}
// calculate our overall fee split
uint256 devFeeBPS;
uint256 marketingFeeBPS;
uint256 rewardFeeBPS;
uint256 totalFeeBPS;
rewardFeeBPS = buyRewardFeeBPS sellRewardFeeBPS;
totalFeeBPS = totalFeeBPS rewardFeeBPS;
if(address(devWallet) != address(0)) {
devFeeBPS = buyDevFeeBPS sellDevFeeBPS;
totalFeeBPS = totalFeeBPS devFeeBPS;
}
if(address(marketingWallet) != address(0)) {
marketingFeeBPS = buyMarketingFeeBPS sellMarketingFeeBPS;
totalFeeBPS = totalFeeBPS marketingFeeBPS;
}
swapTokensForNative(tokens);
//uint256 nativeBalance = address(this).balance;
uint256 unclaimedRewards = totalRewardsDistributed - totalRewardsWithdrawn;
uint256 nativeBalance = address(this).balance - unclaimedRewards;
if(nativeBalance == 0 || nativeBalance < swapNativeMinimum) {
return;
}
if(swapNativeMaximum > 0 && nativeBalance > swapNativeMaximum) {
nativeBalance = swapNativeMaximum;
}
// calculate native BNB amounts
uint256 nativeDev = nativeBalance * devFeeBPS / totalFeeBPS;
uint256 nativeMarketing = nativeBalance * marketingFeeBPS / totalFeeBPS;
uint256 nativeReward = nativeBalance - nativeDev - nativeMarketing;
if(nativeDev > 0) {
payable(devWallet).transfer(nativeDev);
}
if(nativeMarketing > 0) {
payable(marketingWallet).transfer(nativeMarketing);
}
if(nativeReward > 0) {
distributeRewards(nativeReward);
}
}
function swapTokensForNative(uint256 tokens) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokens);
try uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokens,
0, // accept any amount of native
path,
address(this),
block.timestamp
) {
// success
} catch Error(string memory /*err*/) {
// failure
}
}
function setRewardHoldingBalance(address account, uint256 balance) private {
if(_isExcludedFromRewards[account]) {
return;
}
if(balance >= minimumBalanceForRewards) {
_setRewardHoldingBalance(account, balance);
} else {
_setRewardHoldingBalance(account, 0);
}
}
function _setRewardHoldingBalance(address account, uint256 balance) private {
require(account != address(0));
uint256 currentBalance = _rewardHoldingBalance[account];
if(balance > currentBalance) {
uint256 addAmount = balance - currentBalance;
_totalRewardHoldingSupply = addAmount;
_rewardHoldingBalance[account] = addAmount;
magnifiedRewardCorrections[account] = magnifiedRewardCorrections[account]
- int256(magnifiedRewardPerShare * addAmount);
} else {
uint256 subAmount = currentBalance - balance;
require(currentBalance >= subAmount);
_totalRewardHoldingSupply -= subAmount;
_rewardHoldingBalance[account] -= subAmount;
magnifiedRewardCorrections[account] = magnifiedRewardCorrections[account]
int256(magnifiedRewardPerShare * subAmount);
}
}
function distributeRewards(uint256 amount) private {
if(amount > 0 && _totalRewardHoldingSupply > 0) {
magnifiedRewardPerShare = magnifiedRewardPerShare
((amount * magnitude) / _totalRewardHoldingSupply);
totalRewardsDistributed = amount;
}
}
function excludeFromRewards(address account, bool excluded) public onlyOwner {
_isExcludedFromRewards[account] = excluded;
if(excluded) {
_setRewardHoldingBalance(account, 0);
} else {
setRewardHoldingBalance(account, balanceOf(account));
}
}
function isExcludedFromRewards(address account) public view returns (bool) {
return _isExcludedFromRewards[account];
}
function accumulativeRewards(address account) public view returns (uint256) {
int256 a = int256(magnifiedRewardPerShare * _rewardHoldingBalance[account]);
int256 b = magnifiedRewardCorrections[account];
return uint256(a b) / magnitude;
}
function withdrawableRewards(address account) public view returns (uint256) {
return accumulativeRewards(account) - rewardsWithdrawn[account];
}
function withdrawnRewards(address account) public view returns (uint256) {
return rewardsWithdrawn[account];
}
function getRewardInfo(address account) public view returns (uint256, uint256, uint256) {
return (
withdrawableRewards(account),
withdrawnRewards(account),
lastClaimTimes[account]
);
}
function claimRewards() public nonReentrant {
address account = _msgSender();
uint256 amount = withdrawableRewards(account);
if(amount > 0) {
rewardsWithdrawn[account] = amount;
totalRewardsWithdrawn = amount;
payable(account).transfer(amount);
lastClaimTimes[account] = block.timestamp;
}
}
}