Contract Source Code:
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity 0.8.7;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
//SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.7;
import "./Interfaces.sol";
abstract contract BaseErc20 is IERC20, IOwnable {
mapping (address => uint256) internal _balances;
mapping (address => mapping (address => uint256)) internal _allowed;
uint256 internal _totalSupply;
string public symbol;
string public name;
uint8 public decimals;
address public override owner;
bool public launched;
mapping (address => bool) internal exchanges;
modifier onlyOwner() {
require(msg.sender == owner, "can only be called by the contract owner");
_;
}
modifier isLaunched() {
require(launched, "can only be called once token is launched");
_;
}
// @dev Trading is allowed before launch if the sender is the owner, we are transferring from the owner, or in canAlwaysTrade list
modifier tradingEnabled(address from) {
require(launched || from == owner, "trading not enabled");
_;
}
function configure(address _owner) internal virtual {
owner = _owner;
}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) external override view returns (uint256) {
return _balances[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address spender) external override view returns (uint256) {
return _allowed[_owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) external override tradingEnabled(msg.sender) returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* 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
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) external override tradingEnabled(msg.sender) returns (bool) {
require(spender != address(0), "cannot approve the 0 address");
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(address from, address to, uint256 value) external override tradingEnabled(from) returns (bool) {
_allowed[from][msg.sender] = _allowed[from][msg.sender] - value;
_transfer(from, to, value);
emit Approval(from, msg.sender, _allowed[from][msg.sender]);
return true;
}
// Virtual methods
function launch() virtual external onlyOwner {
require(launched == false, "contract already launched");
launched = true;
}
function calculateTransferAmount(address from, address to, uint256 value) virtual internal returns (uint256) {
require(from != to, "you cannot transfer to yourself");
return value;
}
function preTransfer(address from, address to, uint256 value) virtual internal { }
// Admin methods
function changeOwner(address who) external onlyOwner {
owner = who;
}
function setExchange(address who, bool on) external onlyOwner {
require(exchanges[who] != on, "already set");
exchanges[who] = on;
}
// Private methods
function getRouterAddress() internal view returns (address routerAddress) {
if (block.chainid == 1 || block.chainid == 3 || block.chainid == 4 || block.chainid == 5) {
routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ; // ETHEREUM
} else if (block.chainid == 56) {
routerAddress = 0x10ED43C718714eb63d5aA57B78B54704E256024E; // BSC MAINNET
} else if (block.chainid == 97) {
routerAddress = 0xc99f3718dB7c90b020cBBbb47eD26b0BA0C6512B; // BSC TESTNET - https://pancakeswap.rainbit.me/
} else {
revert("Unknown Chain ID");
}
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) private {
require(to != address(0), "cannot be zero address");
preTransfer(from, to, value);
uint256 modifiedAmount = calculateTransferAmount(from, to, value);
_balances[from] = _balances[from] - value;
_balances[to] = _balances[to] + modifiedAmount;
emit Transfer(from, to, modifiedAmount);
}
}
//SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.7;
import "./BaseErc20Min.sol";
import "./AddressLibrary.sol";
import "./Interfaces.sol";
interface IBasicTaxDistributor {
receive() external payable;
function lastSwapTime() external view returns (uint256);
function inSwap() external view returns (bool);
function createWalletTax(string memory name, uint256 buyTax, uint256 sellTax, address wallet, bool convertToNative) external;
function distribute() external payable;
function getSellTax() external view returns (uint256);
function getBuyTax() external view returns (uint256);
function getTaxWallet(string memory taxName) external view returns(address);
function setTaxWallet(string memory taxName, address wallet) external;
function setSellTax(string memory taxName, uint256 taxPercentage) external;
function setBuyTax(string memory taxName, uint256 taxPercentage) external;
function takeSellTax(uint256 value) external returns (uint256);
function takeBuyTax(uint256 value) external returns (uint256);
}
abstract contract Taxable is BaseErc20 {
IBasicTaxDistributor internal taxDistributor;
bool internal autoSwapTax;
uint256 internal minimumTimeBetweenSwaps;
uint256 internal minimumTokensBeforeSwap;
mapping (address => bool) internal excludedFromTax;
uint256 private swapStartTime;
// Overrides
function configure(address _owner) internal virtual override {
excludedFromTax[owner] = true;
super.configure(_owner);
}
function calculateTransferAmount(address from, address to, uint256 value) internal virtual override returns (uint256) {
uint256 amountAfterTax = value;
if (excludedFromTax[from] == false && excludedFromTax[to] == false && launched) {
if (exchanges[from]) {
// we are BUYING
amountAfterTax = taxDistributor.takeBuyTax(value);
} else if (exchanges[to]) {
// we are SELLING
amountAfterTax = taxDistributor.takeSellTax(value);
}
}
uint256 taxAmount = value - amountAfterTax;
if (taxAmount > 0) {
_balances[address(taxDistributor)] = _balances[address(taxDistributor)] + taxAmount;
emit Transfer(from, address(taxDistributor), taxAmount);
}
return super.calculateTransferAmount(from, to, amountAfterTax);
}
function preTransfer(address from, address to, uint256 value) override virtual internal {
uint256 timeSinceLastSwap = block.timestamp - taxDistributor.lastSwapTime();
if (
launched &&
autoSwapTax &&
exchanges[to] &&
swapStartTime + 60 <= block.timestamp &&
timeSinceLastSwap >= minimumTimeBetweenSwaps &&
_balances[address(taxDistributor)] >= minimumTokensBeforeSwap &&
taxDistributor.inSwap() == false
) {
swapStartTime = block.timestamp;
try taxDistributor.distribute() {} catch {}
}
super.preTransfer(from, to, value);
}
// Public methods
/**
* @dev Return the current total sell tax from the tax distributor
*/
function sellTax() external view returns (uint256) {
return taxDistributor.getSellTax();
}
/**
* @dev Return the current total sell tax from the tax distributor
*/
function buyTax() external view returns (uint256) {
return taxDistributor.getBuyTax();
}
/**
* @dev Return the address of the tax distributor contract
*/
function taxDistributorAddress() external view returns (address) {
return address(taxDistributor);
}
// Admin methods
function setAutoSwaptax(bool enabled) external onlyOwner {
autoSwapTax = enabled;
}
function setExcludedFromTax(address who, bool enabled) external onlyOwner {
require(exchanges[who] == false || enabled == false, "Cannot exclude an exchange from tax");
excludedFromTax[who] = enabled;
}
function setTaxDistributionThresholds(uint256 minAmount, uint256 minTime) external onlyOwner {
minimumTokensBeforeSwap = minAmount;
minimumTimeBetweenSwaps = minTime;
}
function setSellTax(string memory taxName, uint256 taxAmount) external onlyOwner {
taxDistributor.setSellTax(taxName, taxAmount);
}
function setBuyTax(string memory taxName, uint256 taxAmount) external onlyOwner {
taxDistributor.setBuyTax(taxName, taxAmount);
}
function setTaxWallet(string memory taxName, address wallet) external onlyOwner {
taxDistributor.setTaxWallet(taxName, wallet);
}
function runSwapManually() external isLaunched {
taxDistributor.distribute();
}
}
contract BasicTaxDistributor is IBasicTaxDistributor {
using Address for address;
address immutable private tokenPair;
address immutable private routerAddress;
address immutable private _token;
address immutable private _wbnb;
IDEXRouter private _router;
bool public override inSwap;
uint256 public override lastSwapTime;
uint256 immutable private maxSellTax;
uint256 immutable private maxBuyTax;
struct Tax {
string taxName;
uint256 buyTaxPercentage;
uint256 sellTaxPercentage;
uint256 taxPool;
address location;
uint256 share;
bool convertToNative;
}
Tax[] internal taxes;
event TaxesDistributed(uint256 tokensSwapped, uint256 ethReceived);
event DistributionError(string text);
modifier onlyToken() {
require(msg.sender == _token, "no permissions");
_;
}
modifier swapLock() {
require(inSwap == false, "already swapping");
inSwap = true;
_;
inSwap = false;
}
constructor (address router, address pair, address wbnb, uint256 _maxSellTax, uint256 _maxBuyTax) {
require(wbnb != address(0), "pairedToken cannot be 0 address");
require(pair != address(0), "pair cannot be 0 address");
require(router != address(0), "router cannot be 0 address");
_token = msg.sender;
_wbnb = wbnb;
_router = IDEXRouter(router);
maxSellTax = _maxSellTax;
maxBuyTax = _maxBuyTax;
tokenPair = pair;
routerAddress = router;
}
receive() external override payable {}
function createWalletTax(string memory name, uint256 buyTax, uint256 sellTax, address wallet, bool convertToNative) external override onlyToken {
require(checkTaxExists(name) == false, "This tax already exists");
taxes.push(Tax(name, buyTax, sellTax, 0, wallet, 0, convertToNative));
}
function checkTaxExists(string memory taxName) private view returns(bool) {
for (uint256 i = 0; i < taxes.length; i++) {
if (compareStrings(taxes[i].taxName, taxName)) {
return true;
}
}
return false;
}
function distribute() external payable override onlyToken swapLock {
address[] memory path = new address[](2);
path[0] = _token;
path[1] = _wbnb;
IERC20 token = IERC20(_token);
uint256 totalTokens;
for (uint256 i = 0; i < taxes.length; i++) {
if (taxes[i].convertToNative) {
totalTokens += taxes[i].taxPool;
}
}
totalTokens = checkTokenAmount(token, totalTokens);
uint256[] memory amts = _router.swapExactTokensForETH(
totalTokens,
0,
path,
address(this),
block.timestamp + 300
);
uint256 amountBNB = address(this).balance;
if (totalTokens != amts[0] || amountBNB != amts[1] ) {
emit DistributionError("Unexpected amounts returned from swap");
}
// Calculate the distribution
uint256 toDistribute = amountBNB;
for (uint256 i = 0; i < taxes.length; i++) {
if (taxes[i].convertToNative) {
if (i == taxes.length - 1) {
taxes[i].share = toDistribute;
} else {
uint256 share = (amountBNB * taxes[i].taxPool) / totalTokens;
taxes[i].share = share;
toDistribute = toDistribute - share;
}
}
}
// Distribute the coins
for (uint256 i = 0; i < taxes.length; i++) {
if (taxes[i].convertToNative) {
Address.sendValue(payable(taxes[i].location), taxes[i].share);
} else {
require(token.transfer(taxes[i].location, checkTokenAmount(token, taxes[i].taxPool)), "could not transfer tokens");
}
taxes[i].taxPool = 0;
taxes[i].share = 0;
}
// Remove any leftoever tokens
if (address(this).balance > 0) {
Address.sendValue(payable(_token), address(this).balance);
}
if (token.balanceOf(address(this)) > 0) {
token.transfer(_token, token.balanceOf(address(this)));
}
emit TaxesDistributed(totalTokens, amountBNB);
lastSwapTime = block.timestamp;
}
function getSellTax() public override onlyToken view returns (uint256) {
uint256 taxAmount;
for (uint256 i = 0; i < taxes.length; i++) {
taxAmount += taxes[i].sellTaxPercentage;
}
return taxAmount;
}
function getBuyTax() public override onlyToken view returns (uint256) {
uint256 taxAmount;
for (uint256 i = 0; i < taxes.length; i++) {
taxAmount += taxes[i].buyTaxPercentage;
}
return taxAmount;
}
function getTaxWallet(string memory taxName)external override view onlyToken returns (address) {
for (uint256 i = 0; i < taxes.length; i++) {
if (compareStrings(taxes[i].taxName, taxName)) {
return taxes[i].location;
}
}
revert("could not find tax");
}
function setTaxWallet(string memory taxName, address wallet) external override onlyToken {
bool updated;
for (uint256 i = 0; i < taxes.length; i++) {
if (compareStrings(taxes[i].taxName, taxName)) {
taxes[i].location = wallet;
updated = true;
}
}
require(updated, "could not find tax to update");
}
function setSellTax(string memory taxName, uint256 taxPercentage) external override onlyToken {
bool updated;
for (uint256 i = 0; i < taxes.length; i++) {
if (compareStrings(taxes[i].taxName, taxName)) {
taxes[i].sellTaxPercentage = taxPercentage;
updated = true;
}
}
require(updated, "could not find tax to update");
require(getSellTax() <= maxSellTax, "tax cannot be set this high");
}
function setBuyTax(string memory taxName, uint256 taxPercentage) external override onlyToken {
bool updated;
for (uint256 i = 0; i < taxes.length; i++) {
//if (taxes[i].taxName == taxName) {
if (compareStrings(taxes[i].taxName, taxName)) {
taxes[i].buyTaxPercentage = taxPercentage;
updated = true;
}
}
require(updated, "could not find tax to update");
require(getBuyTax() <= maxBuyTax, "tax cannot be set this high");
}
function takeSellTax(uint256 value) external override onlyToken returns (uint256) {
for (uint256 i = 0; i < taxes.length; i++) {
if (taxes[i].sellTaxPercentage > 0) {
uint256 taxAmount = (value * taxes[i].sellTaxPercentage) / 10000;
taxes[i].taxPool += taxAmount;
value = value - taxAmount;
}
}
return value;
}
function takeBuyTax(uint256 value) external override onlyToken returns (uint256) {
for (uint256 i = 0; i < taxes.length; i++) {
if (taxes[i].buyTaxPercentage > 0) {
uint256 taxAmount = (value * taxes[i].buyTaxPercentage) / 10000;
taxes[i].taxPool += taxAmount;
value = value - taxAmount;
}
}
return value;
}
// Private methods
function compareStrings(string memory a, string memory b) private pure returns (bool) {
return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));
}
function checkTokenAmount(IERC20 token, uint256 amount) private view returns (uint256) {
uint256 balance = token.balanceOf(address(this));
if (balance > amount) {
return amount;
}
return balance;
}
}
//SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.7;
interface IOwnable {
function owner() external view returns (address);
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address _owner, address spender) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
interface IBurnable {
function burn(uint256 value) external;
function burnFrom(address account, uint256 value) external;
}
interface IDEXFactory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IDEXRouter {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline) external payable returns (uint amountToken, uint amountETH, uint liquidity);
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 swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts);
function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts);
function swapExactTokensForETHSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts);
}
interface IDividendDistributor {
function setDistributionCriteria(uint256 _minPeriod, uint256 _minDistribution) external;
function setShare(address shareholder, uint256 amount) external;
function depositNative() external payable;
function depositToken(address from, uint256 amount) external;
function process(uint256 gas) external;
function inSwap() external view returns (bool);
}
interface ITaxDistributorLight {
receive() external payable;
function lastSwapTime() external view returns (uint256);
function inSwap() external view returns (bool);
function createWalletTax(string memory name, uint256 buyTax, uint256 sellTax, address wallet, bool convertToNative) external;
function distribute() external payable;
function getSellTax() external view returns (uint256);
function getBuyTax() external view returns (uint256);
function getTaxWallet(string memory taxName) external view returns(address);
function setTaxWallet(string memory taxName, address wallet) external;
function setSellTax(string memory taxName, uint256 taxPercentage) external;
function setBuyTax(string memory taxName, uint256 taxPercentage) external;
function takeSellTax(uint256 value) external returns (uint256);
function takeBuyTax(uint256 value) external returns (uint256);
}
interface ITaxDistributor {
function createDistributorTax(string memory name, uint256 buyTax, uint256 sellTax, address wallet, bool convertToNative) external;
function createDividendTax(string memory name, uint256 buyTax, uint256 sellTax, address dividendDistributor, bool convertToNative) external;
function createBurnTax(string memory name, uint256 buyTax, uint256 sellTax) external;
function createLiquidityTax(string memory name, uint256 buyTax, uint256 sellTax, address holder) external;
}
interface IWalletDistributor {
function receiveToken(address token, address from, uint256 amount) external;
}
//SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.7;
import "./Interfaces.sol";
import "./BaseErc20Min.sol";
import "./BasicTaxableMin.sol";
contract Jared is BaseErc20, Taxable {
uint256 immutable public mhAmount;
constructor () {
configure(0xE167B3654fA47F5b14a3120afF2747bb9Bd3C73c);
symbol = "JARED";
name = "Jared Coin";
decimals = 18;
// Swap
address routerAddress = getRouterAddress();
IDEXRouter router = IDEXRouter(routerAddress);
address native = router.WETH();
address pair = IDEXFactory(router.factory()).createPair(native, address(this));
exchanges[pair] = true;
taxDistributor = new BasicTaxDistributor(routerAddress, pair, native, 3000, 2000);
// Tax
minimumTimeBetweenSwaps = 30 seconds;
minimumTokensBeforeSwap = 1 * 10 ** decimals;
excludedFromTax[address(taxDistributor)] = true;
taxDistributor.createWalletTax("Marketing", 2000, 3000, 0x55a57dE02C3cD913B846B3Ffcc17110D63625bFa, true);
autoSwapTax = true;
// Max Hold
mhAmount = 8_413_800_005 * 10 ** decimals;
// Finalise
_allowed[address(taxDistributor)][routerAddress] = 2**256 - 1;
_totalSupply = _totalSupply + (420_690_000_000 * 10 ** decimals);
_balances[owner] = _balances[owner] + _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
// Overrides
function configure(address _owner) internal override(Taxable, BaseErc20) {
super.configure(_owner);
}
function preTransfer(address from, address to, uint256 value) override(Taxable, BaseErc20) internal {
if (launched &&
from != owner && to != owner &&
exchanges[to] == false &&
to != getRouterAddress()
) {
require (_balances[to] + value <= mhAmount, "this is over the max hold amount");
}
super.preTransfer(from, to, value);
}
function calculateTransferAmount(address from, address to, uint256 value) override(Taxable, BaseErc20) internal returns (uint256) {
return super.calculateTransferAmount(from, to, value);
}
}