Verified contractExactMIT
SuuperToken
Address0x00d721f40b4a47714ef968eb9d2bcd4a8ec12ad6
- Balance
0 ETH
- Transactions
5
- Compiler
solc 0.8.28
- Same code
Only this contract
Details
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,006,393
- Creation transaction
- 0xef7c23c561…ec3edd385b
9 files
- project/contracts/SuuperToken.solmain27.79 KB
- npm/@openzeppelin/[email protected]/access/Ownable.sol3.1 KB
- npm/@openzeppelin/[email protected]/access/Ownable2Step.sol2.48 KB
- npm/@openzeppelin/[email protected]/interfaces/draft-IERC6093.sol6.54 KB
- npm/@openzeppelin/[email protected]/token/ERC20/ERC20.sol10.8 KB
- npm/@openzeppelin/[email protected]/token/ERC20/IERC20.sol2.78 KB
- npm/@openzeppelin/[email protected]/token/ERC20/extensions/ERC20Burnable.sol1.18 KB
- npm/@openzeppelin/[email protected]/token/ERC20/extensions/IERC20Metadata.sol684 B
- npm/@openzeppelin/[email protected]/utils/Context.sol963 B
project/contracts/SuuperToken.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/Ownable2Step.sol";
interface IUniswapV2Router02 {
function factory() external view returns (address);
function WETH() external view returns (address);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function getAmountsOut(
uint256 amountIn,
address[] calldata path
) external view returns (uint256[] memory amounts);
}
contract SuuperToken is ERC20, ERC20Burnable, Ownable2Step {
uint256 public constant INITIAL_SUPPLY = 350_000_000 ether;
uint256 private constant WAD = 1e18;
uint256 public constant REBASE_INTERVAL = 15 minutes;
uint256 public constant PHASE_1_END = 35_040;
uint256 public constant PHASE_2_END = 52_560;
uint256 public constant PHASE_3_END = 280_320;
uint256 public constant PHASE_1_RATE = 100_000_000_000_000;
uint256 public constant PHASE_2_RATE = 12_000_000_000_000;
uint256 public constant PHASE_3_RATE = 8_000_000_000_000;
uint256 public constant PHASE_4_RATE = 200_000_000_000;
uint256 public rebaseCount;
uint256 public lastRebaseTime;
uint256 public rebaseIndex = WAD;
uint256 public totalShares;
uint256 public excludedSupply;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _excludedBalances;
mapping(address => bool) public excludedFromRebase;
uint256 public constant PRESALE_ALLOCATION = 105_000_000 ether;
uint256 public constant LIQUIDITY_ALLOCATION = 70_000_000 ether;
uint256 public constant STAKING_ALLOCATION = 52_500_000 ether;
uint256 public constant MARKETING_ALLOCATION = 35_000_000 ether;
uint256 public constant TREASURY_ALLOCATION = 17_500_000 ether;
uint256 public constant TEAM_ALLOCATION = 35_000_000 ether;
uint256 public constant DEVELOPMENT_ALLOCATION = 17_500_000 ether;
uint256 public constant ECOSYSTEM_ALLOCATION = 17_500_000 ether;
address public immutable treasury;
address public immutable presaleContract;
address public immutable stakingWallet;
address public immutable marketingWallet;
address public immutable teamWallet;
address public immutable developmentWallet;
address public immutable ecosystemWallet;
uint256 public constant BUY_TAX_BPS = 300;
uint256 public constant SELL_TAX_BPS = 300;
uint256 public constant TAX_TREASURY_BPS = 100;
uint256 public constant TAX_BURN_BPS = 100;
uint256 public constant TAX_LIQUIDITY_BPS = 100;
uint256 public constant BPS_DENOMINATOR = 10_000;
address public constant TAX_TREASURY =
0x3E9B5b053b22045aA323317620Cb1164a1B3AD08;
mapping(address => bool) public taxExempt;
mapping(address => bool) public automatedMarketMakerPairs;
IUniswapV2Router02 public liquidityRouter;
address public liquidityPair;
bool public autoLiquidityEnabled;
bool private _inSwap;
uint256 public constant LIQUIDITY_THRESHOLD = 50_000 ether;
uint256 public constant AUTO_LIQUIDITY_SLIPPAGE_BPS = 500;
uint256 public liquidityTokensPending;
uint256 public totalTaxCollected;
uint256 public totalTaxBurned;
uint256 public totalLiquidityTokens;
event Rebase(
uint256 indexed rebaseCount,
uint256 rebaseIndex,
uint256 totalSupply
);
event RebaseExclusionUpdated(
address indexed account,
bool excluded
);
event TaxExemptionUpdated(
address indexed account,
bool exempt
);
event AutomatedMarketMakerPairUpdated(
address indexed pair,
bool value
);
event LiquidityRouterConfigured(
address indexed router,
address indexed pair
);
event AutoLiquidityStatusUpdated(bool enabled);
event TaxProcessed(
address indexed from,
address indexed to,
uint256 totalTax,
uint256 treasuryAmount,
uint256 burnAmount,
uint256 liquidityAmount
);
event LiquidityProcessed(
uint256 tokenAmount,
uint256 ethAmount
);
constructor(
address initialOwner,
address _treasury,
address _presaleContract,
address _stakingWallet,
address _marketingWallet,
address _teamWallet,
address _developmentWallet,
address _ecosystemWallet
)
ERC20("Suuper Protocol", "SUUPER")
Ownable(initialOwner)
{
require(initialOwner != address(0), "Invalid owner");
require(_treasury != address(0), "Invalid treasury");
require(_presaleContract != address(0), "Invalid presale");
require(_stakingWallet != address(0), "Invalid staking wallet");
require(_marketingWallet != address(0), "Invalid marketing wallet");
require(_teamWallet != address(0), "Invalid team wallet");
require(_developmentWallet != address(0), "Invalid development wallet");
require(_ecosystemWallet != address(0), "Invalid ecosystem wallet");
require(
TAX_TREASURY_BPS + TAX_BURN_BPS + TAX_LIQUIDITY_BPS ==
BUY_TAX_BPS,
"Invalid buy tax"
);
require(
TAX_TREASURY_BPS + TAX_BURN_BPS + TAX_LIQUIDITY_BPS ==
SELL_TAX_BPS,
"Invalid sell tax"
);
require(
_treasury != TAX_TREASURY,
"Treasuries must differ"
);
treasury = _treasury;
presaleContract = _presaleContract;
stakingWallet = _stakingWallet;
marketingWallet = _marketingWallet;
teamWallet = _teamWallet;
developmentWallet = _developmentWallet;
ecosystemWallet = _ecosystemWallet;
lastRebaseTime = block.timestamp;
_validateTokenomics();
_initializeAllocations(initialOwner);
_setRebaseExcluded(_presaleContract, true);
_setRebaseExcluded(address(this), true);
_setRebaseExcluded(TAX_TREASURY, true);
_initializeTaxExemptions(initialOwner);
}
receive() external payable {}
function _validateTokenomics() private pure {
uint256 totalAllocation =
PRESALE_ALLOCATION +
LIQUIDITY_ALLOCATION +
STAKING_ALLOCATION +
MARKETING_ALLOCATION +
TREASURY_ALLOCATION +
TEAM_ALLOCATION +
DEVELOPMENT_ALLOCATION +
ECOSYSTEM_ALLOCATION;
require(
totalAllocation == INITIAL_SUPPLY,
"Invalid tokenomics"
);
}
function _initializeAllocations(address initialOwner) private {
_createExcludedBalance(
initialOwner,
PRESALE_ALLOCATION + LIQUIDITY_ALLOCATION
);
_createExcludedBalance(
stakingWallet,
STAKING_ALLOCATION
);
_createExcludedBalance(
marketingWallet,
MARKETING_ALLOCATION
);
_createExcludedBalance(
treasury,
TREASURY_ALLOCATION
);
_createExcludedBalance(
teamWallet,
TEAM_ALLOCATION
);
_createExcludedBalance(
developmentWallet,
DEVELOPMENT_ALLOCATION
);
_createExcludedBalance(
ecosystemWallet,
ECOSYSTEM_ALLOCATION
);
}
function _createExcludedBalance(
address account,
uint256 amount
) private {
require(account != address(0), "Invalid account");
require(!excludedFromRebase[account], "Account already excluded");
excludedFromRebase[account] = true;
_excludedBalances[account] = amount;
excludedSupply += amount;
emit Transfer(address(0), account, amount);
emit RebaseExclusionUpdated(account, true);
}
function _initializeTaxExemptions(address initialOwner) private {
_setTaxExempt(initialOwner, true);
_setTaxExempt(presaleContract, true);
_setTaxExempt(address(this), true);
_setTaxExempt(treasury, true);
_setTaxExempt(TAX_TREASURY, true);
}
function fundPresale() external onlyOwner {
require(
balanceOf(owner()) >= PRESALE_ALLOCATION,
"Insufficient presale allocation"
);
_moveWithoutTax(
owner(),
presaleContract,
PRESALE_ALLOCATION
);
}
function currentPhase() public view returns (uint256) {
if (rebaseCount < PHASE_1_END) return 1;
if (rebaseCount < PHASE_2_END) return 2;
if (rebaseCount < PHASE_3_END) return 3;
return 4;
}
function currentRewardRate() public view returns (uint256) {
uint256 phase = currentPhase();
if (phase == 1) return PHASE_1_RATE;
if (phase == 2) return PHASE_2_RATE;
if (phase == 3) return PHASE_3_RATE;
return PHASE_4_RATE;
}
function sharesOf(address account) external view returns (uint256) {
return _shares[account];
}
function excludedBalanceOf(
address account
) external view returns (uint256) {
return _excludedBalances[account];
}
function balanceOf(
address account
) public view override returns (uint256) {
if (excludedFromRebase[account]) {
return _excludedBalances[account];
}
return _amountForShares(_shares[account]);
}
function totalSupply() public view override returns (uint256) {
return _amountForShares(totalShares) + excludedSupply;
}
function checkRebase() external {
rebase();
}
function rebase() public {
if (
block.timestamp <
lastRebaseTime + REBASE_INTERVAL
) {
return;
}
uint256 periods =
(block.timestamp - lastRebaseTime) /
REBASE_INTERVAL;
if (periods == 0) return;
uint256 remaining = periods;
while (remaining > 0) {
uint256 rate = currentRewardRate();
uint256 nextBoundary;
if (rebaseCount < PHASE_1_END) {
nextBoundary = PHASE_1_END;
} else if (rebaseCount < PHASE_2_END) {
nextBoundary = PHASE_2_END;
} else if (rebaseCount < PHASE_3_END) {
nextBoundary = PHASE_3_END;
} else {
nextBoundary = type(uint256).max;
}
uint256 available;
if (nextBoundary == type(uint256).max) {
available = remaining;
} else {
available = nextBoundary - rebaseCount;
}
uint256 applyPeriods =
remaining < available
? remaining
: available;
rebaseIndex = _compound(
rebaseIndex,
rate,
applyPeriods
);
rebaseCount += applyPeriods;
remaining -= applyPeriods;
}
lastRebaseTime += periods * REBASE_INTERVAL;
emit Rebase(
rebaseCount,
rebaseIndex,
totalSupply()
);
}
function setExcludedFromRebase(
address account,
bool excluded
) external onlyOwner {
_setRebaseExcluded(account, excluded);
}
function _setRebaseExcluded(
address account,
bool excluded
) internal {
require(account != address(0), "Invalid account");
if (excludedFromRebase[account] == excluded) {
return;
}
if (excluded) {
uint256 currentBalance = balanceOf(account);
uint256 shares = _shares[account];
_shares[account] = 0;
totalShares -= shares;
_excludedBalances[account] = currentBalance;
excludedSupply += currentBalance;
} else {
uint256 currentBalance = _excludedBalances[account];
uint256 shares =
_sharesForAmountDown(currentBalance);
uint256 creditedAmount =
_amountForShares(shares);
require(
creditedAmount > 0 || currentBalance == 0,
"Amount too small"
);
_excludedBalances[account] =
currentBalance - creditedAmount;
excludedSupply -= creditedAmount;
_shares[account] += shares;
totalShares += shares;
}
excludedFromRebase[account] = excluded;
emit RebaseExclusionUpdated(
account,
excluded
);
}
function setTaxExempt(
address account,
bool exempt
) external onlyOwner {
require(account != address(0), "Invalid account");
_setTaxExempt(account, exempt);
}
function _setTaxExempt(
address account,
bool exempt
) internal {
taxExempt[account] = exempt;
emit TaxExemptionUpdated(
account,
exempt
);
}
function taxTreasury() external pure returns (address) {
return TAX_TREASURY;
}
function setAutomatedMarketMakerPair(
address pair,
bool value
) external onlyOwner {
require(pair != address(0), "Invalid pair");
automatedMarketMakerPairs[pair] = value;
_setRebaseExcluded(pair, value);
emit AutomatedMarketMakerPairUpdated(
pair,
value
);
}
function configureV2Liquidity(
address router,
address pair
) external onlyOwner {
require(router != address(0), "Invalid router");
require(pair != address(0), "Invalid pair");
liquidityRouter = IUniswapV2Router02(router);
liquidityPair = pair;
automatedMarketMakerPairs[pair] = true;
_setRebaseExcluded(pair, true);
autoLiquidityEnabled = true;
emit AutomatedMarketMakerPairUpdated(
pair,
true
);
emit LiquidityRouterConfigured(
router,
pair
);
emit AutoLiquidityStatusUpdated(true);
}
function disableAutoLiquidity() external onlyOwner {
autoLiquidityEnabled = false;
emit AutoLiquidityStatusUpdated(false);
}
function manualProcessLiquidity() external onlyOwner {
_processAutoLiquidity();
}
function _update(
address from,
address to,
uint256 amount
) internal override {
if (from == address(0)) {
revert("Minting disabled");
}
if (!_inSwap && to != address(0)) {
rebase();
}
if (
_inSwap ||
to == address(0) ||
taxExempt[from] ||
taxExempt[to]
) {
_moveWithoutTax(from, to, amount);
return;
}
bool isBuy =
automatedMarketMakerPairs[from] &&
!automatedMarketMakerPairs[to];
bool isSell =
automatedMarketMakerPairs[to] &&
!automatedMarketMakerPairs[from];
if (!isBuy && !isSell) {
_moveWithoutTax(from, to, amount);
return;
}
uint256 taxBps =
isBuy
? BUY_TAX_BPS
: SELL_TAX_BPS;
uint256 totalTax =
(amount * taxBps) /
BPS_DENOMINATOR;
uint256 treasuryAmount =
(amount * TAX_TREASURY_BPS) /
BPS_DENOMINATOR;
uint256 burnAmount =
(amount * TAX_BURN_BPS) /
BPS_DENOMINATOR;
uint256 liquidityAmount =
totalTax -
treasuryAmount -
burnAmount;
uint256 netAmount =
amount -
totalTax;
_moveWithoutTax(
from,
to,
netAmount
);
if (treasuryAmount > 0) {
_moveWithoutTax(
from,
TAX_TREASURY,
treasuryAmount
);
}
if (burnAmount > 0) {
_burnFromInternal(
from,
burnAmount
);
}
if (liquidityAmount > 0) {
uint256 actualLiquidity =
_moveWithoutTax(
from,
address(this),
liquidityAmount
);
liquidityTokensPending +=
actualLiquidity;
}
totalTaxCollected += totalTax;
totalTaxBurned += burnAmount;
totalLiquidityTokens += liquidityAmount;
emit TaxProcessed(
from,
to,
totalTax,
treasuryAmount,
burnAmount,
liquidityAmount
);
if (
autoLiquidityEnabled &&
!_inSwap &&
liquidityTokensPending >= LIQUIDITY_THRESHOLD
) {
_processAutoLiquidity();
}
}
function _moveWithoutTax(
address from,
address to,
uint256 amount
) internal returns (uint256) {
require(from != address(0), "Invalid sender");
if (amount == 0) {
emit Transfer(from, to, 0);
return 0;
}
if (to == address(0)) {
return _burnFromInternal(from, amount);
}
if (
excludedFromRebase[from] &&
excludedFromRebase[to]
) {
require(
_excludedBalances[from] >= amount,
"Insufficient balance"
);
_excludedBalances[from] -= amount;
_excludedBalances[to] += amount;
emit Transfer(from, to, amount);
return amount;
}
if (
excludedFromRebase[from] &&
!excludedFromRebase[to]
) {
require(
_excludedBalances[from] >= amount,
"Insufficient balance"
);
uint256 shares =
_sharesForAmountDown(amount);
require(shares > 0, "Amount too small");
uint256 actualAmount =
_amountForShares(shares);
require(
actualAmount > 0 &&
actualAmount <= amount,
"Invalid share amount"
);
_excludedBalances[from] -= actualAmount;
excludedSupply -= actualAmount;
_shares[to] += shares;
totalShares += shares;
emit Transfer(
from,
to,
actualAmount
);
return actualAmount;
}
if (
!excludedFromRebase[from] &&
excludedFromRebase[to]
) {
uint256 shares =
_sharesForAmountDown(amount);
require(shares > 0, "Amount too small");
require(
_shares[from] >= shares,
"Insufficient balance"
);
uint256 actualAmount =
_amountForShares(shares);
_shares[from] -= shares;
totalShares -= shares;
_excludedBalances[to] += actualAmount;
excludedSupply += actualAmount;
emit Transfer(
from,
to,
actualAmount
);
return actualAmount;
}
uint256 sharesToMove =
_sharesForAmountDown(amount);
require(
sharesToMove > 0,
"Amount too small"
);
require(
_shares[from] >= sharesToMove,
"Insufficient balance"
);
uint256 actualTransfer =
_amountForShares(sharesToMove);
_shares[from] -= sharesToMove;
_shares[to] += sharesToMove;
emit Transfer(
from,
to,
actualTransfer
);
return actualTransfer;
}
function _burnFromInternal(
address from,
uint256 amount
) internal returns (uint256) {
require(
from != address(0),
"Invalid account"
);
if (amount == 0) {
emit Transfer(
from,
address(0),
0
);
return 0;
}
if (excludedFromRebase[from]) {
require(
_excludedBalances[from] >= amount,
"Insufficient balance"
);
_excludedBalances[from] -= amount;
excludedSupply -= amount;
emit Transfer(
from,
address(0),
amount
);
return amount;
}
uint256 shares =
_sharesForAmountDown(amount);
require(
shares > 0,
"Amount too small"
);
require(
_shares[from] >= shares,
"Insufficient balance"
);
uint256 actualAmount =
_amountForShares(shares);
_shares[from] -= shares;
totalShares -= shares;
emit Transfer(
from,
address(0),
actualAmount
);
return actualAmount;
}
function _sharesForAmountDown(
uint256 amount
) internal view returns (uint256) {
if (amount == 0) return 0;
return
(amount * WAD) /
rebaseIndex;
}
function _amountForShares(
uint256 shares
) internal view returns (uint256) {
if (shares == 0) return 0;
return
(shares * rebaseIndex) /
WAD;
}
function _compound(
uint256 base,
uint256 rate,
uint256 periods
) internal pure returns (uint256) {
if (periods == 0) return base;
uint256 multiplier = WAD + rate;
uint256 result = WAD;
uint256 exponent = periods;
while (exponent > 0) {
if ((exponent & 1) == 1) {
result = _mulWad(
result,
multiplier
);
}
exponent >>= 1;
if (exponent > 0) {
multiplier = _mulWad(
multiplier,
multiplier
);
}
}
return _mulWad(base, result);
}
function _mulWad(
uint256 a,
uint256 b
) internal pure returns (uint256) {
if (a == 0 || b == 0) return 0;
require(
a <= type(uint256).max / b,
"WAD multiplication overflow"
);
return (a * b) / WAD;
}
function _processAutoLiquidity() internal {
if (_inSwap) return;
if (!autoLiquidityEnabled) return;
if (liquidityTokensPending == 0) return;
address router =
address(liquidityRouter);
if (router == address(0)) return;
if (liquidityPair == address(0)) return;
uint256 contractBalance =
_excludedBalances[address(this)];
if (contractBalance == 0) return;
uint256 tokenAmount =
liquidityTokensPending;
if (tokenAmount > contractBalance) {
tokenAmount = contractBalance;
}
if (
tokenAmount <
LIQUIDITY_THRESHOLD
) {
return;
}
_inSwap = true;
uint256 half =
tokenAmount / 2;
uint256 otherHalf =
tokenAmount - half;
if (half == 0 || otherHalf == 0) {
_inSwap = false;
return;
}
_approve(
address(this),
router,
half
);
uint256 ethBefore =
address(this).balance;
address[] memory path =
new address[](2);
path[0] = address(this);
path[1] = liquidityRouter.WETH();
uint256[] memory quotedAmounts;
try
liquidityRouter.getAmountsOut(
half,
path
)
returns (uint256[] memory amounts) {
quotedAmounts = amounts;
} catch {
_inSwap = false;
return;
}
if (quotedAmounts.length < 2) {
_inSwap = false;
return;
}
uint256 minimumEth =
(quotedAmounts[1] *
(BPS_DENOMINATOR -
AUTO_LIQUIDITY_SLIPPAGE_BPS)) /
BPS_DENOMINATOR;
try
liquidityRouter
.swapExactTokensForETHSupportingFeeOnTransferTokens(
half,
minimumEth,
path,
address(this),
block.timestamp
)
{
liquidityTokensPending -= half;
} catch {
_inSwap = false;
return;
}
uint256 ethReceived =
address(this).balance -
ethBefore;
if (ethReceived == 0) {
_inSwap = false;
return;
}
_approve(
address(this),
router,
otherHalf
);
try
liquidityRouter
.addLiquidityETH{
value: ethReceived
}(
address(this),
otherHalf,
(otherHalf *
(BPS_DENOMINATOR -
AUTO_LIQUIDITY_SLIPPAGE_BPS)) /
BPS_DENOMINATOR,
minimumEth,
owner(),
block.timestamp
)
returns (
uint256 amountToken,
uint256 amountETH,
uint256
)
{
if (
amountToken >=
liquidityTokensPending
) {
liquidityTokensPending = 0;
} else {
liquidityTokensPending -=
amountToken;
}
emit LiquidityProcessed(
amountToken,
amountETH
);
} catch {
/*
* Unused ETH remains in the contract.
* Unused SUUPER remains pending.
*/
}
_inSwap = false;
}
function withdrawETH(
uint256 amount
) external onlyOwner {
require(
amount <= address(this).balance,
"Insufficient ETH"
);
(
bool success,
) = payable(owner()).call{
value: amount
}("");
require(
success,
"ETH transfer failed"
);
}
function mint(
address,
uint256
) external pure {
revert("Minting disabled");
}
}npm/@openzeppelin/[email protected]/access/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
npm/@openzeppelin/[email protected]/access/Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}
npm/@openzeppelin/[email protected]/interfaces/draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (interfaces/draft-IERC6093.sol)
pragma solidity >=0.8.4;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-721.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
npm/@openzeppelin/[email protected]/token/ERC20/ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (token/ERC20/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";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
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;
/**
* @dev Sets the values for {name} and {symbol}.
*
* Both values are immutable: they can only be set once during construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/// @inheritdoc IERC20
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/// @inheritdoc IERC20
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/// @inheritdoc IERC20
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
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;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
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);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner`'s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation sets the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the `transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
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);
}
}
/**
* @dev Updates `owner`'s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
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);
}
}
}
}
npm/@openzeppelin/[email protected]/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
npm/@openzeppelin/[email protected]/token/ERC20/extensions/ERC20Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Burnable.sol)
pragma solidity ^0.8.20;
import {ERC20} from "../ERC20.sol";
import {Context} from "../../../utils/Context.sol";
/**
* @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis).
*/
abstract contract ERC20Burnable is Context, ERC20 {
/**
* @dev Destroys a `value` amount of tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 value) public virtual {
_burn(_msgSender(), value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, deducting from
* the caller's allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `value`.
*/
function burnFrom(address account, uint256 value) public virtual {
_spendAllowance(account, _msgSender(), value);
_burn(account, value);
}
}
npm/@openzeppelin/[email protected]/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
npm/@openzeppelin/[email protected]/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
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;
}
}
Compiler settingsShow
{
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.