File 1 of 1: BasedMiner.sol
pragma solidity 0.8.25;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
contract BasedMiner is Ownable {
uint256 private ETH_TO_DIG_1ETH = 1080000;
uint256 private PSN = 10000;
uint256 private PSNH = 5000;
uint256 private feeVal = 8;
bool private initialized = false;
address payable private projectAdd;
address payable private teamAdd;
mapping (address => uint256) private userClaims;
mapping (address => uint256) private userDeposits;
mapping (address => uint256) private producedMinters;
mapping (address => uint256) private claimedMiners;
mapping (address => uint256) public lastHire;
mapping (address => address) public referrals;
uint256 private marketMiners;
uint256 public totalDeposits;
event MinersBought(address indexed buyer, uint256 amountSpent, uint256 minersBought);
event MinersReHired(address indexed rehirer, address indexed referral, uint256 minersUsed);
constructor() {
}
receive () external payable {}
function reHire(address ref) public {
require(initialized);
require(block.timestamp > lastHire[msg.sender] + 3600, "Please Wait");
if(ref == msg.sender) {
ref = address(0);
}
if(referrals[msg.sender] == address(0) && referrals[msg.sender] != msg.sender) {
referrals[msg.sender] = ref;
}
uint256 minersUsed = getMyMiners(msg.sender);
uint256 minerValue = calculateMinerSell(minersUsed);
projectAdd.transfer((minerValue * 1 / 100));
uint256 newMinters = minersUsed / ETH_TO_DIG_1ETH;
producedMinters[msg.sender] = producedMinters[msg.sender] + newMinters;
claimedMiners[msg.sender] = 0;
lastHire[msg.sender] = block.timestamp;
if (lastHire[msg.sender] == 0) {
lastHire[msg.sender] = block.timestamp;
}
if (lastHire[referrals[msg.sender]] == 0) {
lastHire[referrals[msg.sender]] = block.timestamp;
}
producedMinters[referrals[msg.sender]] = producedMinters[referrals[msg.sender]] + ((minersUsed / 100) / ETH_TO_DIG_1ETH);
marketMiners = marketMiners + (minersUsed / 5);
emit MinersReHired(msg.sender, ref, minersUsed);
}
function sellMiners() public {
require(initialized);
uint256 hasMiners = getMyMiners(msg.sender);
uint256 minerValue = calculateMinerSell(hasMiners);
uint256 fee = projFee(minerValue);
userClaims[msg.sender] += minerValue;
claimedMiners[msg.sender] = 0;
lastHire[msg.sender] = block.timestamp;
marketMiners = marketMiners + hasMiners;
teamAdd.transfer((minerValue * 3) / 100);
projectAdd.transfer((minerValue * 5) / 100);
payable (msg.sender).transfer(minerValue - fee);
}
function ethRewards(address adr) public view returns(uint256) {
uint256 hasMiners = getMyMiners(adr);
if (hasMiners == 0) {
return 0;
}
uint256 minerValue = calculateMinerSell(hasMiners);
return minerValue;
}
function buyMiners(address ref) public payable {
require(initialized);
require(msg.value < (address(this).balance * 15) / 100);
totalDeposits += msg.value;
userDeposits[msg.sender] += msg.value;
uint256 minersBought = calculateMinerBuy(msg.value,(address(this).balance - msg.value));
minersBought = minersBought - projFee(minersBought);
teamAdd.transfer((msg.value * 3) / 100);
projectAdd.transfer((msg.value * 5) / 100);
producedMinters[msg.sender] += (minersBought / ETH_TO_DIG_1ETH);
if(ref == msg.sender) {
ref = address(0);
}
if(referrals[msg.sender] == address(0) && referrals[msg.sender] != msg.sender) {
referrals[msg.sender] = ref;
}
if (lastHire[msg.sender] == 0) {
lastHire[msg.sender] = block.timestamp;
}
if (lastHire[referrals[msg.sender]] == 0) {
lastHire[referrals[msg.sender]] = block.timestamp;
}
producedMinters[referrals[msg.sender]] = producedMinters[referrals[msg.sender]] + ((minersBought / 10) / ETH_TO_DIG_1ETH);
emit MinersBought(msg.sender, msg.value, minersBought);
}
function getETHDeposited(address adr) public view returns(uint256) {
return userDeposits[adr];
}
function getETHClaimed(address adr) public view returns(uint256) {
return userClaims[adr];
}
function calculateTrade(uint256 rt,uint256 rs, uint256 bs) private view returns(uint256) {
return (PSN * bs) / (PSNH + ((PSN * rs + PSNH * rt) / rt));
}
function calculateMinerSell(uint256 miners) public view returns(uint256) {
return calculateTrade(miners,marketMiners,address(this).balance);
}
function calculateMinerBuy(uint256 eth,uint256 contractBalance) public view returns(uint256) {
return calculateTrade(eth,contractBalance,marketMiners);
}
function calculateMinerBuySimple(uint256 eth) public view returns(uint256) {
return calculateMinerBuy(eth,address(this).balance);
}
function projFee(uint256 amount) private view returns(uint256) {
return ((amount * feeVal) / 100);
}
function seedMarket(address adr1, address adr2) public payable onlyOwner {
require(marketMiners == 0);
initialized = true;
marketMiners = 108000000000;
teamAdd = payable(adr1);
projectAdd = payable(adr2);
}
function getBalance() public view returns(uint256) {
return address(this).balance;
}
function getMyMinters(address adr) public view returns(uint256) {
return producedMinters[adr];
}
function getMyMiners(address adr) public view returns(uint256) {
return (claimedMiners[adr] + getMinersSinceLastHire(adr));
}
function getMinersSinceLastHire(address adr) public view returns(uint256) {
uint256 secondsPassed = min(ETH_TO_DIG_1ETH,(block.timestamp - lastHire[adr]));
return (secondsPassed * producedMinters[adr]);
}
function min(uint256 a, uint256 b) private pure returns (uint256) {
return a < b ? a : b;
}
}
{
"compilationTarget": {
"BasedMiner.sol": "BasedMiner"
},
"evmVersion": "cancun",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}