/**
*Submitted for verification at BscScan.com on 2022-02-24
*/
/**
*Submitted for verification at BscScan.com on 2022-02-24
*/
/**
*Submitted for verification at BscScan.com on 2022-02-22
*/
/**
*Submitted for verification at BscScan.com on 2022-02-05
*/
pragma solidity ^0.8.6;
// SPDX-License-Identifier: Unlicensed
interface IERC20 {
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
);
}
contract Ownable {
address public _owner;
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == msg.sender, "Ownable: caller is not the owner");
_;
}
function changeOwner(address newOwner) public onlyOwner {
_owner = newOwner;
}
}
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's ` ` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c a % b); // There is no case in which this doesn't hold
return c;
}
}
contract mains is IERC20, Ownable {
using SafeMath for uint256;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFee;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal;
uint256 private _rTotal;
uint256 private _tFeeTotal;
string private _name;
string private _symbol;
uint256 private _decimals;
uint256 public _liquidityFee = 2;
uint256 public _destroyFee = 0;
address private _destroyAddress =
address(0x000000000000000000000000000000000000dEaD);
uint256 public _inviterFee = 1;
mapping(address => address) public inviter;
mapping(address => uint256) public lastSellTime;
address public uniswapV2Pair;
address public fund1Address;
address public fund2Address;
uint256 public _fund1Fee = 3;
uint256 public _fund2Fee = 0;
uint256 public _mintTotal;
constructor(address tokenOwner,address _fund1Address,address _fund2Address) {
_name = "TITAN RISE";
_symbol = "TIT";
_decimals = 18;
_tTotal = 500000000 * 10**_decimals;
_mintTotal = 5000000 * 10**_decimals;
_rTotal = (MAX - (MAX % _tTotal));
_rOwned[tokenOwner] = _rTotal;
setMintTotal(_mintTotal);
//exclude owner and this contract from fee
_isExcludedFromFee[tokenOwner] = true;
_isExcludedFromFee[address(this)] = true;
fund1Address = _fund1Address;
fund2Address = _fund2Address;
_owner = tokenOwner;
emit Transfer(address(0), tokenOwner, _tTotal);
}
function getFund1Address() public view returns (address) {
return fund1Address;
}
function setFund1Address(address _fund1Address) public{
fund1Address = _fund1Address;
}
function getFund2Address() public view returns (address) {
return fund2Address;
}
function setFund2Address(address _fund2Address) public{
fund2Address = _fund2Address;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint256) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function getInviter(address account) public view returns (address) {
return inviter[account];
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function balancROf(address account) public view returns (uint256) {
return _rOwned[account];
}
function transfer(address recipient, uint256 amount)
public
override
returns (bool)
{
if(msg.sender == uniswapV2Pair){
_transfer(msg.sender, recipient, amount);
}else{
_tokenOlnyTransfer(msg.sender, recipient, amount);
}
return true;
}
function allowance(address owner, address spender)
public
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(msg.sender, spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
if(recipient == uniswapV2Pair){
_transfer(sender, recipient, amount);
}else{
_tokenOlnyTransfer(sender, recipient, amount);
}
_approve(
sender,
msg.sender,
_allowances[sender][msg.sender].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
function increaseAllowance(address spender, uint256 addedValue)
public
virtual
returns (bool)
{
_approve(
msg.sender,
spender,
_allowances[msg.sender][spender].add(addedValue)
);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue)
public
virtual
returns (bool)
{
_approve(
msg.sender,
spender,
_allowances[msg.sender][spender].sub(
subtractedValue,
"ERC20: decreased allowance below zero"
)
);
return true;
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function tokenFromReflection(uint256 rAmount)
public
view
returns (uint256)
{
require(
rAmount <= _rTotal,
"Amount must be less than total reflections"
);
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns (uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function claimTokens() public onlyOwner {
payable(_owner).transfer(address(this).balance);
}
function isExcludedFromFee(address account) public view returns (bool) {
return _isExcludedFromFee[account];
}
function _approve(
address owner,
address spender,
uint256 amount
) private {
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 _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
takeFee = false;
}
if(_mintTotal>=_tTotal){
takeFee = false;
}
//transfer amount, it will take tax, burn, liquidity fee
_tokenTransfer(from, to, amount, takeFee);
}
//this method is responsible for taking all fee, if takeFee is true
function _tokenTransfer(
address sender,
address recipient,
uint256 tAmount,
bool takeFee
) private {
uint256 currentRate = _getRate();
// use sender fee
uint256 rAmount = tAmount.mul(currentRate);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
uint256 rate;
if (takeFee) {
_takeTransfer(
sender,
uniswapV2Pair,
tAmount.div(100).mul(_liquidityFee),
currentRate
);
_takeTransfer(
sender,
fund1Address,
tAmount.div(100).mul(_fund1Fee),
currentRate
);
// _inviterFee
_takeInviterFee(sender, recipient, tAmount, currentRate);
rate =_liquidityFee _destroyFee _inviterFee _fund1Fee _fund2Fee;
}
uint256 recipientRate = 100 - rate;
_rOwned[recipient] = _rOwned[recipient].add(
rAmount.div(100).mul(recipientRate)
);
emit Transfer(sender, recipient, tAmount.div(100).mul(recipientRate));
}
//this method is responsible for taking all fee, if takeFee is true
function _tokenOlnyTransfer(
address sender,
address recipient,
uint256 tAmount
) private {
uint256 currentRate = _getRate();
if(_rOwned[recipient] == 0 && inviter[recipient] == address(0)){
inviter[recipient] = sender;
}else{
}
// 扣除发送人的
uint256 rAmount = tAmount.mul(currentRate);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rAmount);
emit Transfer(sender, recipient, tAmount);
}
function tokenOlnyTransferCheck1(
address sender,
address recipient
) public view returns(bool){
return _isExcludedFromFee[recipient] || _isExcludedFromFee[sender];
}
function tokenOlnyTransferCheck2(
address recipient
) public view returns(bool){
return _rOwned[recipient] == 0 && inviter[recipient] == address(0);
}
function _takeTransfer(
address sender,
address to,
uint256 tAmount,
uint256 currentRate
) private {
uint256 rAmount = tAmount.mul(currentRate);
_rOwned[to] = _rOwned[to].add(rAmount);
emit Transfer(sender, to, tAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _takeInviterFee(
address sender,
address recipient,
uint256 tAmount,
uint256 currentRate
) private {
address cur;
if (sender == uniswapV2Pair) {
cur = recipient;
} else {
cur = sender;
}
for (int256 i = 0; i < 1; i ) {
uint256 rate = 1;
cur = inviter[cur];
if (cur == address(0)) {
break;
}
uint256 curTAmount = tAmount.div(100).mul(rate);
uint256 curRAmount = curTAmount.mul(currentRate);
_rOwned[cur] = _rOwned[cur].add(curRAmount);
emit Transfer(sender, cur, curTAmount);
}
}
function changeRouter(address router) public onlyOwner {
uniswapV2Pair = router;
}
function setMintTotal(uint256 mintTotal) private {
_mintTotal = mintTotal;
}
}