编译器
0.8.17+commit.8df45f5f
文件 1 的 8:Context.sol
pragma solidity ^0.8.0;
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;
}
}
文件 2 的 8:ERC20.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => 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 override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
文件 3 的 8:IERC20.sol
pragma solidity ^0.8.0;
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 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
文件 4 的 8:IERC20Metadata.sol
pragma solidity ^0.8.0;
import "../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);
}
文件 5 的 8:LibCommon.sol
pragma solidity 0.8.17;
library LibCommon {
error ETHTransferFailed();
error ZeroAddress();
error TransferFailed();
function safeTransferETH(address to, uint256 amount) internal {
assembly {
if iszero(call(gas(), to, amount, 0, 0, 0, 0)) {
mstore(0x00, 0xb12d13eb)
revert(0x1c, 0x04)
}
}
}
function validateAddress(address addr) internal pure {
assembly {
if iszero(shl(96, addr)) {
mstore(0x00, 0xd92e233d)
revert(0x1c, 0x04)
}
}
}
function safeTransferFrom(
address tokenAddress,
address from,
address to,
uint256 amount
) internal returns (bool) {
(bool success, bytes memory data) = tokenAddress.call(
abi.encodeWithSignature(
"transferFrom(address,address,uint256)",
from,
to,
amount
)
);
if (!success) {
if (data.length != 0) {
assembly {
let returndata_size := mload(data)
revert(add(32, data), returndata_size)
}
} else {
revert TransferFailed();
}
}
return true;
}
function safeTransfer(
address tokenAddress,
address to,
uint256 amount
) internal returns (bool) {
(bool success, bytes memory data) = tokenAddress.call(
abi.encodeWithSignature("transfer(address,uint256)", to, amount)
);
if (!success) {
if (data.length != 0) {
assembly {
let returndata_size := mload(data)
revert(add(32, data), returndata_size)
}
} else {
revert TransferFailed();
}
}
return true;
}
}
文件 6 的 8:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
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);
}
}
文件 7 的 8:ReflectiveV3ERC20.sol
pragma solidity 0.8.17;
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { LibCommon } from "./lib/LibCommon.sol";
abstract contract ReflectiveV3ERC20 is ERC20 {
uint256 private constant BPS_DIVISOR = 10_000;
uint256 public constant MAX_REWARDS_EXCLUSION_LIMIT = 100;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
uint256 private constant UINT_256_MAX = type(uint256).max;
uint256 private _rTotal;
uint256 private _tFeeTotal;
uint256 public tFeeBPS;
bool private immutable isReflective;
mapping (address => bool) private _isRewardsExcluded;
address[] public rewardsExcluded;
event ExcludedFromRewards(address indexed account);
event IncludedInRewards(address indexed account);
error TokenIsNotReflective();
error TotalReflectionTooSmall();
error ZeroTransferError();
error BurningNotEnabled();
error ERC20InsufficientBalance(
address recipient,
uint256 fromBalance,
uint256 balance
);
error AlreadyExcludedFromRewards();
error AlreadyIncludedInRewards();
error ReachedMaxRewardExclusionLimit();
function _tTotal() public view virtual returns (uint256) {
return totalSupply();
}
constructor(
string memory name_,
string memory symbol_,
address tokenOwner,
uint256 totalSupply_,
uint8 decimalsToSet,
uint256 tFeeBPS_,
bool isReflective_
) ERC20(name_, symbol_) {
if (totalSupply_ != 0) {
super._mint(tokenOwner, totalSupply_ * 10 ** decimalsToSet);
_rTotal = (UINT_256_MAX - (UINT_256_MAX % totalSupply_));
}
_rOwned[tokenOwner] = _rTotal;
tFeeBPS = tFeeBPS_;
isReflective = isReflective_;
}
function balanceOf(address account) public view override returns (uint256) {
if (isReflective) {
if (_isRewardsExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
} else {
return super.balanceOf(account);
}
}
function transferFrom(
address from,
address to,
uint256 value
) public virtual override returns (bool) {
address spender = super._msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
function transfer(
address to,
uint256 value
) public virtual override returns (bool) {
address owner = super._msgSender();
_transfer(owner, to, value);
return true;
}
function _transfer(
address from,
address to,
uint256 amount
) internal override {
if (isReflective) {
LibCommon.validateAddress(from);
LibCommon.validateAddress(to);
if (amount == 0) {
revert ZeroTransferError();
}
if (_isRewardsExcluded[from] && !_isRewardsExcluded[to]) {
_transferFromExcluded(from, to, amount);
} else if (!_isRewardsExcluded[from] && _isRewardsExcluded[to]) {
_transferToExcluded(from, to, amount);
} else if (!_isRewardsExcluded[from] && !_isRewardsExcluded[to]) {
_transferStandard(from, to, amount);
} else if (_isRewardsExcluded[from] && _isRewardsExcluded[to]) {
_transferBothExcluded(from, to, amount);
} else {
_transferStandard(from, to, amount);
}
} else {
super._transfer(from, to, amount);
}
}
function _burn(address account, uint256 value) internal override {
if (isReflective) {
revert BurningNotEnabled();
} else {
super._burn(account, value);
}
}
function _setReflectionFee(uint256 _tFeeBPS) internal {
if (!isReflective) {
revert TokenIsNotReflective();
}
tFeeBPS = _tFeeBPS;
}
function tokenFromReflection(uint256 rAmount) public view returns (uint256) {
if (rAmount > _rTotal) {
revert TotalReflectionTooSmall();
}
uint256 currentRate = _getRate();
return rAmount / currentRate;
}
function _excludeFromRewards(
address account
) internal {
if (!isReflective) {
revert TokenIsNotReflective();
}
if (_isRewardsExcluded[account]) {
revert AlreadyExcludedFromRewards();
}
if (rewardsExcluded.length >= MAX_REWARDS_EXCLUSION_LIMIT) {
revert ReachedMaxRewardExclusionLimit();
}
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isRewardsExcluded[account] = true;
rewardsExcluded.push(account);
emit ExcludedFromRewards(account);
}
function _includeInRewards(address account) internal {
if (!isReflective) {
revert TokenIsNotReflective();
}
if (!_isRewardsExcluded[account]) {
revert AlreadyIncludedInRewards();
}
for (uint256 i = 0; i < rewardsExcluded.length; i++) {
if (rewardsExcluded[i] == account) {
rewardsExcluded[i] = rewardsExcluded[rewardsExcluded.length - 1];
_isRewardsExcluded[account] = false;
_tOwned[account] = 0;
rewardsExcluded.pop();
emit IncludedInRewards(account);
break;
}
}
}
function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private {
uint256 tFee = calculateFee(tAmount, sender, recipient);
uint256 tTransferAmount = tAmount - tFee;
(uint256 rAmount, uint256 rFee, uint256 rTransferAmount) = _getRValues(
tAmount,
tFee,
tTransferAmount
);
if (tAmount != 0) {
_rUpdate(sender, recipient, rAmount, rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tAmount);
}
}
function _transferFromExcluded(
address sender,
address recipient,
uint256 tAmount
) private {
uint256 tFee = calculateFee(tAmount, sender, recipient);
uint256 tTransferAmount = tAmount - tFee;
(uint256 rAmount, uint256 rFee, uint256 rTransferAmount) = _getRValues(
tAmount,
tFee,
tTransferAmount
);
if (tAmount != 0) {
_rUpdate(sender, recipient, rAmount, rTransferAmount);
_tOwned[sender] = _tOwned[sender] - (tAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tAmount);
}
}
function _transferToExcluded(
address sender,
address recipient,
uint256 tAmount
) private {
uint256 tFee = calculateFee(tAmount, sender, recipient);
uint256 tTransferAmount = tAmount - tFee;
(uint256 rAmount, uint256 rFee, uint256 rTransferAmount) = _getRValues(
tAmount,
tFee,
tTransferAmount
);
if (tAmount != 0) {
_rUpdate(sender, recipient, rAmount, rTransferAmount);
_tOwned[recipient] = _tOwned[recipient] + (tTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tAmount);
}
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 tFee = calculateFee(tAmount, sender, recipient);
uint256 tTransferAmount = tAmount - tFee;
(uint256 rAmount, uint256 rFee, uint256 rTransferAmount) = _getRValues(
tAmount,
tFee,
tTransferAmount
);
if (tAmount != 0) {
_rUpdate(sender, recipient, rAmount, rTransferAmount);
_tOwned[sender] = _tOwned[sender] - (tAmount);
_tOwned[recipient] = _tOwned[recipient] + (tTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tAmount);
}
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal - rFee;
_tFeeTotal = _tFeeTotal + tFee;
}
function calculateFee(uint256 amount, address sender, address recipient) private view returns (uint256) {
if (_isRewardsExcluded[sender] || _isRewardsExcluded[recipient]) {
return 0;
} else {
return (amount * tFeeBPS) / BPS_DIVISOR;
}
}
function _transferNonReflectedTax(
address from,
address to,
uint256 tAmount
) internal {
if (isReflective) {
if (tAmount != 0) {
uint256 currentRate = _getRate();
uint256 rAmount = tAmount * currentRate;
_rUpdate(from, to, rAmount, rAmount);
emit Transfer(from, to, tAmount);
}
} else {
super._transfer(from, to, tAmount);
}
}
function _getRValues(
uint256 tAmount,
uint256 tFee,
uint256 tTransferAmount
) private view returns (uint256, uint256, uint256) {
uint256 currentRate = _getRate();
uint256 rAmount = tAmount * currentRate;
uint256 rFee = tFee * currentRate;
uint256 rTransferAmount = tTransferAmount * currentRate;
return (rAmount, rFee, rTransferAmount);
}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply / tSupply;
}
function _getCurrentSupply() private view returns (uint256, uint256) {
return (_rTotal, _tTotal());
}
function _rUpdate(
address sender,
address recipient,
uint256 rSubAmount,
uint256 rTransferAmount
) private {
uint256 fromBalance = _rOwned[sender];
if (fromBalance < rSubAmount) {
revert ERC20InsufficientBalance(recipient, fromBalance, rSubAmount);
}
_rOwned[sender] = _rOwned[sender] - rSubAmount;
_rOwned[recipient] = _rOwned[recipient] + rTransferAmount;
}
}
文件 8 的 8:YbetsCasinoBonus.sol
pragma solidity 0.8.17;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { LibCommon } from "./lib/LibCommon.sol";
import { ReflectiveV3ERC20 } from "./ReflectiveV3ERC20.sol";
contract YbetsCasinoBonus is ReflectiveV3ERC20, Ownable {
uint256 private constant MAX_BPS_AMOUNT = 10_000;
uint256 private constant MAX_ALLOWED_BPS = 2_000;
uint256 public constant MAX_EXCLUSION_LIMIT = 100;
string public constant VERSION = "defi_v_1_fixed_supply";
string public constant CONTRACT_NAME = "YbetsCasinoBonus";
bytes32 public constant CONTRACT_HASH = 0x0fceafefe5f1b31b56e93437f48fb514951a168688f1a27ef59dee9e0818e206;
string public initialDocumentUri;
string public documentUri;
uint256 public immutable initialSupply;
uint256 public immutable initialMaxTokenAmountPerAddress;
uint256 public maxTokenAmountPerAddress;
mapping(address => bool) public isFeesAndLimitsExcluded;
address[] public feesAndLimitsExcluded;
struct ERC20ConfigProps {
bool _isBurnable;
bool _isDocumentAllowed;
bool _isMaxAmountOfTokensSet;
bool _isTaxable;
bool _isDeflationary;
bool _isReflective;
}
ERC20ConfigProps private configProps;
address public immutable initialTokenOwner;
uint8 private immutable _decimals;
address public taxAddress;
uint256 public taxBPS;
uint256 public deflationBPS;
event DocumentUriSet(string newDocUri);
event MaxTokenAmountPerSet(uint256 newMaxTokenAmount);
event TaxConfigSet(address indexed _taxAddress, uint256 indexed _taxBPS);
event DeflationConfigSet(uint256 indexed _deflationBPS);
event ReflectionConfigSet(uint256 indexed _feeBPS);
event ExcludeFromFeesAndLimits(address indexed account);
event IncludedInFeesAndLimits(address indexed account);
error InvalidMaxTokenAmount(uint256 maxTokenAmount);
error InvalidDecimals(uint8 decimals);
error MaxTokenAmountPerAddrLtPrevious();
error DestBalanceExceedsMaxAllowed(address addr);
error DocumentUriNotAllowed();
error MaxTokenAmountNotAllowed();
error TokenIsNotTaxable();
error TokenIsNotDeflationary();
error InvalidTotalBPS(uint256 bps);
error InvalidReflectiveConfig();
error AlreadyExcludedFromFeesAndLimits();
error AlreadyIncludedInFeesAndLimits();
error ReachedMaxExclusionLimit();
constructor(
string memory name_,
string memory symbol_,
uint256 initialSupplyToSet,
uint8 decimalsToSet,
address tokenOwner,
ERC20ConfigProps memory customConfigProps,
string memory newDocumentUri,
address _taxAddress,
uint256[3] memory bpsParams,
uint256[1] memory amountParams
)
ReflectiveV3ERC20(
name_,
symbol_,
tokenOwner,
initialSupplyToSet,
decimalsToSet,
initialSupplyToSet != 0 ? bpsParams[2] : 0,
customConfigProps._isReflective
)
{
if (
(customConfigProps._isReflective &&
(customConfigProps._isBurnable ||
customConfigProps._isDeflationary)) ||
(!customConfigProps._isReflective && bpsParams[2] != 0)
) {
revert InvalidReflectiveConfig();
}
if (customConfigProps._isMaxAmountOfTokensSet) {
if (amountParams[0] == 0) {
revert InvalidMaxTokenAmount(amountParams[0]);
}
}
if (decimalsToSet > 18) {
revert InvalidDecimals(decimalsToSet);
}
bpsInitChecks(customConfigProps, bpsParams, _taxAddress);
LibCommon.validateAddress(tokenOwner);
taxAddress = _taxAddress;
taxBPS = bpsParams[0];
deflationBPS = bpsParams[1];
initialSupply = initialSupplyToSet;
initialMaxTokenAmountPerAddress = amountParams[0];
initialDocumentUri = newDocumentUri;
initialTokenOwner = tokenOwner;
_decimals = decimalsToSet;
configProps = customConfigProps;
documentUri = newDocumentUri;
maxTokenAmountPerAddress = amountParams[0];
if (tokenOwner != msg.sender) {
transferOwnership(tokenOwner);
}
}
function bpsInitChecks(
ERC20ConfigProps memory customConfigProps,
uint256[3] memory bpsParams,
address _taxAddress
) private pure {
uint256 totalBPS = 0;
if (customConfigProps._isTaxable) {
LibCommon.validateAddress(_taxAddress);
totalBPS += bpsParams[0];
}
if (customConfigProps._isDeflationary) {
totalBPS += bpsParams[1];
}
if (customConfigProps._isReflective) {
totalBPS += bpsParams[2];
}
if (totalBPS > MAX_ALLOWED_BPS) {
revert InvalidTotalBPS(totalBPS);
}
}
function getFeesAndLimitsExclusionList() external view returns (address[] memory) {
return feesAndLimitsExcluded;
}
function isBurnable() public view returns (bool) {
return configProps._isBurnable;
}
function getRewardsExclusionList() public view returns (address[] memory) {
return rewardsExcluded;
}
function isMaxAmountOfTokensSet() public view returns (bool) {
return configProps._isMaxAmountOfTokensSet;
}
function isDocumentUriAllowed() public view returns (bool) {
return configProps._isDocumentAllowed;
}
function decimals() public view virtual override returns (uint8) {
return _decimals;
}
function isTaxable() public view returns (bool) {
return configProps._isTaxable;
}
function isDeflationary() public view returns (bool) {
return configProps._isDeflationary;
}
function isReflective() public view returns (bool) {
return configProps._isReflective;
}
function setDocumentUri(string memory newDocumentUri) external onlyOwner {
if (!isDocumentUriAllowed()) {
revert DocumentUriNotAllowed();
}
documentUri = newDocumentUri;
emit DocumentUriSet(newDocumentUri);
}
function setMaxTokenAmountPerAddress(
uint256 newMaxTokenAmount
) external onlyOwner {
if (!isMaxAmountOfTokensSet()) {
revert MaxTokenAmountNotAllowed();
}
if (newMaxTokenAmount <= maxTokenAmountPerAddress) {
revert MaxTokenAmountPerAddrLtPrevious();
}
maxTokenAmountPerAddress = newMaxTokenAmount;
emit MaxTokenAmountPerSet(newMaxTokenAmount);
}
function setReflectionConfig(uint256 _feeBPS) external onlyOwner {
if (!isReflective()) {
revert TokenIsNotReflective();
}
super._setReflectionFee(_feeBPS);
emit ReflectionConfigSet(_feeBPS);
}
function setTaxConfig(
address _taxAddress,
uint256 _taxBPS
) external onlyOwner {
if (!isTaxable()) {
revert TokenIsNotTaxable();
}
uint256 totalBPS = deflationBPS + tFeeBPS + _taxBPS;
if (totalBPS > MAX_ALLOWED_BPS) {
revert InvalidTotalBPS(totalBPS);
}
LibCommon.validateAddress(_taxAddress);
taxAddress = _taxAddress;
taxBPS = _taxBPS;
emit TaxConfigSet(_taxAddress, _taxBPS);
}
function setDeflationConfig(uint256 _deflationBPS) external onlyOwner {
if (!isDeflationary()) {
revert TokenIsNotDeflationary();
}
uint256 totalBPS = deflationBPS + tFeeBPS + _deflationBPS;
if (totalBPS > MAX_ALLOWED_BPS) {
revert InvalidTotalBPS(totalBPS);
}
deflationBPS = _deflationBPS;
emit DeflationConfigSet(_deflationBPS);
}
function transfer(
address to,
uint256 amount
) public virtual override returns (bool) {
uint256 taxAmount = _taxAmount(msg.sender, to, amount);
uint256 deflationAmount = _deflationAmount(msg.sender, to, amount);
uint256 amountToTransfer = amount - taxAmount - deflationAmount;
if (isMaxAmountOfTokensSet() && !isFeesAndLimitsExcluded[to]) {
if (balanceOf(to) + amountToTransfer > maxTokenAmountPerAddress) {
revert DestBalanceExceedsMaxAllowed(to);
}
}
if (taxAmount != 0) {
_transferNonReflectedTax(msg.sender, taxAddress, taxAmount);
}
if (deflationAmount != 0) {
_burn(msg.sender, deflationAmount);
}
return super.transfer(to, amountToTransfer);
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
uint256 taxAmount = _taxAmount(from, to, amount);
uint256 deflationAmount = _deflationAmount(from, to, amount);
uint256 amountToTransfer = amount - taxAmount - deflationAmount;
if (isMaxAmountOfTokensSet() && !isFeesAndLimitsExcluded[to]) {
if (balanceOf(to) + amountToTransfer > maxTokenAmountPerAddress) {
revert DestBalanceExceedsMaxAllowed(to);
}
}
if (taxAmount != 0) {
_transferNonReflectedTax(from, taxAddress, taxAmount);
}
if (deflationAmount != 0) {
_burn(from, deflationAmount);
}
return super.transferFrom(from, to, amountToTransfer);
}
function burn(uint256 amount) external onlyOwner {
if (!isBurnable()) {
revert BurningNotEnabled();
}
_burn(msg.sender, amount);
}
function renounceOwnership() public override onlyOwner {
super.renounceOwnership();
}
function transferOwnership(address newOwner) public override onlyOwner {
super.transferOwnership(newOwner);
}
function excludeFromFeesAndLimits(
address account
) external onlyOwner {
if (isFeesAndLimitsExcluded[account]) {
revert AlreadyExcludedFromFeesAndLimits();
}
if (feesAndLimitsExcluded.length >= MAX_EXCLUSION_LIMIT) {
revert ReachedMaxExclusionLimit();
}
isFeesAndLimitsExcluded[account] = true;
feesAndLimitsExcluded.push(account);
emit ExcludeFromFeesAndLimits(account);
}
function excludeFromRewards(address account) external onlyOwner {
super._excludeFromRewards(account);
}
function includeInFeesAndLimits(address account) external onlyOwner() {
if (!isFeesAndLimitsExcluded[account]) {
revert AlreadyIncludedInFeesAndLimits();
}
for (uint256 i = 0; i < feesAndLimitsExcluded.length; i++) {
if (feesAndLimitsExcluded[i] == account) {
feesAndLimitsExcluded[i] = feesAndLimitsExcluded[feesAndLimitsExcluded.length - 1];
isFeesAndLimitsExcluded[account] = false;
feesAndLimitsExcluded.pop();
emit IncludedInFeesAndLimits(account);
break;
}
}
}
function includeInRewards(address account) external onlyOwner() {
super._includeInRewards(account);
}
function _taxAmount(
address sender,
address recipient,
uint256 amount
) internal view returns (uint256 taxAmount) {
taxAmount = 0;
if (taxBPS != 0 && sender != taxAddress && !isFeesAndLimitsExcluded[sender] && !isFeesAndLimitsExcluded[recipient]) {
taxAmount = (amount * taxBPS) / MAX_BPS_AMOUNT;
}
}
function _deflationAmount(
address sender,
address recipient,
uint256 amount
) internal view returns (uint256 deflationAmount) {
deflationAmount = 0;
if (deflationBPS != 0 && !isFeesAndLimitsExcluded[sender] && !isFeesAndLimitsExcluded[recipient]) {
deflationAmount = (amount * deflationBPS) / MAX_BPS_AMOUNT;
}
}
}
{
"compilationTarget": {
"contracts/YbetsCasinoBonus.sol": "YbetsCasinoBonus"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"uint256","name":"initialSupplyToSet","type":"uint256"},{"internalType":"uint8","name":"decimalsToSet","type":"uint8"},{"internalType":"address","name":"tokenOwner","type":"address"},{"components":[{"internalType":"bool","name":"_isBurnable","type":"bool"},{"internalType":"bool","name":"_isDocumentAllowed","type":"bool"},{"internalType":"bool","name":"_isMaxAmountOfTokensSet","type":"bool"},{"internalType":"bool","name":"_isTaxable","type":"bool"},{"internalType":"bool","name":"_isDeflationary","type":"bool"},{"internalType":"bool","name":"_isReflective","type":"bool"}],"internalType":"struct YbetsCasinoBonus.ERC20ConfigProps","name":"customConfigProps","type":"tuple"},{"internalType":"string","name":"newDocumentUri","type":"string"},{"internalType":"address","name":"_taxAddress","type":"address"},{"internalType":"uint256[3]","name":"bpsParams","type":"uint256[3]"},{"internalType":"uint256[1]","name":"amountParams","type":"uint256[1]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyExcludedFromFeesAndLimits","type":"error"},{"inputs":[],"name":"AlreadyExcludedFromRewards","type":"error"},{"inputs":[],"name":"AlreadyIncludedInFeesAndLimits","type":"error"},{"inputs":[],"name":"AlreadyIncludedInRewards","type":"error"},{"inputs":[],"name":"BurningNotEnabled","type":"error"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"DestBalanceExceedsMaxAllowed","type":"error"},{"inputs":[],"name":"DocumentUriNotAllowed","type":"error"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"fromBalance","type":"uint256"},{"internalType":"uint256","name":"balance","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"uint8","name":"decimals","type":"uint8"}],"name":"InvalidDecimals","type":"error"},{"inputs":[{"internalType":"uint256","name":"maxTokenAmount","type":"uint256"}],"name":"InvalidMaxTokenAmount","type":"error"},{"inputs":[],"name":"InvalidReflectiveConfig","type":"error"},{"inputs":[{"internalType":"uint256","name":"bps","type":"uint256"}],"name":"InvalidTotalBPS","type":"error"},{"inputs":[],"name":"MaxTokenAmountNotAllowed","type":"error"},{"inputs":[],"name":"MaxTokenAmountPerAddrLtPrevious","type":"error"},{"inputs":[],"name":"ReachedMaxExclusionLimit","type":"error"},{"inputs":[],"name":"ReachedMaxRewardExclusionLimit","type":"error"},{"inputs":[],"name":"TokenIsNotDeflationary","type":"error"},{"inputs":[],"name":"TokenIsNotReflective","type":"error"},{"inputs":[],"name":"TokenIsNotTaxable","type":"error"},{"inputs":[],"name":"TotalReflectionTooSmall","type":"error"},{"inputs":[],"name":"ZeroTransferError","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":"uint256","name":"_deflationBPS","type":"uint256"}],"name":"DeflationConfigSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"newDocUri","type":"string"}],"name":"DocumentUriSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"ExcludeFromFeesAndLimits","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"ExcludedFromRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"IncludedInFeesAndLimits","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"IncludedInRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newMaxTokenAmount","type":"uint256"}],"name":"MaxTokenAmountPerSet","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":true,"internalType":"uint256","name":"_feeBPS","type":"uint256"}],"name":"ReflectionConfigSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_taxAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"_taxBPS","type":"uint256"}],"name":"TaxConfigSet","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":[],"name":"CONTRACT_HASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONTRACT_NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_EXCLUSION_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_REWARDS_EXCLUSION_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_tTotal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"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":"amount","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":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"deflationBPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"documentUri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"excludeFromFeesAndLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"excludeFromRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"feesAndLimitsExcluded","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFeesAndLimitsExclusionList","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRewardsExclusionList","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"includeInFeesAndLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"includeInRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialDocumentUri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialMaxTokenAmountPerAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialTokenOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isBurnable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isDeflationary","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isDocumentUriAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isFeesAndLimitsExcluded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isMaxAmountOfTokensSet","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isReflective","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isTaxable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTokenAmountPerAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardsExcluded","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_deflationBPS","type":"uint256"}],"name":"setDeflationConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newDocumentUri","type":"string"}],"name":"setDocumentUri","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMaxTokenAmount","type":"uint256"}],"name":"setMaxTokenAmountPerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_feeBPS","type":"uint256"}],"name":"setReflectionConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_taxAddress","type":"address"},{"internalType":"uint256","name":"_taxBPS","type":"uint256"}],"name":"setTaxConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tFeeBPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxBPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"rAmount","type":"uint256"}],"name":"tokenFromReflection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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"}]