编译器
0.8.24+commit.e11b9ed9
文件 1 的 23:Address.sol
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
library Address {
error AddressEmptyCode(address target);
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert Errors.FailedCall();
}
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
function _revert(bytes memory returndata) private pure {
if (returndata.length > 0) {
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert Errors.FailedCall();
}
}
}
文件 2 的 23:Context.sol
pragma solidity ^0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
文件 3 的 23:ERC20.sol
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function decimals() public view virtual returns (uint8) {
return 18;
}
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
_totalSupply -= value;
}
} else {
unchecked {
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
文件 4 的 23:Errors.sol
pragma solidity ^0.8.20;
library Errors {
error InsufficientBalance(uint256 balance, uint256 needed);
error FailedCall();
error FailedDeployment();
error MissingPrecompile(address);
}
文件 5 的 23:Hyperpool.sol
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import "./interfaces/IERC721A.sol";
import "./interfaces/ITeamFinanceLocker.sol";
import "./interfaces/IToken.sol";
import "./PrizePoolV2.sol";
contract Token is IToken, ERC20, Ownable {
struct UserInfo {
bool isFeeExempt;
bool isTxLimitExempt;
uint256 lastTxBlock;
bool isPrizePoolExcluded;
bool isWhitelisted;
}
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable pair;
PrizePool public prizePool;
address payable public secondaryWallet;
address payable public immutable proofWallet;
address payable public immutable proofStaking;
IERC721A public proofPassNFT;
uint256 public launchedAt;
uint256 public maxWallet;
uint256 public initMaxWallet;
bool public checkMaxHoldings = true;
bool public maxWalletChanged;
uint256 public swapping;
bool public swapEnabled = true;
uint256 public swapTokensAtAmount;
mapping (uint256 => uint256) public swapThrottle;
uint256 public maxSwapsPerBlock = 4;
FeeInfo public feeTokens;
FeeInfo public buyFees;
FeeInfo public sellFees;
uint256 public restingBuyTotal;
uint256 public restingSellTotal;
uint256 public whitelistDuration;
uint256 public whitelistEndTime;
bool public isWhitelistActive;
bool public buyTaxesSettled;
bool public sellTaxesSettled;
bool public proofFeeReduced;
bool public proofFeeRemoved;
bool public cancelled;
uint256 public lockID;
uint256 public immutable lpLockDuration;
address public immutable lockerAddress;
mapping (address => UserInfo) public userInfo;
event SwapAndLiquify(uint256 tokensAutoLiq, uint256 ethAutoLiq);
event SwapAndLiquifyEnabledUpdated(bool enabled);
error InsufficientLiq();
error NotWhitelisted();
constructor(
uint256 _totalSupply,
FeeInfo memory _buyFees,
FeeInfo memory _sellFees,
uint256 _percentToLP,
uint256 _lpLockDuration,
address _secondaryWallet,
address _proofPassNFT,
address[] memory _whitelist,
ProofInfo memory _addresses,
PrizePoolInfo memory prizePoolArgs
) ERC20("Hyperpool", "HYPER") Ownable(msg.sender) payable {
if (_lpLockDuration < 30 days || _percentToLP < 70) {
revert InvalidConfiguration();
}
if (msg.value < 1 ether) {
revert InsufficientLiq();
}
(_buyFees.proof, _sellFees.proof) = (2,2);
_validateFees(_buyFees, _sellFees);
restingBuyTotal = _buyFees.total;
restingSellTotal = _sellFees.total;
_buyFees.secondary = 15 - _buyFees.proof - _buyFees.main - _buyFees.liquidity;
_buyFees.total = 15;
_sellFees.secondary = 20 - _sellFees.proof - _sellFees.main - _sellFees.liquidity;
_sellFees.total = 20;
buyFees = _buyFees;
sellFees = _sellFees;
secondaryWallet = payable(_secondaryWallet);
prizePool = new PrizePool(prizePoolArgs.vrfCoordinator, prizePoolArgs.subscriptionId, [50, 25, 25], prizePoolArgs.timerStart, prizePoolArgs.drawTimeHours, prizePoolArgs.entriesPerTicket);
lockerAddress = _addresses.locker;
proofWallet = payable(_addresses.proofWallet);
proofStaking = payable(_addresses.proofStaking);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(_addresses.router);
uniswapV2Router = _uniswapV2Router;
pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uint256 amountToPair = _totalSupply * _percentToLP / 100;
super._update(address(0), address(this), amountToPair);
lpLockDuration = _lpLockDuration;
swapTokensAtAmount = _totalSupply * 5 / 4000;
initMaxWallet = 250;
maxWallet = _totalSupply * 250 / 100000;
userInfo[address(this)] = UserInfo(true, true, 0, true, true);
userInfo[pair].isTxLimitExempt = true;
userInfo[pair].isPrizePoolExcluded = true;
userInfo[pair].isWhitelisted = true;
userInfo[owner()].isPrizePoolExcluded = true;
userInfo[_addresses.router].isPrizePoolExcluded = true;
userInfo[address(prizePool)].isPrizePoolExcluded = true;
proofPassNFT = IERC721A(_proofPassNFT);
whitelistDuration = 120;
_setWhitelisted(_whitelist);
_updateAndSetBalance(address(0), owner(), _totalSupply - amountToPair);
}
function launch() external payable onlyOwner lockTheSwap {
if (launchedAt != 0 || cancelled) {
revert InvalidConfiguration();
}
launchedAt = block.timestamp;
whitelistEndTime = block.timestamp + whitelistDuration;
isWhitelistActive = true;
_approve(address(this), address(uniswapV2Router), type(uint256).max);
addLiquidity(balanceOf(address(this)), address(this).balance - msg.value, address(this));
uint256 len = proofPassNFT.totalSupply() + 1;
for (uint256 i = 1; i < len; ) {
userInfo[proofPassNFT.ownerOf(i)].isWhitelisted = true;
unchecked { ++i; }
}
uint256 lpBalance = IERC20(pair).balanceOf(address(this));
IERC20(pair).approve(lockerAddress, lpBalance);
lockID = ITeamFinanceLocker(lockerAddress).lockToken{value: msg.value}(pair, msg.sender, lpBalance, block.timestamp + lpLockDuration, false, address(0));
}
function cancel() external onlyOwner {
if (launchedAt != 0) {
revert InvalidConfiguration();
}
cancelled = true;
_updateAndSetBalance(address(this), owner(), balanceOf(address(this)));
address(owner()).call{value: address(this).balance}("");
}
function _update(
address from,
address to,
uint256 amount
) internal override {
if (swapping == 2 || from == owner() || to == owner() ||
from == address(this) || to == address(this) || amount == 0) {
_updateAndSetBalance(from, to, amount);
return;
}
if (launchedAt == 0) {
revert TradingNotEnabled();
}
UserInfo storage sender = userInfo[from];
UserInfo storage recipient = userInfo[to];
if (isWhitelistActive) {
if (block.timestamp < whitelistEndTime) {
if (!sender.isWhitelisted || !recipient.isWhitelisted)
{
revert NotWhitelisted();
}
} else {
isWhitelistActive = false;
}
}
if (!maxWalletChanged) {
uint256 secondsPassed = block.timestamp - launchedAt;
uint256 percentage = initMaxWallet + (100 * (secondsPassed / 120));
if (percentage > 950) {
percentage = 1000;
maxWalletChanged = true;
}
uint256 newMax = totalSupply() * percentage / 100000;
if (newMax != maxWallet) {
maxWallet = newMax;
}
}
if (checkMaxHoldings) {
if (!recipient.isTxLimitExempt && amount + balanceOf(to) > maxWallet) {
revert ExceedsMaxWalletAmount();
}
}
uint256 total = feeTokens.total;
bool canSwap = total >= swapTokensAtAmount;
if (
canSwap &&
swapEnabled &&
from != pair &&
swapThrottle[block.number] < maxSwapsPerBlock
) {
++swapThrottle[block.number];
processFees(total, swapTokensAtAmount);
}
if (!sender.isFeeExempt && !recipient.isFeeExempt) {
FeeInfo storage _buyFees = buyFees;
FeeInfo storage _sellFees = sellFees;
if (!proofFeeRemoved) {
uint256 secondsPassed = block.timestamp - launchedAt;
if (!proofFeeReduced && secondsPassed > 1 days) {
uint256 totalBuy = _buyFees.total - _buyFees.proof;
if (totalBuy == 0) {
_buyFees.total = 0;
_buyFees.proof = 0;
} else {
_buyFees.main = _buyFees.main + 1;
_buyFees.proof = 1;
}
uint256 totalSell = _sellFees.total - _sellFees.proof;
if (totalSell == 0) {
_sellFees.total = 0;
_sellFees.proof = 0;
} else {
_sellFees.main = _sellFees.main + 1;
_sellFees.proof = 1;
}
proofFeeReduced = true;
} else if (secondsPassed > 31 days) {
_buyFees.main += _buyFees.proof;
_sellFees.main += _sellFees.proof;
_buyFees.proof = 0;
_sellFees.proof = 0;
proofFeeRemoved = true;
} else {
if (!buyTaxesSettled) {
uint256 restingTotal = restingBuyTotal;
uint256 feeTotal = restingTotal;
if (secondsPassed < 1801) {
feeTotal = 15 - (secondsPassed / 120);
}
if (feeTotal <= restingTotal) {
_buyFees.total = restingTotal;
_buyFees.secondary = restingTotal - _buyFees.liquidity - _buyFees.main - _buyFees.proof;
buyTaxesSettled = true;
} else if (feeTotal != _buyFees.total) {
_buyFees.total = feeTotal;
_buyFees.secondary = feeTotal - _buyFees.liquidity - _buyFees.main - _buyFees.proof;
}
}
if (!sellTaxesSettled) {
uint256 restingTotal = restingSellTotal;
uint256 feeTotal = restingTotal;
if (secondsPassed < 2401) {
feeTotal = 20 - (secondsPassed / 120);
}
if (feeTotal <= restingTotal) {
_sellFees.total = restingTotal;
_sellFees.secondary = restingTotal - _sellFees.liquidity - _sellFees.main - _sellFees.proof;
sellTaxesSettled = true;
} else if (feeTotal != _sellFees.total) {
_sellFees.total = feeTotal;
_sellFees.secondary = feeTotal - _sellFees.liquidity - _sellFees.main - _sellFees.proof;
}
}
}
}
uint256 fees;
if (to == pair) {
fees = _calculateFees(_sellFees, amount);
} else if (from == pair) {
fees = _calculateFees(_buyFees, amount);
}
if (fees > 0) {
amount -= fees;
super._update(from, address(this), fees);
}
}
super._update(from, to, amount);
if (!sender.isPrizePoolExcluded) {
try prizePool.setBalance(from, balanceOf(from)) {} catch {}
}
if (!recipient.isPrizePoolExcluded) {
try prizePool.setBalance(to, balanceOf(to)) {} catch {}
}
}
function _calculateFees(FeeInfo memory feeRate, uint256 amount) internal returns (uint256 fees) {
if (feeRate.total != 0) {
fees = amount * feeRate.total / 100;
FeeInfo storage _feeTokens = feeTokens;
_feeTokens.main += fees * feeRate.main / feeRate.total;
_feeTokens.secondary += fees * feeRate.secondary / feeRate.total;
_feeTokens.liquidity += fees * feeRate.liquidity / feeRate.total;
_feeTokens.proof += fees * feeRate.proof / feeRate.total;
_feeTokens.total += fees;
}
}
function processFees(uint256 total, uint256 amountToSwap) internal lockTheSwap {
FeeInfo storage _feeTokens = feeTokens;
FeeInfo memory swapTokens;
swapTokens.main = amountToSwap * _feeTokens.main / total;
swapTokens.secondary = amountToSwap * _feeTokens.secondary / total;
swapTokens.liquidity = amountToSwap * _feeTokens.liquidity / total;
swapTokens.proof = amountToSwap * _feeTokens.proof / total;
uint256 amountToPair = swapTokens.liquidity / 2;
swapTokens.total = amountToSwap - amountToPair;
uint256 ethBalance = swapTokensForETH(swapTokens.total);
FeeInfo memory ethSplit;
ethSplit.main = ethBalance * swapTokens.main / swapTokens.total;
if (ethSplit.main > 0) {
address(prizePool).call{value: ethSplit.main}("");
}
ethSplit.secondary = ethBalance * swapTokens.secondary / swapTokens.total;
if (ethSplit.secondary > 0) {
address(secondaryWallet).call{value: ethSplit.secondary}("");
}
ethSplit.proof = ethBalance * swapTokens.proof / swapTokens.total;
if (ethSplit.proof > 0) {
uint256 revenueSplit = ethSplit.proof / 2;
address(proofStaking).call{value: revenueSplit}("");
address(proofWallet).call{value: ethSplit.proof - revenueSplit}("");
}
uint256 amountPaired;
ethSplit.liquidity = address(this).balance;
if (amountToPair > 0 && ethSplit.liquidity > 0) {
amountPaired = addLiquidity(amountToPair, ethSplit.liquidity, address(0xdead));
emit SwapAndLiquify(amountToPair, ethSplit.liquidity);
}
uint256 liquidityAdjustment = swapTokens.liquidity - (amountToPair - amountPaired);
_feeTokens.main -= swapTokens.main;
_feeTokens.secondary -= swapTokens.secondary;
_feeTokens.liquidity -= liquidityAdjustment;
_feeTokens.proof -= swapTokens.proof;
_feeTokens.total -= swapTokens.main + swapTokens.secondary + swapTokens.proof + liquidityAdjustment;
}
function swapTokensForETH(uint256 tokenAmount) internal returns (uint256 ethBalance) {
uint256 ethBalBefore = address(this).balance;
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
ethBalance = address(this).balance - ethBalBefore;
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount, address recipient) private returns (uint256) {
(uint256 amountA,,) = uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0,
0,
recipient,
block.timestamp
);
return amountA;
}
function burn(uint256 amount) external {
super._burn(msg.sender, amount);
if (!userInfo[msg.sender].isPrizePoolExcluded) {
try prizePool.burn(msg.sender, amount) {} catch {}
try prizePool.setBalance(msg.sender, balanceOf(msg.sender)) {} catch {}
}
}
function changeFees(
uint256 liquidityBuy,
uint256 mainBuy,
uint256 secondaryBuy,
uint256 liquiditySell,
uint256 mainSell,
uint256 secondarySell
) external onlyOwner {
if (!buyTaxesSettled || !sellTaxesSettled) {
revert InvalidConfiguration();
}
FeeInfo memory _buyFees;
_buyFees.liquidity = liquidityBuy;
_buyFees.main = mainBuy;
_buyFees.secondary = secondaryBuy;
FeeInfo memory _sellFees;
_sellFees.liquidity = liquiditySell;
_sellFees.main = mainSell;
_sellFees.secondary = secondarySell;
(_buyFees.proof, _sellFees.proof) = launchedAt != 0 ? _calculateProofFee() : (2,2);
_validateFees(_buyFees, _sellFees);
buyFees = _buyFees;
sellFees = _sellFees;
}
function _calculateProofFee() internal returns (uint256, uint256) {
uint256 secondsPassed = block.timestamp - launchedAt;
if (secondsPassed > 31 days) {
proofFeeRemoved = true;
return (0,0);
} else if (secondsPassed > 1 days) {
proofFeeReduced = true;
return (1,1);
} else {
return (2,2);
}
}
function _validateFees(FeeInfo memory _buyFees, FeeInfo memory _sellFees) internal pure {
_buyFees.total = _buyFees.liquidity + _buyFees.main + _buyFees.secondary;
if (_buyFees.total == 0) {
_buyFees.proof = 0;
} else {
_buyFees.total += _buyFees.proof;
}
_sellFees.total = _sellFees.liquidity + _sellFees.main + _sellFees.secondary;
if (_sellFees.total == 0) {
_sellFees.proof = 0;
} else {
_sellFees.total += _sellFees.proof;
}
if (_buyFees.total > 7 || _sellFees.total > 7) {
revert InvalidConfiguration();
}
}
function setCheckMaxHoldingsEnabled(bool _enabled) external onlyOwner{
checkMaxHoldings = _enabled;
}
function setFeeExempt(address account, bool value) public onlyOwner {
userInfo[account].isFeeExempt = value;
}
function setFeeExempt(address[] memory accounts) public onlyOwner {
uint256 len = accounts.length;
for (uint256 i; i < len; i++) {
userInfo[accounts[i]].isFeeExempt = true;
}
}
function setSecondaryWallet(address newWallet) external onlyOwner {
secondaryWallet = payable(newWallet);
}
function updatePrizePool(address newAddress) public onlyOwner {
require(newAddress != address(prizePool));
PrizePool newPrizePool = PrizePool(payable(newAddress));
require(newPrizePool.owner() == address(this));
prizePool = newPrizePool;
}
function setSwapAndLiquifyEnabled(bool _enabled) external onlyOwner {
swapEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
function setSwapAtAmount(uint256 amount) external onlyOwner {
swapTokensAtAmount = amount;
}
function setMaxSwapsPerBlock(uint256 _maxSwaps) external onlyOwner {
maxSwapsPerBlock = _maxSwaps;
}
function setAllocationPercentages(uint256 _dailyAllocation, uint256 _weeklyAllocation, uint256 _monthlyAllocation) external onlyOwner {
prizePool.setAllocationPercentages(_dailyAllocation, _weeklyAllocation, _monthlyAllocation);
}
function updatePoolIntervals(
uint256[] calldata newIntervals
) external onlyOwner {
prizePool.updatePoolIntervals(newIntervals);
}
function updateEntriesPerTicket(uint256 _entriesPerTicket) external onlyOwner {
prizePool.updateEntriesPerTicket(_entriesPerTicket);
}
function updateBurnMultiplier(uint256 newMultiplier) external onlyOwner {
prizePool.updateBurnMultiplier(newMultiplier);
}
function updateGasLimit(uint32 newLimit) external onlyOwner {
prizePool.updateGasLimit(newLimit);
}
function setPrizeExcluded(address account, bool value) public onlyOwner {
userInfo[account].isPrizePoolExcluded = value;
try prizePool.setExcluded(account, value, balanceOf(account)) {} catch {}
}
function setPrizeExcludedMany(address[] memory accounts) public onlyOwner {
uint256 len = accounts.length;
for (uint256 i; i < len; i++) {
try prizePool.setExcluded(accounts[i], true, balanceOf(accounts[i])) {} catch {}
}
}
function setWhitelisted(address[] memory accounts) external onlyOwner {
if (launchedAt != 0) {
revert InvalidConfiguration();
}
_setWhitelisted(accounts);
}
function _setWhitelisted(address[] memory accounts) internal {
uint256 len = accounts.length;
for (uint256 i; i < len; i++) {
userInfo[accounts[i]].isWhitelisted = true;
}
}
function pausePrizeDraws(bool value) external onlyOwner {
prizePool.pausePrizeDraws(value);
}
function updateDrawTime(uint256 timeInHours) external onlyOwner {
prizePool.updateDrawTime(timeInHours);
}
function updateCoordinator(address _coordinator) external onlyOwner {
prizePool.updateCoordinator(_coordinator);
}
function updateKeyHash(bytes32 _keyhash) external onlyOwner {
prizePool.updateKeyHash(_keyhash);
}
function updateSubscriptionID(uint256 _subID) external onlyOwner {
prizePool.updateSubscriptionID(_subID);
}
function withdrawStuckTokens() external onlyOwner {
_updateAndSetBalance(address(this), _msgSender(), balanceOf(address(this)) - feeTokens.total);
}
function _updateAndSetBalance(address from, address to, uint256 amount) internal {
super._update(from, to, amount);
if (!userInfo[from].isPrizePoolExcluded) {
try prizePool.setBalance(from, balanceOf(from)) {} catch {}
}
if (!userInfo[to].isPrizePoolExcluded) {
try prizePool.setBalance(to, balanceOf(to)) {} catch {}
}
}
function getCirculatingSupply() external view returns (uint256) {
return totalSupply() - balanceOf(address(0xdead));
}
modifier lockTheSwap() {
swapping = 2;
_;
swapping = 1;
}
function decimals() public view virtual override returns (uint8) {
return 9;
}
function version() public pure returns (uint8) {
return 1;
}
receive() external payable {}
}
文件 6 的 23:IERC1363.sol
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
interface IERC1363 is IERC20, IERC165 {
function transferAndCall(address to, uint256 value) external returns (bool);
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
function approveAndCall(address spender, uint256 value) external returns (bool);
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
文件 7 的 23:IERC165.sol
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
文件 8 的 23:IERC20.sol
pragma solidity ^0.8.20;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
文件 9 的 23:IERC20Metadata.sol
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 10 的 23:IERC721A.sol
pragma solidity ^0.8.24;
interface IERC721A {
function totalSupply() external returns (uint256);
function ownerOf(uint256) external returns (address);
}
文件 11 的 23:ITeamFinanceLocker.sol
pragma solidity ^0.8.24;
interface ITeamFinanceLocker {
function lockToken(
address _tokenAddress,
address _withdrawalAddress,
uint256 _amount,
uint256 _unlockTime,
bool _mintNFT,
address referrer
) external payable returns (uint256 _id);
}
文件 12 的 23:IToken.sol
pragma solidity ^0.8.24;
interface IToken {
struct FeeInfo {
uint256 main;
uint256 secondary;
uint256 liquidity;
uint256 proof;
uint256 total;
}
struct ProofInfo {
address locker;
address router;
address proofWallet;
address proofStaking;
}
struct PrizePoolInfo {
address vrfCoordinator;
uint256 subscriptionId;
uint256 timerStart;
uint256 drawTimeHours;
uint256 entriesPerTicket;
}
error ExceedsMaxTxAmount();
error ExceedsMaxWalletAmount();
error InvalidConfiguration();
error TradingNotEnabled();
error TransferDelayEnabled(uint256 currentBlock, uint256 delayedUntil);
}
文件 13 的 23:IUniswapV2Factory.sol
pragma solidity >=0.5.0;
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;
}
文件 14 的 23:IUniswapV2Router01.sol
pragma solidity >=0.6.2;
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);
}
文件 15 的 23:IUniswapV2Router02.sol
pragma solidity >=0.6.2;
import './IUniswapV2Router01.sol';
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;
}
文件 16 的 23:IVRFCoordinatorV2Plus.sol
pragma solidity ^0.8.0;
import {VRFV2PlusClient} from "../libraries/VRFV2PlusClient.sol";
import {IVRFSubscriptionV2Plus} from "./IVRFSubscriptionV2Plus.sol";
interface IVRFCoordinatorV2Plus is IVRFSubscriptionV2Plus {
function requestRandomWords(VRFV2PlusClient.RandomWordsRequest calldata req) external returns (uint256 requestId);
}
文件 17 的 23:IVRFSubscriptionV2Plus.sol
pragma solidity ^0.8.0;
interface IVRFSubscriptionV2Plus {
function addConsumer(uint256 subId, address consumer) external;
function removeConsumer(uint256 subId, address consumer) external;
function cancelSubscription(uint256 subId, address to) external;
function acceptSubscriptionOwnerTransfer(uint256 subId) external;
function requestSubscriptionOwnerTransfer(uint256 subId, address newOwner) external;
function createSubscription() external returns (uint256 subId);
function getSubscription(
uint256 subId
)
external
view
returns (uint96 balance, uint96 nativeBalance, uint64 reqCount, address owner, address[] memory consumers);
function pendingRequestExists(uint256 subId) external view returns (bool);
function getActiveSubscriptionIds(uint256 startIndex, uint256 maxCount) external view returns (uint256[] memory);
function fundSubscriptionWithNative(uint256 subId) external payable;
}
文件 18 的 23:Ownable.sol
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
error OwnableUnauthorizedAccount(address account);
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 19 的 23:PrizePoolV2.sol
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@chainlink/contracts/src/v0.8/vrf/VRFConsumerBaseV2.sol";
import "@chainlink/contracts/src/v0.8/vrf/dev/libraries/VRFV2PlusClient.sol";
import {IVRFCoordinatorV2Plus} from "@chainlink/contracts/src/v0.8/vrf/dev/interfaces/IVRFCoordinatorV2Plus.sol";
import "@chainlink/contracts/src/v0.8/vrf/VRFConsumerBaseV2.sol";
error InvalidConfiguration();
error StakeLocked();
error DrawNotReady();
error RegistrationError();
error LotteryPaused();
error InsufficientStakeBalance();
event WinnerSelected(uint256 poolDraw, address winner, uint256 amount, uint256 winningNumber);
contract PrizePool is VRFConsumerBaseV2, Ownable {
using SafeERC20 for IERC20;
struct UserInfo {
uint256 staked;
uint256 burnBonus;
mapping(uint256 => uint256[]) indexes;
uint256 lastStakedTime;
}
struct Pool {
uint256 lastDrawTime;
uint256 interval;
uint256 allocPercent;
uint256 currentRewards;
}
mapping(address => UserInfo) public userInfo;
mapping(uint256 => Pool) public prizePools;
IERC20 public hype;
uint256 public DRAW_TIME_OF_DAY = 0;
uint256[] private currentPoolDraws;
uint256 public burnMultiplier = 4;
uint256 remainder;
uint256 subscriptionId;
IVRFCoordinatorV2Plus coordinator;
address vrfCoordinator;
bytes32 keyHash = 0x8af398995b04c28e9951adb9721ef74c74f93e6a478f39e7e0777be13527e7ef;
uint32 callbackGasLimit = 15000000;
uint16 requestConfirmations = 3;
bool paused = false;
uint256 public entriesPerTicket;
uint256 public totalTickets;
mapping(uint256 => uint256) public totalToUserIndexes;
mapping(uint256 => address[]) ticketList;
uint256 currListID;
constructor(
address _vrfCoordinator,
uint256 _subscriptionId,
uint8[3] memory poolAllocations,
uint256 drawTimerStart,
uint256 drawTimeHours,
uint256 _entriesPerTicket
) VRFConsumerBaseV2(_vrfCoordinator) Ownable(msg.sender) {
hype = IERC20(msg.sender);
if (poolAllocations[0] + poolAllocations[1] + poolAllocations[2] != 100) {
revert InvalidConfiguration();
}
prizePools[0] = Pool(
drawTimerStart,
1 days,
poolAllocations[0],
0
);
prizePools[1] = Pool(
drawTimerStart,
7 days,
poolAllocations[1],
0
);
prizePools[2] = Pool(
drawTimerStart,
30 days,
poolAllocations[2],
0
);
entriesPerTicket = _entriesPerTicket;
coordinator = IVRFCoordinatorV2Plus(_vrfCoordinator);
subscriptionId = _subscriptionId;
DRAW_TIME_OF_DAY = drawTimeHours * 3600;
}
function setBalance(address account, uint256 newBalance) external onlyOwner {
_setBalance(account, newBalance);
}
function _setBalance(address account, uint256 newBalance) internal {
UserInfo storage user = userInfo[account];
uint256 id = currListID;
uint256 numTickets = (newBalance + (user.staked * 2) + (user.burnBonus)) / entriesPerTicket;
if(numTickets > user.indexes[id].length) {
addUser(account, numTickets);
} else if (numTickets < user.indexes[id].length) {
removeUser(account, numTickets);
}
}
function addUser(address account, uint256 numTickets) internal {
UserInfo storage user = userInfo[account];
uint256 id = currListID;
uint256 toAdd = numTickets - user.indexes[id].length;
address[] storage list = ticketList[id];
uint256 startingIndex = list.length;
for (uint256 i; i < toAdd; i++) {
user.indexes[id].push(startingIndex + i);
list.push(account);
totalToUserIndexes[startingIndex + i] = user.indexes[id].length - 1;
}
totalTickets += toAdd;
}
function removeUser(address account, uint256 numTickets) internal {
UserInfo storage user = userInfo[account];
uint256 id = currListID;
uint256 toRemove = user.indexes[id].length - numTickets;
address[] storage _ticketList = ticketList[id];
for (uint256 i; i < toRemove; i++) {
uint256 lastTicket = _ticketList.length - 1;
uint256[] memory userIndexes = user.indexes[id];
UserInfo storage movedUser = userInfo[_ticketList[lastTicket]];
_ticketList[userIndexes[userIndexes.length - 1]] = _ticketList[lastTicket];
movedUser.indexes[id][totalToUserIndexes[lastTicket]] = userIndexes[userIndexes.length - 1];
totalToUserIndexes[userIndexes[userIndexes.length - 1]] = totalToUserIndexes[lastTicket];
user.indexes[id].pop();
_ticketList.pop();
}
totalTickets -= toRemove;
}
receive() external payable {
uint256 toDistribute = msg.value + remainder;
Pool storage pool0 = prizePools[0];
Pool storage pool1 = prizePools[1];
Pool storage pool2 = prizePools[2];
uint256 pool0Reward = (toDistribute * pool0.allocPercent) / 100;
uint256 pool1Reward = (toDistribute * pool1.allocPercent) / 100;
uint256 pool2Reward = (toDistribute * pool2.allocPercent) / 100;
pool0.currentRewards += pool0Reward;
pool1.currentRewards += pool1Reward;
pool2.currentRewards += pool2Reward;
remainder = toDistribute - pool0Reward - pool1Reward - pool2Reward;
}
function stake(uint256 amount) external {
userInfo[msg.sender].staked += amount;
userInfo[msg.sender].lastStakedTime = block.timestamp;
hype.safeTransferFrom(address(msg.sender), address(this), amount);
}
function unstake(uint256 amount) external {
if (block.timestamp < userInfo[msg.sender].lastStakedTime + 7 days) {
revert StakeLocked();
}
if (userInfo[msg.sender].staked < amount) {
revert InsufficientStakeBalance();
}
userInfo[msg.sender].staked -= amount;
hype.safeTransfer(address(msg.sender), amount);
}
function burn(address account, uint256 amount) external onlyOwner {
userInfo[account].burnBonus += amount * burnMultiplier;
}
function draw() external {
if (paused) {
revert LotteryPaused();
}
delete currentPoolDraws;
uint256 available;
uint256 currTime = block.timestamp;
uint256 timeOfDay = DRAW_TIME_OF_DAY;
for (uint256 i = 0; i < 3; i++) {
Pool storage pool = prizePools[i];
if (pool.lastDrawTime + pool.interval <= block.timestamp && pool.currentRewards != 0) {
prizePools[i].lastDrawTime = currTime - (currTime % 86400) + timeOfDay;
currentPoolDraws.push(i);
available++;
}
}
if (available == 0 || totalTickets == 0) {
revert DrawNotReady();
}
requestRandomWords(callbackGasLimit, requestConfirmations, 1);
}
function selectWinner(uint256 randomness) internal {
uint256[] memory poolIDs = currentPoolDraws;
uint256 numberOfDraws = poolIDs.length;
uint256 randNonce;
bool success;
for (uint256 i; i < numberOfDraws; i++) {
uint256 winningNumber = (uint256(keccak256(abi.encodePacked(randomness, randNonce))) % totalTickets);
randNonce++;
uint256 poolReward = prizePools[poolIDs[i]].currentRewards;
(success, ) = ticketList[currListID][winningNumber].call{value: poolReward}("");
if (success) prizePools[poolIDs[i]].currentRewards = 0;
emit WinnerSelected(poolIDs[i], ticketList[currListID][winningNumber], poolReward, winningNumber);
}
}
function requestRandomWords(
uint32 _callbackGasLimit,
uint16 _requestConfirmations,
uint32 _numWords
) internal {
bytes memory args = VRFV2PlusClient._argsToBytes(
VRFV2PlusClient.ExtraArgsV1({nativePayment: false})
);
VRFV2PlusClient.RandomWordsRequest memory request = VRFV2PlusClient
.RandomWordsRequest({
keyHash: keyHash,
subId: subscriptionId,
requestConfirmations: _requestConfirmations,
callbackGasLimit: _callbackGasLimit,
numWords: _numWords,
extraArgs: args
});
coordinator.requestRandomWords(request);
}
function fulfillRandomWords(
uint256 _requestId,
uint256[] memory randomWords
) internal override {
selectWinner(randomWords[0]);
}
function register() external {
_setBalance(msg.sender, hype.balanceOf(msg.sender));
}
function setAllocationPercentages(
uint256 pool1Allocation,
uint256 pool2Allocation,
uint256 pool3Allocation
) external onlyOwner {
_setAllocationPercentages(
pool1Allocation,
pool2Allocation,
pool3Allocation
);
}
function _setAllocationPercentages(
uint256 _pool1Allocation,
uint256 _pool2Allocation,
uint256 _pool3Allocation
) internal {
if (_pool1Allocation + _pool2Allocation + _pool3Allocation != 100) {
revert InvalidConfiguration();
}
prizePools[0].allocPercent = _pool1Allocation;
prizePools[1].allocPercent = _pool2Allocation;
prizePools[2].allocPercent = _pool3Allocation;
}
function updatePoolIntervals(
uint256[] calldata newIntervals
) external onlyOwner {
if (newIntervals.length != 3 ||
newIntervals[0] % 86400 != 0 ||
newIntervals[1] % 86400 != 0 ||
newIntervals[2] % 86400 != 0
) { revert InvalidConfiguration(); }
prizePools[0].interval = newIntervals[0];
prizePools[1].interval = newIntervals[1];
prizePools[2].interval = newIntervals[2];
}
function updateEntriesPerTicket(uint256 _entriesPerTicket) external onlyOwner {
if (_entriesPerTicket < 10**9) {
revert InvalidConfiguration();
}
entriesPerTicket = _entriesPerTicket;
currListID++;
totalTickets = 0;
}
function updateBurnMultiplier(uint256 newMultiplier) external onlyOwner {
burnMultiplier = newMultiplier;
}
function updateGasLimit(uint32 newLimit) external onlyOwner {
callbackGasLimit = newLimit;
}
function setExcluded(address account, bool value, uint256 balance) external onlyOwner {
if (value) {
removeUser(account, 0);
} else {
_setBalance(account, balance);
}
}
function pausePrizeDraws(bool value) external onlyOwner {
paused = value;
}
function updateDrawTime(uint256 timeInHours) external onlyOwner {
DRAW_TIME_OF_DAY = timeInHours * 3600;
}
function updateCoordinator(address _coordinator) external onlyOwner {
coordinator = IVRFCoordinatorV2Plus(_coordinator);
}
function updateKeyHash(bytes32 _keyHash) external onlyOwner {
keyHash = _keyHash;
}
function updateSubscriptionID(uint256 _subId) external onlyOwner {
subscriptionId = _subId;
}
function getUserPoints(address user) external view returns (uint256) {
UserInfo storage _user = userInfo[user];
return (hype.balanceOf(user) + (_user.staked * 2) + (_user.burnBonus));
}
function getUserTickets(address user) external view returns (uint256) {
return userInfo[user].indexes[currListID].length;
}
}
文件 20 的 23:SafeERC20.sol
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {Address} from "../../../utils/Address.sol";
library SafeERC20 {
error SafeERC20FailedOperation(address token);
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
文件 21 的 23:VRFConsumerBaseV2.sol
pragma solidity ^0.8.4;
abstract contract VRFConsumerBaseV2 {
error OnlyCoordinatorCanFulfill(address have, address want);
address private immutable vrfCoordinator;
constructor(address _vrfCoordinator) {
vrfCoordinator = _vrfCoordinator;
}
function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual;
function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external {
if (msg.sender != vrfCoordinator) {
revert OnlyCoordinatorCanFulfill(msg.sender, vrfCoordinator);
}
fulfillRandomWords(requestId, randomWords);
}
}
文件 22 的 23:VRFV2PlusClient.sol
pragma solidity ^0.8.4;
library VRFV2PlusClient {
bytes4 public constant EXTRA_ARGS_V1_TAG = bytes4(keccak256("VRF ExtraArgsV1"));
struct ExtraArgsV1 {
bool nativePayment;
}
struct RandomWordsRequest {
bytes32 keyHash;
uint256 subId;
uint16 requestConfirmations;
uint32 callbackGasLimit;
uint32 numWords;
bytes extraArgs;
}
function _argsToBytes(ExtraArgsV1 memory extraArgs) internal pure returns (bytes memory bts) {
return abi.encodeWithSelector(EXTRA_ARGS_V1_TAG, extraArgs);
}
}
文件 23 的 23:draft-IERC6093.sol
pragma solidity ^0.8.20;
interface IERC20Errors {
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
error ERC20InvalidSender(address sender);
error ERC20InvalidReceiver(address receiver);
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
error ERC20InvalidApprover(address approver);
error ERC20InvalidSpender(address spender);
}
interface IERC721Errors {
error ERC721InvalidOwner(address owner);
error ERC721NonexistentToken(uint256 tokenId);
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
error ERC721InvalidSender(address sender);
error ERC721InvalidReceiver(address receiver);
error ERC721InsufficientApproval(address operator, uint256 tokenId);
error ERC721InvalidApprover(address approver);
error ERC721InvalidOperator(address operator);
}
interface IERC1155Errors {
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
error ERC1155InvalidSender(address sender);
error ERC1155InvalidReceiver(address receiver);
error ERC1155MissingApprovalForAll(address operator, address owner);
error ERC1155InvalidApprover(address approver);
error ERC1155InvalidOperator(address operator);
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
{
"compilationTarget": {
"contracts/Hyperpool.sol": "Token"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"uint256","name":"_totalSupply","type":"uint256"},{"components":[{"internalType":"uint256","name":"main","type":"uint256"},{"internalType":"uint256","name":"secondary","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"proof","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"}],"internalType":"struct IToken.FeeInfo","name":"_buyFees","type":"tuple"},{"components":[{"internalType":"uint256","name":"main","type":"uint256"},{"internalType":"uint256","name":"secondary","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"proof","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"}],"internalType":"struct IToken.FeeInfo","name":"_sellFees","type":"tuple"},{"internalType":"uint256","name":"_percentToLP","type":"uint256"},{"internalType":"uint256","name":"_lpLockDuration","type":"uint256"},{"internalType":"address","name":"_secondaryWallet","type":"address"},{"internalType":"address","name":"_proofPassNFT","type":"address"},{"internalType":"address[]","name":"_whitelist","type":"address[]"},{"components":[{"internalType":"address","name":"locker","type":"address"},{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"proofWallet","type":"address"},{"internalType":"address","name":"proofStaking","type":"address"}],"internalType":"struct IToken.ProofInfo","name":"_addresses","type":"tuple"},{"components":[{"internalType":"address","name":"vrfCoordinator","type":"address"},{"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"internalType":"uint256","name":"timerStart","type":"uint256"},{"internalType":"uint256","name":"drawTimeHours","type":"uint256"},{"internalType":"uint256","name":"entriesPerTicket","type":"uint256"}],"internalType":"struct IToken.PrizePoolInfo","name":"prizePoolArgs","type":"tuple"}],"stateMutability":"payable","type":"constructor"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[],"name":"ExceedsMaxTxAmount","type":"error"},{"inputs":[],"name":"ExceedsMaxWalletAmount","type":"error"},{"inputs":[],"name":"InsufficientLiq","type":"error"},{"inputs":[],"name":"InvalidConfiguration","type":"error"},{"inputs":[],"name":"NotWhitelisted","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"TradingNotEnabled","type":"error"},{"inputs":[{"internalType":"uint256","name":"currentBlock","type":"uint256"},{"internalType":"uint256","name":"delayedUntil","type":"uint256"}],"name":"TransferDelayEnabled","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","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":"tokensAutoLiq","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ethAutoLiq","type":"uint256"}],"name":"SwapAndLiquify","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"SwapAndLiquifyEnabledUpdated","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":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"buyFees","outputs":[{"internalType":"uint256","name":"main","type":"uint256"},{"internalType":"uint256","name":"secondary","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"proof","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyTaxesSettled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"liquidityBuy","type":"uint256"},{"internalType":"uint256","name":"mainBuy","type":"uint256"},{"internalType":"uint256","name":"secondaryBuy","type":"uint256"},{"internalType":"uint256","name":"liquiditySell","type":"uint256"},{"internalType":"uint256","name":"mainSell","type":"uint256"},{"internalType":"uint256","name":"secondarySell","type":"uint256"}],"name":"changeFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"checkMaxHoldings","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeTokens","outputs":[{"internalType":"uint256","name":"main","type":"uint256"},{"internalType":"uint256","name":"secondary","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"proof","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCirculatingSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initMaxWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isWhitelistActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"launch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"launchedAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpLockDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSwapsPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWalletChanged","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":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"}],"name":"pausePrizeDraws","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"prizePool","outputs":[{"internalType":"contract PrizePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proofFeeReduced","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proofFeeRemoved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proofPassNFT","outputs":[{"internalType":"contract IERC721A","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proofStaking","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proofWallet","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"restingBuyTotal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"restingSellTotal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"secondaryWallet","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sellFees","outputs":[{"internalType":"uint256","name":"main","type":"uint256"},{"internalType":"uint256","name":"secondary","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"proof","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sellTaxesSettled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_dailyAllocation","type":"uint256"},{"internalType":"uint256","name":"_weeklyAllocation","type":"uint256"},{"internalType":"uint256","name":"_monthlyAllocation","type":"uint256"}],"name":"setAllocationPercentages","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"setCheckMaxHoldingsEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setFeeExempt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"}],"name":"setFeeExempt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxSwaps","type":"uint256"}],"name":"setMaxSwapsPerBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setPrizeExcluded","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"}],"name":"setPrizeExcludedMany","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newWallet","type":"address"}],"name":"setSecondaryWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"setSwapAndLiquifyEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setSwapAtAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"}],"name":"setWhitelisted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"swapThrottle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapTokensAtAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapping","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"value","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":"value","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"},{"inputs":[],"name":"uniswapV2Router","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMultiplier","type":"uint256"}],"name":"updateBurnMultiplier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_coordinator","type":"address"}],"name":"updateCoordinator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"timeInHours","type":"uint256"}],"name":"updateDrawTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_entriesPerTicket","type":"uint256"}],"name":"updateEntriesPerTicket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"newLimit","type":"uint32"}],"name":"updateGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_keyhash","type":"bytes32"}],"name":"updateKeyHash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"newIntervals","type":"uint256[]"}],"name":"updatePoolIntervals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAddress","type":"address"}],"name":"updatePrizePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_subID","type":"uint256"}],"name":"updateSubscriptionID","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"bool","name":"isFeeExempt","type":"bool"},{"internalType":"bool","name":"isTxLimitExempt","type":"bool"},{"internalType":"uint256","name":"lastTxBlock","type":"uint256"},{"internalType":"bool","name":"isPrizePoolExcluded","type":"bool"},{"internalType":"bool","name":"isWhitelisted","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"whitelistDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"whitelistEndTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawStuckTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]