// SPDX-License-Identifier: UNLICENSEDpragmasolidity ^0.8.21;import"../libs/constant.sol";
/**
* @title BurnInfo
* @dev this contract is meant to be inherited into main contract
* @notice It has the variables and functions specifically for tracking burn amount and reward
*/abstractcontractBurnInfo{
//Variables//track the total Shogun burn amountuint256private s_totalShogunBurned;
//mappings//track wallet address -> total Shogun burn amountmapping(address=>uint256) private s_userBurnAmount;
//track contract/project address -> total Shogun burn amountmapping(address=>uint256) private s_project_BurnAmount;
//track contract/project address, wallet address -> total Shogun burn amountmapping(address=>mapping(address=>uint256)) private s_projectUser_BurnAmount;
//events/** @dev log user burn Shogun event
* project can be address(0) if user burns Shogun directly from Shogun contract
*/eventShogunBurned(addressindexed user, addressindexed project, uint256 amount);
//functions/** @dev update the burn amount
* @param user wallet address
* @param project contract address
* @param amount Shogun amount burned
*/function_updateBurnAmount(address user, address project, uint256 amount) internal{
s_userBurnAmount[user] += amount;
s_totalShogunBurned += amount;
if (project !=address(0)) {
s_project_BurnAmount[project] += amount;
s_projectUser_BurnAmount[project][user] += amount;
}
emit ShogunBurned(user, project, amount);
}
//views/** @notice return total burned Shogun amount from all users burn or projects burn
* @return totalBurnAmount returns entire burned Shogun
*/functiongetTotalBurnTotal() publicviewreturns (uint256) {
return s_totalShogunBurned;
}
/** @notice return user address total burned Shogun
* @return userBurnAmount returns user address total burned Shogun
*/functiongetUserBurnTotal(address user) publicviewreturns (uint256) {
return s_userBurnAmount[user];
}
/** @notice return project address total burned Shogun amount
* @return projectTotalBurnAmount returns project total burned Shogun
*/functiongetProjectBurnTotal(address contractAddress) publicviewreturns (uint256) {
return s_project_BurnAmount[contractAddress];
}
/** @notice return user address total burned Shogun amount via a project address
* @param contractAddress project address
* @param user user address
* @return projectUserTotalBurnAmount returns user address total burned Shogun via a project address
*/functiongetProjectUserBurnTotal(address contractAddress,
address user
) publicviewreturns (uint256) {
return s_projectUser_BurnAmount[contractAddress][user];
}
}
Contract Source Code
File 2 of 19: Context.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)pragmasolidity ^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.
*/abstractcontractContext{
function_msgSender() internalviewvirtualreturns (address) {
returnmsg.sender;
}
function_msgData() internalviewvirtualreturns (bytescalldata) {
returnmsg.data;
}
function_contextSuffixLength() internalviewvirtualreturns (uint256) {
return0;
}
}
Contract Source Code
File 3 of 19: ERC20.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/ERC20.sol)pragmasolidity ^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.
*/abstractcontractERC20isContext, IERC20, IERC20Metadata, IERC20Errors{
mapping(address account =>uint256) private _balances;
mapping(address account =>mapping(address spender =>uint256)) private _allowances;
uint256private _totalSupply;
stringprivate _name;
stringprivate _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/constructor(stringmemory name_, stringmemory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/functionname() publicviewvirtualreturns (stringmemory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/functionsymbol() publicviewvirtualreturns (stringmemory) {
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}.
*/functiondecimals() publicviewvirtualreturns (uint8) {
return18;
}
/**
* @dev See {IERC20-totalSupply}.
*/functiontotalSupply() publicviewvirtualreturns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/functionbalanceOf(address account) publicviewvirtualreturns (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`.
*/functiontransfer(address to, uint256 value) publicvirtualreturns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
returntrue;
}
/**
* @dev See {IERC20-allowance}.
*/functionallowance(address owner, address spender) publicviewvirtualreturns (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.
*/functionapprove(address spender, uint256 value) publicvirtualreturns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
returntrue;
}
/**
* @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`.
*/functiontransferFrom(addressfrom, address to, uint256 value) publicvirtualreturns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
returntrue;
}
/**
* @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(addressfrom, 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(addressfrom, address to, uint256 value) internalvirtual{
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 set 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) internalvirtual{
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) internalvirtual{
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);
}
}
}
}
Contract Source Code
File 4 of 19: GlobalInfo.sol
// SPDX-License-Identifier: UNLICENSEDpragmasolidity ^0.8.21;import"../libs/constant.sol";
import"../interfaces/IShogunBnB.sol";
errorShogun_InvalidRange();
abstractcontractGlobalInfo{
//Variables//deployed timestampuint256privateimmutable i_genesisTs;
/** @dev track current contract day */uint256private s_currentContractDay;
/** @dev track current daily auction supply in phase 2 */uint256private s_currentAuctionSupply;
/** @dev track current amount for next perpetual auction supply in phase 2 */uint256private s_currentWarChestSupply;
//*********** Auction Variables ***********//** @dev track user total amount for each daily cycle
* s_userCycleAmount[address][1] = 300 = day 1 300
* s_userCycleAmount[address][2] = 500 = day 2 500
* */mapping(address=>mapping(uint256=>uint256)) s_userCycleAmount;
/** @dev track auction total amount for each daily cycle
* s_cycleTotal[1] = 30000
* s_cycleTotal[2] = 60000
*/mapping(uint256=>uint256) private s_cycleTotal;
/** @dev track auction supply per share for each daily cycle
* s_cycleSupplyPerShare[1] = 10
* s_cycleSupplyPerShare[2] = 8
*/mapping(uint256=>uint256) private s_cycleSupplyPerShare;
/** @dev track user start auction claim index
* so calculation would start from current index
* [address] = 1
*/mapping(address=>uint256) private s_userStartAuctionClaimIndex;
//structsstructCycleAuctionInfo {
uint256 day;
uint256 amount;
uint256 reward;
}
//eventeventGlobalDailyUpdateStats(uint256indexed day, uint256indexed auctionSupply);
eventCalculatedAuctionSupplyPerShare(uint256indexed day, uint256indexed supplyPerShare);
/** @dev Update variables in terms of day, modifier is used in all external/public functions (exclude view)
* Every interaction to the contract would run this function to update variables
*/modifierdailyUpdate(address bnbAddress) {
_dailyUpdate(bnbAddress);
_;
}
constructor() {
i_genesisTs =block.timestamp;
s_currentContractDay =1;
s_currentAuctionSupply = INITIAL_PHASE_DAILY_AUCTION_SUPPLY;
}
/** @dev calculate and update variables daily */function_dailyUpdate(address bnbAddress) private{
uint256 currentContractDay = s_currentContractDay;
uint256 currentBlockDay = ((block.timestamp- i_genesisTs) /1days) +1;
if (currentBlockDay > currentContractDay) {
//calculate previous cycle SupplyPerShareif (currentContractDay <28) {
_calculateCycleSupplyPerShare(
currentContractDay,
INITIAL_PHASE_DAILY_AUCTION_SUPPLY
);
emit GlobalDailyUpdateStats(currentBlockDay, INITIAL_PHASE_DAILY_AUCTION_SUPPLY);
} else {
_calculateCycleSupplyPerShare(currentContractDay, s_currentAuctionSupply);
uint256 newAuctionSupply = (s_currentWarChestSupply *
PHASE_2_DAILY_AUCTION_SUPPLY_PERCENT) / PERCENT_BPS;
s_currentAuctionSupply = newAuctionSupply;
s_currentWarChestSupply -= newAuctionSupply;
emit GlobalDailyUpdateStats(currentBlockDay, newAuctionSupply);
}
s_currentContractDay = currentBlockDay;
IShogunBnB(bnbAddress).dailyUpdate(); //update BnB daily funds
}
}
/******* Auction functions *******//** @dev calculate supply per share on a given contract day
* @param contractDay contract day
* @param auctionSupply auction supply
*/function_calculateCycleSupplyPerShare(uint256 contractDay, uint256 auctionSupply) internal{
uint256 supplyPerShare;
uint256 totalAmount = s_cycleTotal[contractDay];
if (totalAmount !=0) {
supplyPerShare = (auctionSupply *1ether) / totalAmount;
s_cycleSupplyPerShare[contractDay] = supplyPerShare;
}
emit CalculatedAuctionSupplyPerShare(contractDay, supplyPerShare);
}
/** @dev update cylce user amount and total amount based on current contract day
* @param user address
* @param amount amount
*/function_updateCycleAmount(address user, uint256 amount) internal{
uint256 currentContractDay = getCurrentContractDay();
//only new user will need to init claim index//set claim index to start from current contract dayif (s_userStartAuctionClaimIndex[user] ==0) {
s_userStartAuctionClaimIndex[user] = currentContractDay;
}
//update user amount and total amount in current cycle
s_userCycleAmount[user][currentContractDay] += amount;
s_cycleTotal[currentContractDay] += amount;
}
/** @dev update to the last index where a user has claimed the auction
* @param user user address
*/function_updateUserAuctionClaimIndex(address user) internal{
s_userStartAuctionClaimIndex[user] = getCurrentContractDay();
}
/** @dev increase War Chest supply from buy and burn or a % from transfer tax
* @param amount amount to increase
*/function_AddWarChestSupply(uint256 amount) internal{
s_currentWarChestSupply += amount;
}
/** Views *//** @notice Returns current contract day
* @return currentContractDay current contract day
*/functiongetCurrentContractDay() publicviewreturns (uint256) {
return s_currentContractDay;
}
/** @notice Returns current auction supply
* @return current auction supply
*/functiongetCurrentAuctionSupply() publicviewreturns (uint256) {
return s_currentAuctionSupply;
}
/** @notice Returns current War Chest supply
* @return current War Chest supply
*/functiongetCurrentWarChestSupply() publicviewreturns (uint256) {
return s_currentWarChestSupply;
}
/** @notice Returns contract deployment block timestamp
* @return genesisTs deployed timestamp
*/functiongenesisTs() publicviewreturns (uint256) {
return i_genesisTs;
}
/** @notice Returns the calculated supply per share for a given contract day as index
* @param index cycle index
* @return supplyPerShare
*/functiongetSupplyPerShare(uint256 index) publicviewreturns (uint256) {
return s_cycleSupplyPerShare[index];
}
/** @notice Returns total amount in a given daily cycle
* * @param day day
* @return total amount
*/functiongetCycleTotalAmount(uint256 day) publicviewreturns (uint256) {
return s_cycleTotal[day];
}
/** @notice Returns user total amount in a given daily cycle
* @param user user address
* * @param day day
* @return total amount
*/functiongetUserCycleAmount(address user, uint256 day) publicviewreturns (uint256) {
return s_userCycleAmount[user][day];
}
/** @notice Returns user's start claim index
* @param user user address
* @return cycleIndex cycle index
*/functiongetUserStartAuctionClaimIndex(address user) publicviewreturns (uint256) {
return s_userStartAuctionClaimIndex[user];
}
/** @notice Returns user total unclaim auction supply from user's start claim index
* @param user address
* @return claimableSupply total unclaim amount
*/functiongetUserClaimableAuctionSupply(address user
) publicviewreturns (uint256 claimableSupply) {
uint256 startClaimIndex = s_userStartAuctionClaimIndex[user];
uint256 maxContractDay = getCurrentContractDay();
for (uint256 i = startClaimIndex; i < maxContractDay; i++) {
claimableSupply += s_userCycleAmount[user][i] * s_cycleSupplyPerShare[i];
}
//supplyPerShare has 18 decimals scaling, so here divide by 18 decimalsif (claimableSupply !=0) claimableSupply /=1ether;
}
/** @notice return a list of user auction info based on input range (contract start and end day)
* the list will return real time auction amount (current contract day) and past cycles' auction reward
* @param startDay start day
* @param endDay end day
*/functiongetUserAuctionInfo(address user,
uint256 startDay,
uint256 endDay
) publicviewreturns (CycleAuctionInfo[] memory cycleAuctionInfo) {
if (startDay > endDay) revert Shogun_InvalidRange();
uint256 currentContractDay = getCurrentContractDay();
endDay = endDay > currentContractDay ? currentContractDay : endDay;
uint256 index =0;
cycleAuctionInfo =new CycleAuctionInfo[](endDay - startDay +1);
for (uint256 i = startDay; i <= endDay; i++) {
uint256 amount = s_userCycleAmount[user][i];
cycleAuctionInfo[index++] = CycleAuctionInfo({
day: i,
amount: amount,
reward: (amount * s_cycleSupplyPerShare[i]) /1ether
});
}
}
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)pragmasolidity ^0.8.20;/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/interfaceIERC20{
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/eventTransfer(addressindexedfrom, addressindexed 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.
*/eventApproval(addressindexed owner, addressindexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/functiontotalSupply() externalviewreturns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/functionbalanceOf(address account) externalviewreturns (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.
*/functiontransfer(address to, uint256 value) externalreturns (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.
*/functionallowance(address owner, address spender) externalviewreturns (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.
*/functionapprove(address spender, uint256 value) externalreturns (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.
*/functiontransferFrom(addressfrom, address to, uint256 value) externalreturns (bool);
}
Contract Source Code
File 7 of 19: IERC20Metadata.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)pragmasolidity ^0.8.20;import {IERC20} from"../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/interfaceIERC20MetadataisIERC20{
/**
* @dev Returns the name of the token.
*/functionname() externalviewreturns (stringmemory);
/**
* @dev Returns the symbol of the token.
*/functionsymbol() externalviewreturns (stringmemory);
/**
* @dev Returns the decimals places of the token.
*/functiondecimals() externalviewreturns (uint8);
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)pragmasolidity ^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.
*/abstractcontractOwnableisContext{
addressprivate _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/errorOwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/errorOwnableInvalidOwner(address owner);
eventOwnershipTransferred(addressindexed previousOwner, addressindexed 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.
*/modifieronlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/functionowner() publicviewvirtualreturns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/function_checkOwner() internalviewvirtual{
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.
*/functionrenounceOwnership() publicvirtualonlyOwner{
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/functiontransferOwnership(address newOwner) publicvirtualonlyOwner{
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) internalvirtual{
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Contract Source Code
File 16 of 19: ReentrancyGuard.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)pragmasolidity ^0.8.20;/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/abstractcontractReentrancyGuard{
// Booleans are more expensive than uint256 or any type that takes up a full// word because each write operation emits an extra SLOAD to first read the// slot's contents, replace the bits taken up by the boolean, and then write// back. This is the compiler's defense against contract upgrades and// pointer aliasing, and it cannot be disabled.// The values being non-zero value makes deployment a bit more expensive,// but in exchange the refund on every call to nonReentrant will be lower in// amount. Since refunds are capped to a percentage of the total// transaction's gas, it is best to keep them low in cases like this one, to// increase the likelihood of the full refund coming into effect.uint256privateconstant NOT_ENTERED =1;
uint256privateconstant ENTERED =2;
uint256private _status;
/**
* @dev Unauthorized reentrant call.
*/errorReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/modifiernonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function_nonReentrantBefore() private{
// On the first call to nonReentrant, _status will be NOT_ENTEREDif (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function_nonReentrantAfter() private{
// By storing the original value once again, a refund is triggered (see// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/function_reentrancyGuardEntered() internalviewreturns (bool) {
return _status == ENTERED;
}
}
Contract Source Code
File 17 of 19: Shogun.sol
// SPDX-License-Identifier: UNLICENSEDpragmasolidity ^0.8.21;import"@openzeppelin/contracts/access/Ownable.sol";
import"@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import"@openzeppelin/contracts/interfaces/IERC165.sol";
import"@openzeppelin/contracts/token/ERC20/ERC20.sol";
import"../interfaces/ITITANX.sol";
import"../interfaces/ITitanBurn.sol";
import"../interfaces/ITitanOnBurn.sol";
import"../interfaces/IShogunOnBurn.sol";
import"../interfaces/IShogun.sol";
import"../interfaces/IX28.sol";
import"./GlobalInfo.sol";
import"./BurnInfo.sol";
//custom errorserrorShogun_NotSupportedContract();
errorShogun_NotAllowed();
errorShogun_InvalidBurnRewardPercent();
errorShogun_LPTokensHasMinted();
errorShogun_InvalidAddress();
errorShogun_UnregisteredCA();
errorShogun_NoSupplyToClaim();
errorShogun_NoAllowance();
errorShogun_NotEnoughBalance();
errorShogun_BurnStakeClosed();
errorShogun_CannotZero();
/** @title Shogun */contractShogunisERC20, ReentrancyGuard, GlobalInfo, BurnInfo, Ownable, ITitanOnBurn{
/** Storage Variables*//** @dev stores genesis wallet address */addressprivate s_genesisAddress;
/** @dev stores LP wallet address */addressprivate s_lPAddress;
/** @dev stores buy and burn contract address */addressprivate s_buyAndBurnAddress;
/** @dev tracks total amount of X28 deposited */uint256 s_totalX28Deposited;
/** @dev tracks total amount of X28 burned */uint256 s_totalX28Burned;
/** @dev tracks total amount of TitanX deposited */uint256 s_totalTitanXDeposited;
/** @dev tracks total amount of TitanX burned */uint256 s_totalTitanXBurned;
/** @dev tracks total amount of Shogun burned from tax */uint256 s_totalShogunTaxBurned;
/** @dev Tracks Shogun buy and burn contract addresses status
* Specifically used for burning Shogun in registered CA */mapping(address=>bool) s_buyAndBurnAddressRegistry;
/** @dev track addresses to exclude from transfer tax */mapping(address=>bool) private s_taxExclusionList;
/** @dev tracks if initial LP tokens has minted or not */boolprivate s_initialLPMinted;
eventAuctionEntered(addressindexed user, uint256indexed day, uint256indexed amount);
eventAuctionSupplyClaimed(addressindexed user, uint256indexed amount);
constructor(address genesisAddress,
address lPAddress,
address buyAndBurnAddress
) Ownable(msg.sender) ERC20("SHOGUN", "SHOGUN") {
if (genesisAddress ==address(0)) revert Shogun_InvalidAddress();
if (lPAddress ==address(0)) revert Shogun_InvalidAddress();
if (buyAndBurnAddress ==address(0)) revert Shogun_InvalidAddress();
s_genesisAddress = genesisAddress;
s_lPAddress = lPAddress;
s_buyAndBurnAddress = buyAndBurnAddress;
s_buyAndBurnAddressRegistry[buyAndBurnAddress] =true;
s_taxExclusionList[buyAndBurnAddress] =true;
s_taxExclusionList[lPAddress] =true;
s_taxExclusionList[address(0)] =true;
_mint(s_lPAddress, LP_WALLET_TOKENS);
}
/** @notice add given address to be excluded from transfer tax. Only callable by owner address.
* @param addr address
*/functionaddTaxExclusionAddress(address addr) externalonlyOwner{
if (addr ==address(0)) revert Shogun_InvalidAddress();
s_taxExclusionList[addr] =true;
}
/** @notice remove given address to be excluded from transfer tax. Only callable by owner address.
* @param addr address
*/functionremoveTaxExclusionAddress(address addr) externalonlyOwner{
if (addr ==address(0)) revert Shogun_InvalidAddress();
s_taxExclusionList[addr] =false;
}
/** @notice Set BuyAndBurn Contract Address.
* Only owner can call this function
* @param contractAddress BuyAndBurn contract address
*/functionsetBuyAndBurnContractAddress(address contractAddress) externalonlyOwner{
/* Only able to change to supported buyandburn contract address.
* Also prevents owner from registering EOA address into s_buyAndBurnAddressRegistry and call burnCAShogun to burn user's tokens.
*/if (
!IERC165(contractAddress).supportsInterface(IERC165.supportsInterface.selector) ||!IERC165(contractAddress).supportsInterface(type(IShogun).interfaceId)
) revert Shogun_NotSupportedContract();
s_buyAndBurnAddress = contractAddress;
s_buyAndBurnAddressRegistry[contractAddress] =true;
s_taxExclusionList[contractAddress] =true;
}
/** @notice Set to new genesis wallet. Only genesis wallet can call this function
* @param newAddress new genesis wallet address
*/functionsetNewGenesisAddress(address newAddress) external{
if (msg.sender!= s_genesisAddress) revert Shogun_NotAllowed();
if (newAddress ==address(0)) revert Shogun_InvalidAddress();
s_genesisAddress = newAddress;
}
/** @notice Set to new LP wallet. Only LP wallet can call this function
* @param newAddress new LP wallet address
*/functionsetNewLPAddress(address newAddress) external{
if (msg.sender!= s_lPAddress) revert Shogun_NotAllowed();
if (newAddress ==address(0)) revert Shogun_InvalidAddress();
s_lPAddress = newAddress;
s_taxExclusionList[newAddress] =true;
}
/** @notice mint initial LP tokens. Only BuyAndBurn contract set by owner can call this function
*/functionmintLPTokens() external{
if (msg.sender!= s_buyAndBurnAddress) revert Shogun_NotAllowed();
if (s_initialLPMinted) revert Shogun_LPTokensHasMinted();
s_initialLPMinted =true;
_mint(s_buyAndBurnAddress, INITAL_LP_TOKENS);
}
/** @notice burn Shogun in BuyAndBurn contract.
* Only burns registered contract address
* % to LP wallet, % to War Chest supply (stored in variable), burn all tokens except LP tokens
*/functionburnCAShogun(address contractAddress) externaldailyUpdate(s_buyAndBurnAddress) {
if (!s_buyAndBurnAddressRegistry[contractAddress]) revert Shogun_UnregisteredCA();
uint256 totalAmount = balanceOf(contractAddress);
uint256 lPAmount = (totalAmount * SHOGUN_LP_PERCENT) / PERCENT_BPS;
uint256 warChestAmount = (totalAmount * SHOGUN_WARCHEST_PERCENT) / PERCENT_BPS;
super._update(contractAddress, address(0), totalAmount - lPAmount); //burn including war chest supplysuper._update(contractAddress, s_lPAddress, lPAmount); //LP supply
_AddWarChestSupply(warChestAmount);
}
/** @notice enter auction using liquid X28
* % burned, % to LP address, % to genesis address, % to B&B contract
* @param amount TitanX amount
*/functionenterAuctionX28Liquid(uint256 amount
) externaldailyUpdate(s_buyAndBurnAddress) nonReentrant{
if (amount ==0) revert Shogun_CannotZero();
//transfer burn amount to X28 BNB, call public burnCAX28() to burn X28uint256 burnAmount = (amount * BURN_PERCENT) / PERCENT_BPS;
IX28(X28).transferFrom(msg.sender, X28_BNB, burnAmount);
IX28(X28).burnCAX28(X28_BNB);
//transfer LP amount to LP addressuint256 lPAmount = (amount * LP_PERCENT) / PERCENT_BPS;
IX28(X28).transferFrom(msg.sender, s_lPAddress, lPAmount);
//transfer genesis amount to genesis addressuint256 genesisAmount = (amount * GENESIS_PERCENT) / PERCENT_BPS;
IX28(X28).transferFrom(msg.sender, s_genesisAddress, genesisAmount);
//transfer BnB amount to BnB contract
IX28(X28).transferFrom(
msg.sender,
s_buyAndBurnAddress,
amount - burnAmount - lPAmount - genesisAmount
);
_updateCycleAmount(msg.sender, amount);
s_totalX28Deposited += amount;
s_totalX28Burned += burnAmount;
emit AuctionEntered(msg.sender, getCurrentContractDay(), amount);
}
/** @notice enter auction using TitanX stakes (up to 28 at once)
* same amount of staked TitanX as liquid is required to burn stake
* % burned, % to LP address, % to genesis address, % to B&B contract
* 8% burn dev reward to BnB contract
* credit 2x amount in current auction
* @param stakeId User TitanX stake Ids
*/functionenterAuctionTitanXStake(uint256[] calldata stakeId
) externaldailyUpdate(s_buyAndBurnAddress) nonReentrant{
if (getCurrentContractDay() >28) revert Shogun_BurnStakeClosed();
if (ITITANX(TITANX_CA).allowanceBurnStakes(msg.sender, address(this)) < stakeId.length)
revert Shogun_NoAllowance();
uint256 amount;
uint256 claimCount;
for (uint256 i =0; i < stakeId.length; i++) {
ITITANX.UserStakeInfo memory info = ITITANX(TITANX_CA).getUserStakeInfo(
msg.sender,
stakeId[i]
);
if (info.status == ITITANX.StakeStatus.ACTIVE && info.titanAmount !=0) {
ITitanBurn(TITANX_CA).burnStakeToPayAddress(
msg.sender,
stakeId[i],
0,
8,
s_buyAndBurnAddress
);
amount += info.titanAmount;
++claimCount;
}
if (claimCount == MAX_BATCH_BURN_COUNT) break;
}
if (ITITANX(TITANX_CA).balanceOf(msg.sender) < amount) revert Shogun_NotEnoughBalance();
//transfer burn amount to TitanX BNBV2, call public burnLPTokens() to burn TitanXuint256 burnAmount = (amount * BURN_PERCENT) / PERCENT_BPS;
ITITANX(TITANX_CA).transferFrom(msg.sender, TITANX_BNBV2, burnAmount);
ITITANX(TITANX_CA).burnLPTokens();
//transfer LP amount to LP addressuint256 lPAmount = (amount * LP_PERCENT) / PERCENT_BPS;
ITITANX(TITANX_CA).transferFrom(msg.sender, s_lPAddress, lPAmount);
//transfer genesis amount to genesis addressuint256 genesisAmount = (amount * GENESIS_PERCENT) / PERCENT_BPS;
ITITANX(TITANX_CA).transferFrom(msg.sender, s_genesisAddress, genesisAmount);
//transfer BnB amount to BnB contract
ITITANX(TITANX_CA).transferFrom(
msg.sender,
s_buyAndBurnAddress,
amount - burnAmount - lPAmount - genesisAmount
);
uint256 totalCreditAmount = amount *2;
_updateCycleAmount(msg.sender, totalCreditAmount);
s_totalTitanXDeposited += totalCreditAmount;
s_totalTitanXBurned += burnAmount + amount; //100% staked amount burned + 20% liquid burnedemit AuctionEntered(msg.sender, getCurrentContractDay(), totalCreditAmount);
}
/** @notice claim available auction supply (accumulate if past auctions was not claimed) */functionclaimUserAuction() externaldailyUpdate(s_buyAndBurnAddress) nonReentrant{
uint256 claimableSupply = getUserClaimableAuctionSupply(msg.sender);
if (claimableSupply ==0) revert Shogun_NoSupplyToClaim();
_updateUserAuctionClaimIndex(msg.sender);
_mint(msg.sender, claimableSupply);
emit AuctionSupplyClaimed(msg.sender, claimableSupply);
}
/** @notice callback function from TitanX contract after burn.
* do nothing
* @param user wallet address
* @param amount burned Titan X amount
*/functiononBurn(address user, uint256 amount) external{}
//private functions/** @dev override ERC20 update for tax logic
* add to tax exlusion list to avoid tax logic
*/function_update(addressfrom, address to, uint256 value) internalvirtualoverride{
if (s_taxExclusionList[from] || s_taxExclusionList[to]) {
super._update(from, to, value);
return;
}
uint256 taxAmount = (value * TRANSFER_TAX_PERCENT) / PERCENT_BPS;
uint256 lPAmount = (taxAmount * SHOGUN_LP_PERCENT) / PERCENT_BPS;
uint256 warChestAmount = (taxAmount * SHOGUN_WARCHEST_PERCENT) / PERCENT_BPS;
super._update(from, address(0), taxAmount - lPAmount); //burn including war chest supplysuper._update(from, s_lPAddress, lPAmount); //LP supplysuper._update(from, to, value - taxAmount); //transfer taxed amount
_AddWarChestSupply(warChestAmount);
s_totalShogunTaxBurned += taxAmount - lPAmount - warChestAmount;
}
/** @dev burn liquid Shogun through other project.
* called by other contracts for proof of burn 2.0 with up to 8% for both builder fee and user rebate
* @param user user address
* @param amount liquid Shogun amount
* @param userRebatePercentage percentage for user rebate in liquid Shogun (0 - 8)
* @param rewardPaybackPercentage percentage for builder fee in liquid Shogun (0 - 8)
* @param rewardPaybackAddress builder can opt to receive fee in another address
*/function_burnLiquidShogun(address user,
uint256 amount,
uint256 userRebatePercentage,
uint256 rewardPaybackPercentage,
address rewardPaybackAddress
) private{
_spendAllowance(user, msg.sender, amount);
_burnbefore(userRebatePercentage, rewardPaybackPercentage);
_burn(user, amount);
_burnAfter(
user,
amount,
userRebatePercentage,
rewardPaybackPercentage,
rewardPaybackAddress
);
}
/** @dev perform checks before burning starts.
* check reward percentage and check if called by supported contract
* @param userRebatePercentage percentage for user rebate
* @param rewardPaybackPercentage percentage for builder fee
*/function_burnbefore(uint256 userRebatePercentage,
uint256 rewardPaybackPercentage
) privateview{
if (rewardPaybackPercentage + userRebatePercentage > MAX_BURN_REWARD_PERCENT)
revert Shogun_InvalidBurnRewardPercent();
//Only supported contracts is allowed to call this functionif (
!IERC165(msg.sender).supportsInterface(IERC165.supportsInterface.selector) ||!IERC165(msg.sender).supportsInterface(type(IShogunOnBurn).interfaceId)
) revert Shogun_NotSupportedContract();
}
/** @dev update burn stats and mint reward to builder or user if applicable
* @param user user address
* @param amount Shogun amount burned
* @param userRebatePercentage percentage for user rebate in liquid Shogun (0 - 8)
* @param rewardPaybackPercentage percentage for builder fee in liquid Shogun (0 - 8)
* @param rewardPaybackAddress builder can opt to receive fee in another address
*/function_burnAfter(address user,
uint256 amount,
uint256 userRebatePercentage,
uint256 rewardPaybackPercentage,
address rewardPaybackAddress
) private{
_updateBurnAmount(user, msg.sender, amount);
uint256 devFee;
uint256 userRebate;
if (rewardPaybackPercentage !=0) devFee = (amount * rewardPaybackPercentage) /100;
if (userRebatePercentage !=0) userRebate = (amount * userRebatePercentage) /100;
if (devFee !=0) _mint(rewardPaybackAddress, devFee);
if (userRebate !=0) _mint(user, userRebate);
IShogunOnBurn(msg.sender).onBurn(user, amount);
}
//Views/** @notice Returns true/false of the given interfaceId
* @param interfaceId interface id
* @return bool true/false
*/functionsupportsInterface(bytes4 interfaceId) publicpurereturns (bool) {
return
interfaceId == IERC165.supportsInterface.selector||
interfaceId ==type(ITitanOnBurn).interfaceId;
}
/** @notice Returns current genesis wallet address
* @return address current genesis wallet address
*/functiongetGenesisAddress() publicviewreturns (address) {
return s_genesisAddress;
}
/** @notice Returns current LP wallet address
* @return address current LP wallet address
*/functiongetLPAddress() publicviewreturns (address) {
return s_lPAddress;
}
/** @notice Returns current buy and burn contract address
* @return address current buy and burn contract address
*/functiongetBuyAndBurnAddress() publicviewreturns (address) {
return s_buyAndBurnAddress;
}
/** @notice Returns status of the given address
* @return true/false
*/functiongetBuyAndBurnAddressRegistry(address contractAddress) publicviewreturns (bool) {
return s_buyAndBurnAddressRegistry[contractAddress];
}
/** @notice Returns status of the given address if it's excluded from transfer tax
* @return true/false
*/functionisAddressTaxExcluded(address user) publicviewreturns (bool) {
return s_taxExclusionList[user];
}
/** @notice Returns total X28 deposited
* @return amount
*/functiongetTotalX28Deposited() publicviewreturns (uint256) {
return s_totalX28Deposited;
}
/** @notice Returns total TitanX burned from deposit
* @return amount
*/functiongetTotalX28BurnedFromDeposits() publicviewreturns (uint256) {
return s_totalX28Burned;
}
/** @notice Returns total TitanX deposited
* @return amount
*/functiongetTotalTitanXDeposited() publicviewreturns (uint256) {
return s_totalTitanXDeposited;
}
/** @notice Returns total TitanX burned from deposit
* @return amount
*/functiongetTotalTitanXBurnedFromDeposits() publicviewreturns (uint256) {
return s_totalTitanXBurned;
}
/** @notice Returns total Shogun burned from tax
* @return amount
*/functiongetTotalShogunBurnedFromTax() publicviewreturns (uint256) {
return s_totalShogunTaxBurned;
}
//Public functions for devs to intergrate with Shogun/** @notice allow anyone to sync dailyUpdate manually */functionmanualDailyUpdate() publicdailyUpdate(s_buyAndBurnAddress) {}
/** @notice Burn Shogun tokens and creates Proof-Of-Burn record to be used by connected DeFi and fee is paid to specified address
* @param user user address
* @param amount Shogun amount
* @param userRebatePercentage percentage for user rebate in liquid Shogun (0 - 8)
* @param rewardPaybackPercentage percentage for builder fee in liquid Shogun (0 - 8)
* @param rewardPaybackAddress builder can opt to receive fee in another address
*/functionburnTokensToPayAddress(address user,
uint256 amount,
uint256 userRebatePercentage,
uint256 rewardPaybackPercentage,
address rewardPaybackAddress
) publicnonReentrantdailyUpdate(s_buyAndBurnAddress) {
_burnLiquidShogun(
user,
amount,
userRebatePercentage,
rewardPaybackPercentage,
rewardPaybackAddress
);
}
/** @notice Burn Shogun tokens and creates Proof-Of-Burn record to be used by connected DeFi and fee is paid to specified address
* @param user user address
* @param amount Shogun amount
* @param userRebatePercentage percentage for user rebate in liquid Shogun (0 - 8)
* @param rewardPaybackPercentage percentage for builder fee in liquid Shogun (0 - 8)
*/functionburnTokens(address user,
uint256 amount,
uint256 userRebatePercentage,
uint256 rewardPaybackPercentage
) publicnonReentrantdailyUpdate(s_buyAndBurnAddress) {
_burnLiquidShogun(user, amount, userRebatePercentage, rewardPaybackPercentage, msg.sender);
}
/** @notice allows user to burn liquid Shogun directly from contract
* @param amount Shogun amount
*/functionuserBurnTokens(uint256 amount) publicnonReentrantdailyUpdate(s_buyAndBurnAddress) {
_burn(msg.sender, amount);
_updateBurnAmount(msg.sender, address(0), amount);
}
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)pragmasolidity ^0.8.20;/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/interfaceIERC20Errors{
/**
* @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.
*/errorERC20InsufficientBalance(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.
*/errorERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/errorERC20InvalidReceiver(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.
*/errorERC20InsufficientAllowance(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.
*/errorERC20InvalidApprover(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.
*/errorERC20InvalidSpender(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.
*/interfaceIERC721Errors{
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/errorERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/errorERC721NonexistentToken(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.
*/errorERC721IncorrectOwner(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.
*/errorERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/errorERC721InvalidReceiver(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.
*/errorERC721InsufficientApproval(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.
*/errorERC721InvalidApprover(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.
*/errorERC721InvalidOperator(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.
*/interfaceIERC1155Errors{
/**
* @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.
*/errorERC1155InsufficientBalance(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.
*/errorERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/errorERC1155InvalidReceiver(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.
*/errorERC1155MissingApprovalForAll(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.
*/errorERC1155InvalidApprover(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.
*/errorERC1155InvalidOperator(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
*/errorERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}