More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 9,586 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Pause | 314370493 | 43 days ago | IN | 0 ETH | 0.00000032 | ||||
Transcend | 314365915 | 43 days ago | IN | 0 ETH | 0.00000294 | ||||
Transcend | 314340990 | 43 days ago | IN | 0 ETH | 0.00003167 | ||||
Transcend | 314330364 | 43 days ago | IN | 0 ETH | 0.00002714 | ||||
Transcend | 314271154 | 43 days ago | IN | 0 ETH | 0.00000711 | ||||
Transcend | 314270619 | 43 days ago | IN | 0 ETH | 0.00000817 | ||||
Transcend | 314270381 | 43 days ago | IN | 0 ETH | 0.00002269 | ||||
Transcend | 314263114 | 43 days ago | IN | 0 ETH | 0.00001402 | ||||
Transcend | 314257523 | 43 days ago | IN | 0 ETH | 0.00028445 | ||||
Transcend | 314230269 | 43 days ago | IN | 0 ETH | 0.00000592 | ||||
Transcend | 314211553 | 44 days ago | IN | 0 ETH | 0.00000772 | ||||
Transcend | 314205792 | 44 days ago | IN | 0 ETH | 0.00001938 | ||||
Transcend | 314193004 | 44 days ago | IN | 0 ETH | 0.00001634 | ||||
Transcend | 314163771 | 44 days ago | IN | 0 ETH | 0.00001181 | ||||
Transcend | 314158893 | 44 days ago | IN | 0 ETH | 0.00007339 | ||||
Transcend | 314150645 | 44 days ago | IN | 0 ETH | 0.0000238 | ||||
Transcend | 314150163 | 44 days ago | IN | 0 ETH | 0.00007922 | ||||
Transcend | 314150025 | 44 days ago | IN | 0 ETH | 0.00007821 | ||||
Transcend | 314149849 | 44 days ago | IN | 0 ETH | 0.00007984 | ||||
Transcend | 314128949 | 44 days ago | IN | 0 ETH | 0.00000417 | ||||
Transcend | 314126826 | 44 days ago | IN | 0 ETH | 0.00000705 | ||||
Transcend | 314121645 | 44 days ago | IN | 0 ETH | 0.00000381 | ||||
Transcend | 314099077 | 44 days ago | IN | 0 ETH | 0.00000327 | ||||
Transcend | 314082429 | 44 days ago | IN | 0 ETH | 0.00003206 | ||||
Transcend | 314082139 | 44 days ago | IN | 0 ETH | 0.00000326 |
Loading...
Loading
Contract Name:
Transcendence
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import { MerkleProof } from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "../Adventurer/IBatchAdventurerData.sol"; import "../Anima/Anima.sol"; import "../Adventurer/IAovLegacy.sol"; import "../Utils/ArrayUtils.sol"; import "../Utils/Epoch.sol"; import "../lib/ERC721A.sol"; import "../Manager/ManagerModifier.sol"; import "../Lootbox/ILootBoxDispenser.sol"; import "../Action/IActionPermit.sol"; import "../Action/Actions.sol"; import "../Adventurer/TraitConstants.sol"; import { EpochConfigurable } from "../Utils/EpochConfigurable.sol"; import "../Adventurer/IBatchAdventurerGateway.sol"; import "../ERC20/ITokenSpender.sol"; struct TranscendenceConfig { uint256 baseCostMultiplier; uint16 epochsPerLevel; uint16 epochDiscount; uint16 maxCooldownEpochs; uint16 maxCostEpochs; uint16 costPerEpoch; uint16 costPerLevel; uint16 costDiscount; uint16 costDivider; uint16 minTrainingPointsPerTranscendence; } uint256 constant OLD_MAX_TRANSCENDENCE = 16 days; struct TranscendenceMemory { // configs TranscendenceConfig config; uint128 epochConfig; uint maxProfession; // external stats uint24[10][] baseStats; uint24[10][] advancedStats; // totals uint totalAnima; LootBoxMemory lootBoxes; // single-adventurer temp address addr; uint256 adventurerId; uint256 archetypeId; bytes32[] proof; bytes32[] archetypeProof; uint256[] requiredEpochs; uint256 profession; uint level; uint class; uint currentArchetype; bool isSameArchetype; uint cost; uint rewardTokenId; } struct LootBoxMemory { uint[] ids; uint[] amounts; bool atLeastOneDispensed; } struct TranscendenceRequest { address[] _addresses; uint256[] _adventurerIds; bytes32[][] _proofs; uint256[] _archetypeIds; bytes32[][] _archetypeProofs; uint256[] _professions; } contract Transcendence is EpochConfigurable, ReentrancyGuard { using Epoch for uint256; //======================================= // Immutables //======================================= IBatchAdventurerData public immutable ADVENTURER_DATA; IBatchAdventurerGateway public immutable GATEWAY; IActionPermit public immutable ACTION_PERMIT; ITokenSpender public immutable TOKEN_SPENDER; IAovLegacy public immutable LEGACY; ILootBoxDispenser public immutable LOOT_BOX_DISPENSER; address public immutable AOV_ADDRESS; TranscendenceConfig public CONFIG; uint256 public immutable DEPLOY_TIME; //======================================= // Uints //======================================= uint256 public maxProfession; //======================================= // Bytes //======================================= bytes32 public merkleRoot; //======================================= // Rewards //======================================= uint256[] rewardTokenIds; uint256[] rewardTranscendenceLevelCaps; //======================================= // Events //======================================= event Transcended( address addr, uint256 adventurerId, uint256 archetypeId, uint256 profession, uint256 cost, uint256 rewardTokenId ); //======================================= // Constructor //======================================= constructor( address _manager, address _adventurerData, address _tokenSpender, address _gateway, address _actionPermit, address _legacy, address _lootBoxDispenser, address _aov, bytes32 _merkleRoot ) EpochConfigurable(_manager, 1 days, 0 hours) { CONFIG.baseCostMultiplier = 1 ether; CONFIG.costDiscount = 45; CONFIG.epochDiscount = 1; CONFIG.epochsPerLevel = 2; CONFIG.maxCostEpochs = 30; CONFIG.maxCooldownEpochs = 20; CONFIG.costPerEpoch = 1; CONFIG.costDivider = 5; ADVENTURER_DATA = IBatchAdventurerData(_adventurerData); TOKEN_SPENDER = ITokenSpender(_tokenSpender); GATEWAY = IBatchAdventurerGateway(_gateway); ACTION_PERMIT = IActionPermit(_actionPermit); LEGACY = IAovLegacy(_legacy); LOOT_BOX_DISPENSER = ILootBoxDispenser(_lootBoxDispenser); AOV_ADDRESS = _aov; merkleRoot = _merkleRoot; maxProfession = 3; DEPLOY_TIME = block.timestamp; } //======================================= // External //======================================= function transcend( address[] calldata _addresses, uint256[] calldata _adventurerIds, bytes32[][] calldata _proofs, uint256[] calldata _archetypeIds, bytes32[][] calldata _archetypeProofs, uint256[] calldata _professions ) external nonReentrant whenNotPaused { ArrayUtils.ensureSameLength( _addresses.length, _adventurerIds.length, _archetypeIds.length, _professions.length ); ArrayUtils.checkForDuplicates(_addresses, _adventurerIds); TranscendenceMemory memory mem; mem.config = CONFIG; mem.epochConfig = EPOCH_CONFIG; mem.advancedStats = ADVENTURER_DATA.getRawBatch( _addresses, _adventurerIds, traits.ADV_TRAIT_GROUP_ADVANCED ); mem.baseStats = ADVENTURER_DATA.getRawBatch( _addresses, _adventurerIds, traits.ADV_TRAIT_GROUP_BASE ); mem.lootBoxes = _prepareLootboxes(); mem.maxProfession = maxProfession; GATEWAY.checkAddressBatch(_addresses, _proofs); mem.requiredEpochs = new uint256[](_addresses.length); for (uint256 j = 0; j < _adventurerIds.length; j++) { mem.addr = _addresses[j]; mem.adventurerId = _adventurerIds[j]; mem.archetypeId = _archetypeIds[j]; mem.proof = _proofs[j]; mem.archetypeProof = _archetypeProofs[j]; mem.profession = _professions[j]; mem.level = mem.baseStats[j][traits.ADV_TRAIT_BASE_LEVEL]; mem.class = mem.baseStats[j][traits.ADV_TRAIT_BASE_CLASS]; // Get current level's cooldown timer to calculate trait points mem.requiredEpochs[j] = _cooldownInEpochs( mem.level, mem.config, mem.config.maxCooldownEpochs ); // Check profession is valid require( mem.profession <= mem.maxProfession, "Transcendence: Profession not valid" ); // Update profession mem.advancedStats[j][traits.ADV_TRAIT_ADVANCED_PROFESSION] = uint24( mem.profession ); // Assign some trait points to be trained mem.advancedStats[j][traits.ADV_TRAIT_ADVANCED_TRAINING_POINTS] += uint24( mem.requiredEpochs[j] < mem.config.minTrainingPointsPerTranscendence ? mem.config.minTrainingPointsPerTranscendence : mem.requiredEpochs[j] ); // Needs to actually wait for previous level transcendence timer, not the current one if (mem.requiredEpochs[j] > mem.config.epochsPerLevel) { mem.requiredEpochs[j] -= mem.config.epochsPerLevel; } else { mem.requiredEpochs[j] = 0; } mem.currentArchetype = uint( mem.advancedStats[j][traits.ADV_TRAIT_ADVANCED_ARCHETYPE] ); mem.isSameArchetype = mem.currentArchetype == mem.archetypeId; // No need to check merkleProof is same archetype if (!mem.isSameArchetype && mem.addr == AOV_ADDRESS) { // Verify address bytes32 leaf = keccak256(abi.encodePacked(mem.archetypeId, mem.class)); bool isValidLeaf = MerkleProof.verify( mem.archetypeProof, merkleRoot, leaf ); // Check if valid archetypeId for class require( isValidLeaf, "Transcendence: Variant class does not match your Adventurer class" ); // Update archetype mem.advancedStats[j][traits.ADV_TRAIT_ADVANCED_ARCHETYPE] = uint24( mem.archetypeId ); } // Calculate anima cost mem.cost = _animaCost(mem.addr, mem.level, mem.config); mem.totalAnima += mem.cost; // Track legacy LEGACY.chronicle( mem.addr, mem.adventurerId, mem.currentArchetype, mem.archetypeId ); // Find lootBox ID to dispense for ( uint16 rewardIndex = 0; rewardIndex < rewardTranscendenceLevelCaps.length && mem.level > rewardTranscendenceLevelCaps[rewardIndex]; rewardIndex++ ) { mem.rewardTokenId = rewardTokenIds[rewardIndex]; } // Dispense rewards if eligible if (mem.rewardTokenId > 0) { mem.lootBoxes.amounts[mem.rewardTokenId - 1]++; mem.lootBoxes.atLeastOneDispensed = true; } emit Transcended( mem.addr, mem.adventurerId, mem.archetypeId, mem.profession, mem.cost, mem.rewardTokenId ); } ACTION_PERMIT.checkAndMarkActionCompleteMany( msg.sender, _addresses, _adventurerIds, _proofs, ACTION_ADVENTURER_TRANSCENDENCE, mem.requiredEpochs, mem.epochConfig ); // Burn anima TOKEN_SPENDER.spend(msg.sender, mem.totalAnima, SPENDER_ADVENTURER_BUCKET); ADVENTURER_DATA.addBatch( _addresses, _adventurerIds, traits.ADV_TRAIT_GROUP_BASE, traits.LEGACY_ADV_AOV_TRAIT_LEVEL, 1 ); if (mem.lootBoxes.atLeastOneDispensed) { LOOT_BOX_DISPENSER.dispenseBatch( msg.sender, mem.lootBoxes.ids, mem.lootBoxes.amounts ); } ADVENTURER_DATA.updateBatchRaw( _addresses, _adventurerIds, traits.ADV_TRAIT_GROUP_ADVANCED, mem.advancedStats ); } function _cooldownInEpochs( uint level, TranscendenceConfig memory _config, uint16 limit ) internal pure returns (uint256 result) { result = level * uint(_config.epochsPerLevel); if (result < _config.epochDiscount) { return 0; } result -= _config.epochDiscount; if (result > uint(limit)) { result = uint(limit); } } function _animaCost( address _address, uint _level, TranscendenceConfig memory _config ) internal view returns (uint256 result) { result = _config.costPerLevel + _cooldownInEpochs(_level, _config, _config.maxCostEpochs) * _config.costPerEpoch; result *= _level; if (result <= _config.costDiscount) { return 0; } result -= _config.costDiscount; result *= _config.baseCostMultiplier; if (_address != AOV_ADDRESS) { result = result / _config.costDivider; } } function _prepareLootboxes() internal pure returns (LootBoxMemory memory result) { result.ids = new uint[](4); result.amounts = new uint[](4); for (uint i = 0; i < 4; i++) { result.ids[i] = i + 1; } } //======================================= // Admin //======================================= function updateMaxProfession(uint256 _value) external onlyAdmin { maxProfession = _value; } function updateMerkleRoot(bytes32 _value) external onlyAdmin { merkleRoot = _value; } function configureRewards( uint256[] calldata _rewardTranscendenceLevelCaps, uint256[] calldata _rewardTokenIds ) external onlyAdmin { require(_rewardTranscendenceLevelCaps.length == _rewardTokenIds.length); rewardTranscendenceLevelCaps = _rewardTranscendenceLevelCaps; rewardTokenIds = _rewardTokenIds; } function updateTranscendenceConfig( TranscendenceConfig calldata _config ) external onlyAdmin { CONFIG = _config; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @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 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]. */ abstract contract ReentrancyGuard { // 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. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; 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. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // 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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.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}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * 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]. * * 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 ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these 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 override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override 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 value {ERC20} uses, unless this function is * 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 override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override 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 `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` 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 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * 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 `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `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. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` 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. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../../../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 `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` 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 * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { _spendAllowance(account, _msgSender(), amount); _burn(account, amount); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ 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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ 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 amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` 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 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates merkle trees that are safe * against this attack out of the box. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} * * _Available since v4.7._ */ function verifyCalldata( bytes32[] calldata proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} * * _Available since v4.7._ */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * _Available since v4.7._ */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { return hashes[totalHashes - 1]; } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { return hashes[totalHashes - 1]; } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
// SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.17; uint64 constant DAILY_EPOCH_DURATION = 1 days; uint64 constant DAILY_EPOCH_OFFSET = 0 hours; uint64 constant HOURLY_EPOCH_DURATION = 1 hours; uint64 constant NO_OFFSET = 0 hours; uint256 constant ACTION_LOCK = 101; uint256 constant ACTION_ADVENTURER_HOMAGE = 1001; uint256 constant ACTION_ADVENTURER_BATTLE_V3 = 1002; uint256 constant ACTION_ADVENTURER_COLLECT_EPOCH_REWARDS = 1003; uint256 constant ACTION_ADVENTURER_VOID_CRAFTING = 1004; uint256 constant ACTION_ADVENTURER_REALM_CRAFTING = 1005; uint256 constant ACTION_ADVENTURER_ANIMA_REGENERATION = 1006; uint256 constant ACTION_ADVENTURER_BATTLE_V3_OPPONENT = 1007; uint256 constant ACTION_ADVENTURER_TRAINING = 1008; uint256 constant ACTION_ADVENTURER_TRANSCENDENCE = 1009; uint256 constant ACTION_ADVENTURER_MINT_MULTIPASS = 1010; uint256 constant ACTION_ARMORY_STAKE_RARITY_ITEM = 2001; uint256 constant ACTION_ARMORY_UNSTAKE_RARITY_ITEM = 2002; uint256 constant ACTION_ARMORY_STAKE_RARITY_ITEM_SHARD = 2011; uint256 constant ACTION_ARMORY_UNSTAKE_RARITY_ITEM_SHARD = 2012; uint256 constant ACTION_ARMORY_STAKE_MATERIAL_SHARD = 2021; uint256 constant ACTION_ARMORY_UNSTAKE_MATERIAL_SHARD = 2022; uint256 constant ACTION_ARMORY_STAKE_LAB = 2031; uint256 constant ACTION_ARMORY_UNSTAKE_LAB = 2032; uint256 constant ACTION_ARMORY_STAKE_COLLECTIBLE = 2041; uint256 constant ACTION_ARMORY_UNSTAKE_COLLECTIBLE = 2042; uint256 constant ACTION_ARMORY_STAKE_MATERIAL = 2051; uint256 constant ACTION_ARMORY_UNSTAKE_MATERIAL = 2052; uint256 constant ACTION_ARMORY_STAKE_CITY = 2061; uint256 constant ACTION_ARMORY_UNSTAKE_CITY = 2062; uint256 constant ACTION_ARMORY_STAKE_MONUMENT = 2071; uint256 constant ACTION_ARMORY_UNSTAKE_MONUMENT = 2072; uint256 constant ACTION_ARMORY_STAKE_ANIMA_CHAMBER = 2081; uint256 constant ACTION_ARMORY_UNSTAKE_ANIMA_CHAMBER = 2082; uint256 constant ACTION_ANIMA_STAKING_COLLECT_STAKER_REWARDS = 2083; uint256 constant ACTION_ANIMA_STAKING_COLLECT_REALMER_REWARDS = 2084; uint256 constant ACTION_REALM_COLLECT_COLLECTIBLES = 4001; uint256 constant ACTION_REALM_BUILD_LAB = 4011; uint256 constant ACTION_REALM_BUILD_MONUMENT = 4012; uint256 constant ACTION_REALM_BUILD_CITY = 4013;
// SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.17; error Unauthorized(address _tokenAddr, uint256 _tokenId); error EntityLocked(address _tokenAddr, uint256 _tokenId, uint _lockedUntil); error MinEpochsTooLow(uint256 _minEpochs); error InsufficientEpochSpan( uint256 _minEpochs, uint256 _epochs, address _tokenAddr, uint256 _tokenId ); error DuplicateActionAttempt(address _tokenAddr, uint256 _tokenId); interface IActionPermit { // Reverts if no permissions or action was already taken in the last _minEpochs function checkAndMarkActionComplete( address _sender, address _tokenAddr, uint256 _tokenId, bytes32[] calldata _proof, uint256 _action, uint256 _minEpochs, uint128 _epochConfig ) external; function checkAndMarkActionCompleteMany( address _sender, address[] calldata _tokenAddrs, uint256[] calldata _tokenIds, bytes32[][] calldata _proofs, uint256 _action, uint256 _minEpochs, uint128 _epochConfig ) external; function checkAndMarkActionCompleteMany( address _sender, address[] calldata _tokenAddrs, uint256[] calldata _tokenIds, bytes32[][] calldata _proofs, uint256 _action, uint256[] calldata _minEpochs, uint128 _epochConfig ) external; // Marks action complete even if already completed function forceMarkActionComplete(address _tokenAddr, uint256 _tokenId, uint256 _action) external; // Reverts if no permissions function checkPermissions( address _sender, address _tokenAddr, uint256 _tokenId, bytes32[] calldata _proof, uint256 _action ) external view; function checkOwner( address _tokenAddr, uint256 _tokenId, bytes32[] calldata _proof ) external view returns (address); function checkPermissionsMany( address _sender, address[] calldata _tokenAddr, uint256[] calldata _tokenId, bytes32[][] calldata _proofs, uint256 _action ) external view; function checkPermissionsMany( address _sender, address _tokenAddr, uint256[] calldata _tokenId, bytes32[][] calldata _proofs, uint256 _action ) external view; function checkOwnerBatch( address[] calldata _tokenAddrs, uint256[] calldata _tokenIds, bytes32[][] calldata _proofs ) external view returns (address[] memory); // Reverts if action already taken this epoch function checkIfEnoughEpochsElapsed( address _tokenAddr, uint256 _tokenId, uint256 _action, uint256 _minEpochs, uint128 _epochConfig ) external view; function checkIfEnoughEpochsElapsedBatch( address[] calldata _tokenAddrs, uint256[] calldata _tokenIds, uint256 _action, uint256 _minEpochs, uint128 _epochConfig ) external view; function checkIfEnoughEpochsElapsedBatch( address[] calldata _tokenAddrs, uint256[] calldata _tokenIds, uint256 _action, uint256[] calldata _minEpochs, uint128 _epochConfig ) external view; function getElapsedEpochs( address[] calldata _tokenAddrs, uint256[] calldata _tokenIds, uint256 _action, uint128 _epochConfig ) external view returns (uint[] memory result); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface IAovLegacy { function chronicle( address _addr, uint256 _adventurerId, uint256 _currentArchetype, uint256 _archetype ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; uint constant ADVENTURER_DATA_BASE = 0; uint constant ADVENTURER_DATA_AOV = 1; uint constant ADVENTURER_DATA_EXTENSION = 2; interface IBatchAdventurerData { function STORAGE( address _addr, uint256 _id, uint256 _type, uint256 _prop ) external view returns (uint24); function add(address _addr, uint256 _id, uint256 _type, uint256 _prop, uint256 _val) external; function addBatch( address[] calldata _addr, uint256[] calldata _id, uint256 _type, uint256[][] calldata _prop, uint256[][] calldata _val ) external; function addBatch( address[] calldata _addr, uint256[] calldata _id, uint256 _type, uint256 _prop, uint256 _val ) external; function addBatch( address[] calldata _addr, uint256[] calldata _id, uint256 _type, uint256 _prop, uint256[] calldata _val ) external; function update(address _addr, uint256 _id, uint256 _type, uint256 _prop, uint256 _val) external; function updateRaw(address _addr, uint256 _id, uint256 _type, uint24[10] calldata _val) external; function updateBatch( address[] calldata _addr, uint256[] calldata _id, uint256 _type, uint256 _prop, uint256[] calldata _val ) external; function updateBatchRaw( address[] calldata _addr, uint256[] calldata _id, uint256 _type, uint24[10][] calldata _val ) external; function remove(address _addr, uint256 _id, uint256 _type, uint256 _prop, uint256 _val) external; function removeBatch( address[] calldata _addr, uint256[] calldata _id, uint256 _type, uint256[][] calldata _prop, uint256[][] calldata _val ) external; function get(address _addr, uint256 _id, uint256 _type, uint256 _prop) external returns (uint256); function getRaw(address _addr, uint256 _id, uint256 _type) external returns (uint24[10] memory); function getMulti( address _addr, uint256 _id, uint256 _type, uint256[] calldata _prop ) external returns (uint256[] memory result); function getBatch( address[] calldata _addr, uint256[] calldata _id, uint256 _type, uint256 _prop ) external returns (uint256[] memory); function getBatchMulti( address[] calldata _addrs, uint256[] calldata _ids, uint256 _type, uint256[] calldata _props ) external returns (uint256[][] memory); function getRawBatch( address[] calldata _addrs, uint256[] calldata _ids, uint256 _type ) external returns (uint24[10][] memory result); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface IBatchAdventurerGateway { function checkAddress(address _addr, bytes32[] calldata _proof) external view; function checkAddressBatch(address[] calldata _addr, bytes32[][] calldata _proof) external view; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; library traits { uint256 public constant ADV_TRAIT_GROUP_BASE = 0; // Base, _type = 0 uint256 public constant ADV_TRAIT_BASE_LEVEL = 0; uint256 public constant ADV_TRAIT_BASE_XP = 1; uint256 public constant ADV_TRAIT_BASE_STRENGTH = 2; uint256 public constant ADV_TRAIT_BASE_DEXTERITY = 3; uint256 public constant ADV_TRAIT_BASE_CONSTITUTION = 4; uint256 public constant ADV_TRAIT_BASE_INTELLIGENCE = 5; uint256 public constant ADV_TRAIT_BASE_WISDOM = 6; uint256 public constant ADV_TRAIT_BASE_CHARISMA = 7; uint256 public constant ADV_TRAIT_BASE_CLASS = 8; uint256 public constant ADV_TRAIT_GROUP_ADVANCED = 1; // Advanced, _type = 1 uint256 public constant ADV_TRAIT_ADVANCED_ARCHETYPE = 0; uint256 public constant ADV_TRAIT_ADVANCED_PROFESSION = 1; uint256 public constant ADV_TRAIT_ADVANCED_TRAINING_POINTS = 2; // Base Ttraits // See AdventurerData.sol for details uint256 public constant LEGACY_ADV_BASE_TRAIT_XP = 0; uint256 public constant LEGACY_ADV_BASE_TRAIT_XP_BROKEN = 1; uint256 public constant LEGACY_ADV_BASE_TRAIT_STRENGTH = 2; uint256 public constant LEGACY_ADV_BASE_TRAIT_DEXTERITY = 3; uint256 public constant LEGACY_ADV_BASE_TRAIT_CONSTITUTION = 4; uint256 public constant LEGACY_ADV_BASE_TRAIT_INTELLIGENCE = 5; uint256 public constant LEGACY_ADV_BASE_TRAIT_WISDOM = 6; uint256 public constant LEGACY_ADV_BASE_TRAIT_CHARISMA = 7; uint256 public constant LEGACY_ADV_BASE_TRAIT_HP = 8; uint256 public constant LEGACY_ADV_BASE_TRAIT_HP_USED = 9; // AoV Traits // See AdventurerData.sol for details uint256 public constant LEGACY_ADV_AOV_TRAIT_LEVEL = 0; uint256 public constant LEGACY_ADV_AOV_TRAIT_ARCHETYPE = 1; uint256 public constant LEGACY_ADV_AOV_TRAIT_CLASS = 2; uint256 public constant LEGACY_ADV_AOV_TRAIT_PROFESSION = 3; function baseTraitNames() public pure returns (string[10] memory) { return [ "Level", "XP", "Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma", "Class", "" ]; } function advancedTraitNames() public pure returns (string[2] memory) { return ["Archetype", "Profession"]; } function baseTraitName(uint256 traitId) public pure returns (string memory) { return baseTraitNames()[traitId]; } function advancedTraitName(uint256 traitId) public pure returns (string memory) { return advancedTraitNames()[traitId]; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "../Bound/IERC20Bound.sol"; import "./IAnima.sol"; import "../Manager/ManagerModifier.sol"; contract Anima is IAnima, ERC20, ERC20Burnable, ManagerModifier, ReentrancyGuard, Pausable { //======================================= // Immutables //======================================= IERC20Bound public immutable BOUND; uint256 public immutable CAP; //======================================= // Constructor //======================================= constructor( address _manager, address _bound, uint256 _cap ) ERC20("Anima", "ANIMA") ManagerModifier(_manager) { BOUND = IERC20Bound(_bound); CAP = _cap; } //======================================= // External //======================================= function mintFor( address _for, uint256 _amount ) external override onlyTokenMinter { // Check amount doesn't exceed cap require(ERC20.totalSupply() + _amount <= CAP, "Anima: Cap exceeded"); // Mint _mint(_for, _amount); } function burnFrom( address account, uint256 amount ) public override(IAnima, ERC20Burnable) { super.burnFrom(account, amount); } //======================================= // Admin //======================================= function pause() external onlyAdmin { _pause(); } function unpause() external onlyAdmin { _unpause(); } //======================================= // Internal //======================================= function _beforeTokenTransfer( address from, address to, uint256 amount ) internal override { // Call super super._beforeTokenTransfer(from, to, amount); // Check if sender is manager if (!MANAGER.isManager(msg.sender, 0)) { // Check if minting or burning if (from != address(0) && to != address(0)) { // Check if token is unbound require(BOUND.isUnbound(address(this)), "Anima: Token not unbound"); } } // Check if contract is paused require(!paused(), "Anima: Paused"); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; interface IAnima is IERC20, IERC20Metadata { function CAP() external view returns (uint256); function mintFor(address _for, uint256 _amount) external; function burnFrom(address account, uint256 amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface IERC20Bound { function unbind(address _addresses) external; function isUnbound(address _addr) external view returns (bool); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "../Utils/IEpochConfigurable.sol"; uint constant SPENDER_ADVENTURER_BUCKET = 1; uint constant SPENDER_REALM_BUCKET = 2; interface ITokenSpender is IEpochConfigurable { function getEpochValue(uint _epoch) external view returns (uint); function getEpochValueBatch( uint startEpoch, uint endEpoch ) external view returns (uint[] memory result); function getBucketEpochValueBatch( uint _startEpoch, uint _endEpoch, uint _bucket ) external view returns (uint[] memory result); function getEpochValueBatchTotal( uint startEpoch, uint endEpoch ) external view returns (uint result); function getBucketEpochValueBatchTotal( uint _startEpoch, uint _endEpoch, uint _bucket ) external view returns (uint result); function spend(address _owner, uint _amount, uint _bucket) external; }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.1.0 // Creator: Chiru Labs pragma solidity ^0.8.4; import "./IERC721A.sol"; /** * @dev ERC721 token receiver interface. */ interface ERC721A__IERC721Receiver { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, * including the Metadata extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at `_startTokenId()` * (defaults to 0, e.g. 0, 1, 2, 3..). * * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * * Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721A is IERC721A { // Mask of an entry in packed address data. uint256 private constant BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1; // The bit position of `numberMinted` in packed address data. uint256 private constant BITPOS_NUMBER_MINTED = 64; // The bit position of `numberBurned` in packed address data. uint256 private constant BITPOS_NUMBER_BURNED = 128; // The bit position of `aux` in packed address data. uint256 private constant BITPOS_AUX = 192; // Mask of all 256 bits in packed address data except the 64 bits for `aux`. uint256 private constant BITMASK_AUX_COMPLEMENT = (1 << 192) - 1; // The bit position of `startTimestamp` in packed ownership. uint256 private constant BITPOS_START_TIMESTAMP = 160; // The bit mask of the `burned` bit in packed ownership. uint256 private constant BITMASK_BURNED = 1 << 224; // The bit position of the `nextInitialized` bit in packed ownership. uint256 private constant BITPOS_NEXT_INITIALIZED = 225; // The bit mask of the `nextInitialized` bit in packed ownership. uint256 private constant BITMASK_NEXT_INITIALIZED = 1 << 225; // The bit position of `extraData` in packed ownership. uint256 private constant BITPOS_EXTRA_DATA = 232; // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`. uint256 private constant BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1; // The mask of the lower 160 bits for addresses. uint256 private constant BITMASK_ADDRESS = (1 << 160) - 1; // The maximum `quantity` that can be minted with `_mintERC2309`. // This limit is to prevent overflows on the address data entries. // For a limit of 5000, a total of 3.689e15 calls to `_mintERC2309` // is required to cause an overflow, which is unrealistic. uint256 private constant MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000; // The tokenId of the next token to be minted. uint256 private _currentIndex; // The number of tokens burned. uint256 private _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. // See `_packedOwnershipOf` implementation for details. // // Bits Layout: // - [0..159] `addr` // - [160..223] `startTimestamp` // - [224] `burned` // - [225] `nextInitialized` // - [232..255] `extraData` mapping(uint256 => uint256) private _packedOwnerships; // Mapping owner address to address data. // // Bits Layout: // - [0..63] `balance` // - [64..127] `numberMinted` // - [128..191] `numberBurned` // - [192..255] `aux` mapping(address => uint256) private _packedAddressData; // Mapping from token ID to approved address. mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _currentIndex = _startTokenId(); } /** * @dev Returns the starting token ID. * To change the starting token ID, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 0; } /** * @dev Returns the next token ID to be minted. */ function _nextTokenId() internal view returns (uint256) { return _currentIndex; } /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see `_totalMinted`. */ function totalSupply() public view override returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than `_currentIndex - _startTokenId()` times. unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * @dev Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view returns (uint256) { // Counter underflow is impossible as _currentIndex does not decrement, // and it is initialized to `_startTokenId()` unchecked { return _currentIndex - _startTokenId(); } } /** * @dev Returns the total number of tokens burned. */ function _totalBurned() internal view returns (uint256) { return _burnCounter; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface( bytes4 interfaceId ) public view virtual override returns (bool) { // The interface IDs are constants representing the first 4 bytes of the XOR of // all function selectors in the interface. See: https://eips.ethereum.org/EIPS/eip-165 // e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)` return interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165. interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721. interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata. } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return _packedAddressData[owner] & BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return (_packedAddressData[owner] >> BITPOS_NUMBER_MINTED) & BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return (_packedAddressData[owner] >> BITPOS_NUMBER_BURNED) & BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return uint64(_packedAddressData[owner] >> BITPOS_AUX); } /** * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal { uint256 packed = _packedAddressData[owner]; uint256 auxCasted; // Cast `aux` with assembly to avoid redundant masking. assembly { auxCasted := aux } packed = (packed & BITMASK_AUX_COMPLEMENT) | (auxCasted << BITPOS_AUX); _packedAddressData[owner] = packed; } /** * Returns the packed ownership data of `tokenId`. */ function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr) if (curr < _currentIndex) { uint256 packed = _packedOwnerships[curr]; // If not burned. if (packed & BITMASK_BURNED == 0) { // Invariant: // There will always be an ownership that has an address and is not burned // before an ownership that does not have an address and is not burned. // Hence, curr will not underflow. // // We can directly compare the packed value. // If the address is zero, packed is zero. while (packed == 0) { packed = _packedOwnerships[--curr]; } return packed; } } } revert OwnerQueryForNonexistentToken(); } /** * Returns the unpacked `TokenOwnership` struct from `packed`. */ function _unpackedOwnership( uint256 packed ) private pure returns (TokenOwnership memory ownership) { ownership.addr = address(uint160(packed)); ownership.startTimestamp = uint64(packed >> BITPOS_START_TIMESTAMP); ownership.burned = packed & BITMASK_BURNED != 0; ownership.extraData = uint24(packed >> BITPOS_EXTRA_DATA); } /** * Returns the unpacked `TokenOwnership` struct at `index`. */ function _ownershipAt( uint256 index ) internal view returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnerships[index]); } /** * @dev Initializes the ownership slot minted at `index` for efficiency purposes. */ function _initializeOwnershipAt(uint256 index) internal { if (_packedOwnerships[index] == 0) { _packedOwnerships[index] = _packedOwnershipOf(index); } } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function _ownershipOf( uint256 tokenId ) internal view returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnershipOf(tokenId)); } /** * @dev Packs ownership data into a single uint256. */ function _packOwnershipData( address owner, uint256 flags ) private view returns (uint256 result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, BITMASK_ADDRESS) // `owner | (block.timestamp << BITPOS_START_TIMESTAMP) | flags`. result := or(owner, or(shl(BITPOS_START_TIMESTAMP, timestamp()), flags)) } } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return address(uint160(_packedOwnershipOf(tokenId))); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI( uint256 tokenId ) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, it can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev Returns the `nextInitialized` flag set if `quantity` equals 1. */ function _nextInitializedFlag( uint256 quantity ) private pure returns (uint256 result) { // For branchless setting of the `nextInitialized` flag. assembly { // `(quantity == 1) << BITPOS_NEXT_INITIALIZED`. result := shl(BITPOS_NEXT_INITIALIZED, eq(quantity, 1)) } } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ownerOf(tokenId); if (_msgSenderERC721A() != owner) if (!isApprovedForAll(owner, _msgSenderERC721A())) { revert ApprovalCallerNotOwnerNorApproved(); } _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll( address operator, bool approved ) public virtual override { if (operator == _msgSenderERC721A()) revert ApproveToCaller(); _operatorApprovals[_msgSenderERC721A()][operator] = approved; emit ApprovalForAll(_msgSenderERC721A(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll( address owner, address operator ) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { transferFrom(from, to, tokenId); if (to.code.length != 0) if (!_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return _startTokenId() <= tokenId && tokenId < _currentIndex && // If within bounds, _packedOwnerships[tokenId] & BITMASK_BURNED == 0; // and not burned. } /** * @dev Equivalent to `_safeMint(to, quantity, '')`. */ function _safeMint(address to, uint256 quantity) internal returns (uint256) { return _safeMint(to, quantity, ""); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * See {_mint}. * * Emits a {Transfer} event for each mint. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal returns (uint256) { uint256 startTokenId = _mint(to, quantity); unchecked { if (to.code.length != 0) { uint256 end = _currentIndex; uint256 index = end - quantity; do { if (!_checkContractOnERC721Received(address(0), to, index++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (index < end); // Reentrancy protection. if (_currentIndex != end) revert(); } } return startTokenId; } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event for each mint. */ function _mint(address to, uint256 quantity) internal returns (uint256) { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // `balance` and `numberMinted` have a maximum limit of 2**64. // `tokenId` has a maximum limit of 2**256. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. _packedAddressData[to] += quantity * ((1 << BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. _packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); uint256 tokenId = startTokenId; uint256 end = startTokenId + quantity; do { emit Transfer(address(0), to, tokenId++); } while (tokenId < end); _currentIndex = end; } _afterTokenTransfers(address(0), to, startTokenId, quantity); return startTokenId; } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * This function is intended for efficient minting only during contract creation. * * It emits only one {ConsecutiveTransfer} as defined in * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309), * instead of a sequence of {Transfer} event(s). * * Calling this function outside of contract creation WILL make your contract * non-compliant with the ERC721 standard. * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309 * {ConsecutiveTransfer} event is only permissible during contract creation. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {ConsecutiveTransfer} event. */ function _mintERC2309(address to, uint256 quantity) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); if (quantity > MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are unrealistic due to the above check for `quantity` to be below the limit. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. _packedAddressData[to] += quantity * ((1 << BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. _packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); emit ConsecutiveTransfer( startTokenId, startTokenId + quantity - 1, address(0), to ); _currentIndex = startTokenId + quantity; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Returns the storage slot and value for the approved address of `tokenId`. */ function _getApprovedAddress( uint256 tokenId ) private view returns (uint256 approvedAddressSlot, address approvedAddress) { mapping(uint256 => address) storage tokenApprovalsPtr = _tokenApprovals; // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId]`. assembly { // Compute the slot. mstore(0x00, tokenId) mstore(0x20, tokenApprovalsPtr.slot) approvedAddressSlot := keccak256(0x00, 0x40) // Load the slot's value from storage. approvedAddress := sload(approvedAddressSlot) } } /** * @dev Returns whether the `approvedAddress` is equals to `from` or `msgSender`. */ function _isOwnerOrApproved( address approvedAddress, address from, address msgSender ) private pure returns (bool result) { assembly { // Mask `from` to the lower 160 bits, in case the upper bits somehow aren't clean. from := and(from, BITMASK_ADDRESS) // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean. msgSender := and(msgSender, BITMASK_ADDRESS) // `msgSender == from || msgSender == approvedAddress`. result := or(eq(msgSender, from), eq(msgSender, approvedAddress)) } } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner(); ( uint256 approvedAddressSlot, address approvedAddress ) = _getApprovedAddress(tokenId); // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isOwnerOrApproved(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { // We can directly increment and decrement the balances. --_packedAddressData[from]; // Updates: `balance -= 1`. ++_packedAddressData[to]; // Updates: `balance += 1`. // Updates: // - `address` to the next owner. // - `startTimestamp` to the timestamp of transfering. // - `burned` to `false`. // - `nextInitialized` to `true`. _packedOwnerships[tokenId] = _packOwnershipData( to, BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (_packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != _currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. _packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Equivalent to `_burn(tokenId, false)`. */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); address from = address(uint160(prevOwnershipPacked)); ( uint256 approvedAddressSlot, address approvedAddress ) = _getApprovedAddress(tokenId); if (approvalCheck) { // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isOwnerOrApproved(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // Updates: // - `balance -= 1`. // - `numberBurned += 1`. // // We can directly decrement the balance, and increment the number burned. // This is equivalent to `packed -= 1; packed += 1 << BITPOS_NUMBER_BURNED;`. _packedAddressData[from] += (1 << BITPOS_NUMBER_BURNED) - 1; // Updates: // - `address` to the last owner. // - `startTimestamp` to the timestamp of burning. // - `burned` to `true`. // - `nextInitialized` to `true`. _packedOwnerships[tokenId] = _packOwnershipData( from, (BITMASK_BURNED | BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (_packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != _currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. _packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try ERC721A__IERC721Receiver(to).onERC721Received( _msgSenderERC721A(), from, tokenId, _data ) returns (bytes4 retval) { return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } /** * @dev Directly sets the extra data for the ownership data `index`. */ function _setExtraDataAt(uint256 index, uint24 extraData) internal { uint256 packed = _packedOwnerships[index]; if (packed == 0) revert OwnershipNotInitializedForExtraData(); uint256 extraDataCasted; // Cast `extraData` with assembly to avoid redundant masking. assembly { extraDataCasted := extraData } packed = (packed & BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << BITPOS_EXTRA_DATA); _packedOwnerships[index] = packed; } /** * @dev Returns the next extra data for the packed ownership data. * The returned result is shifted into position. */ function _nextExtraData( address from, address to, uint256 prevOwnershipPacked ) private view returns (uint256) { uint24 extraData = uint24(prevOwnershipPacked >> BITPOS_EXTRA_DATA); return uint256(_extraData(from, to, extraData)) << BITPOS_EXTRA_DATA; } /** * @dev Called during each token transfer to set the 24bit `extraData` field. * Intended to be overridden by the cosumer contract. * * `previousExtraData` - the value of `extraData` before transfer. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _extraData( address from, address to, uint24 previousExtraData ) internal view virtual returns (uint24) {} /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. * This includes minting. * And also called before burning one token. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. * This includes minting. * And also called after one token has been burned. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Returns the message sender (defaults to `msg.sender`). * * If you are writing GSN compatible contracts, you need to override this function. */ function _msgSenderERC721A() internal view virtual returns (address) { return msg.sender; } /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function _toString(uint256 value) internal pure returns (string memory ptr) { assembly { // The maximum value of a uint256 contains 78 digits (1 byte per digit), // but we allocate 128 bytes to keep the free memory pointer 32-byte word aliged. // We will need 1 32-byte word to store the length, // and 3 32-byte words to store a maximum of 78 digits. Total: 32 + 3 * 32 = 128. ptr := add(mload(0x40), 128) // Update the free memory pointer to allocate. mstore(0x40, ptr) // Cache the end of the memory to calculate the length later. let end := ptr // We write the string from the rightmost digit to the leftmost digit. // The following is essentially a do-while loop that also handles the zero case. // Costs a bit more than early returning for the zero case, // but cheaper in terms of deployment and overall runtime costs. for { // Initialize and perform the first pass without check. let temp := value // Move the pointer 1 byte leftwards to point to an empty character slot. ptr := sub(ptr, 1) // Write the character to the pointer. 48 is the ASCII index of '0'. mstore8(ptr, add(48, mod(temp, 10))) temp := div(temp, 10) } temp { // Keep dividing `temp` until zero. temp := div(temp, 10) } { // Body of the for loop. ptr := sub(ptr, 1) mstore8(ptr, add(48, mod(temp, 10))) } let length := sub(end, ptr) // Move the pointer 32 bytes leftwards to make room for the length. ptr := sub(ptr, 32) // Store the length. mstore(ptr, length) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; uint256 constant DECIMAL_POINT = 10 ** 3; uint256 constant ROUNDING_ADJUSTER = DECIMAL_POINT - 1; int256 constant SIGNED_DECIMAL_POINT = int256(DECIMAL_POINT); uint256 constant ONE_HUNDRED = 100 * DECIMAL_POINT; uint256 constant ONE_HUNDRED_SQUARE = ONE_HUNDRED * ONE_HUNDRED; int256 constant SIGNED_ONE_HUNDRED = 100 * SIGNED_DECIMAL_POINT; int256 constant SIGNED_ONE_HUNDRED_SQUARE = SIGNED_ONE_HUNDRED * SIGNED_ONE_HUNDRED; int256 constant SIGNED_ZERO = 0;
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.1.0 // Creator: Chiru Labs pragma solidity ^0.8.4; /** * @dev Interface of an ERC721A compliant contract. */ interface IERC721A { /** * The caller must own the token or be an approved operator. */ error ApprovalCallerNotOwnerNorApproved(); /** * The token does not exist. */ error ApprovalQueryForNonexistentToken(); /** * The caller cannot approve to their own address. */ error ApproveToCaller(); /** * Cannot query the balance for the zero address. */ error BalanceQueryForZeroAddress(); /** * Cannot mint to the zero address. */ error MintToZeroAddress(); /** * The quantity of tokens minted must be more than zero. */ error MintZeroQuantity(); /** * The token does not exist. */ error OwnerQueryForNonexistentToken(); /** * The caller must own the token or be an approved operator. */ error TransferCallerNotOwnerNorApproved(); /** * The token must be owned by `from`. */ error TransferFromIncorrectOwner(); /** * Cannot safely transfer to a contract that does not implement the ERC721Receiver interface. */ error TransferToNonERC721ReceiverImplementer(); /** * Cannot transfer to the zero address. */ error TransferToZeroAddress(); /** * The token does not exist. */ error URIQueryForNonexistentToken(); /** * The `quantity` minted with ERC2309 exceeds the safety limit. */ error MintERC2309QuantityExceedsLimit(); /** * The `extraData` cannot be set on an unintialized ownership slot. */ error OwnershipNotInitializedForExtraData(); struct TokenOwnership { // The address of the owner. address addr; // Keeps track of the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; // Arbitrary data similar to `startTimestamp` that can be set through `_extraData`. uint24 extraData; } /** * @dev Returns the total amount of tokens stored by the contract. * * Burned tokens are calculated here, use `_totalMinted()` if you want to count just minted tokens. */ function totalSupply() external view returns (uint256); // ============================== // IERC165 // ============================== /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); // ============================== // IERC721 // ============================== /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer( address indexed from, address indexed to, uint256 indexed tokenId ); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval( address indexed owner, address indexed approved, uint256 indexed tokenId ); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll( address indexed owner, address indexed operator, bool approved ); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved( uint256 tokenId ) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll( address owner, address operator ) external view returns (bool); // ============================== // IERC721Metadata // ============================== /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); // ============================== // IERC2309 // ============================== /** * @dev Emitted when tokens in `fromTokenId` to `toTokenId` (inclusive) is transferred from `from` to `to`, * as defined in the ERC2309 standard. See `_mintERC2309` for more details. */ event ConsecutiveTransfer( uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to ); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; interface ILootBoxDispenser { function dispense(address _address, uint256 _id, uint256 _amount) external; function dispenseBatch( address _address, uint256[] calldata _ids, uint256[] calldata _amounts ) external; event LootBoxesDispensed(address _address, uint256 _tokenId, uint256 _amount); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface IManager { function isAdmin(address _addr) external view returns (bool); function isManager(address _addr, uint256 _type) external view returns (bool); function addManager(address _addr, uint256 _type) external; function removeManager(address _addr, uint256 _type) external; function addAdmin(address _addr) external; function removeAdmin(address _addr) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "../Manager/IManager.sol"; abstract contract ManagerModifier { //======================================= // Immutables //======================================= IManager public immutable MANAGER; //======================================= // Constructor //======================================= constructor(address _manager) { MANAGER = IManager(_manager); } //======================================= // Modifiers //======================================= modifier onlyAdmin() { require(MANAGER.isAdmin(msg.sender), "Manager: Not an Admin"); _; } modifier onlyManager() { require(MANAGER.isManager(msg.sender, 0), "Manager: Not manager"); _; } modifier onlyMinter() { require(MANAGER.isManager(msg.sender, 1), "Manager: Not minter"); _; } modifier onlyTokenMinter() { require(MANAGER.isManager(msg.sender, 2), "Manager: Not token minter"); _; } modifier onlyBinder() { require(MANAGER.isManager(msg.sender, 3), "Manager: Not binder"); _; } modifier onlyConfigManager() { require(MANAGER.isManager(msg.sender, 4), "Manager: Not config manager"); _; } modifier onlyTokenSpender() { require(MANAGER.isManager(msg.sender, 5), "Manager: Not token spender"); _; } modifier onlyTokenEmitter() { require(MANAGER.isManager(msg.sender, 6), "Manager: Not token emitter"); _; } modifier onlyPauser() { require( MANAGER.isAdmin(msg.sender) || MANAGER.isManager(msg.sender, 6), "Manager: Not pauser" ); _; } }
// SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.17; library ArrayUtils { error ArrayLengthMismatch(uint _length1, uint _length2); error InvalidArrayOrder(uint index); function ensureSameLength(uint _l1, uint _l2) internal pure { if (_l1 != _l2) { revert ArrayLengthMismatch(_l1, _l2); } } function ensureSameLength(uint _l1, uint _l2, uint _l3) internal pure { ensureSameLength(_l1, _l2); ensureSameLength(_l1, _l3); } function ensureSameLength( uint _l1, uint _l2, uint _l3, uint _l4 ) internal pure { ensureSameLength(_l1, _l2); ensureSameLength(_l1, _l3); ensureSameLength(_l1, _l4); } function ensureSameLength( uint _l1, uint _l2, uint _l3, uint _l4, uint _l5 ) internal pure { ensureSameLength(_l1, _l2); ensureSameLength(_l1, _l3); ensureSameLength(_l1, _l4); ensureSameLength(_l1, _l5); } function checkAddressesForDuplicates( address[] memory _tokenAddrs ) internal pure { address lastAddress; for (uint i = 0; i < _tokenAddrs.length; i++) { if (lastAddress > _tokenAddrs[i]) { revert InvalidArrayOrder(i); } lastAddress = _tokenAddrs[i]; } } function checkForDuplicates(uint[] memory _ids) internal pure { uint lastId; for (uint i = 0; i < _ids.length; i++) { if (lastId > _ids[i]) { revert InvalidArrayOrder(i); } lastId = _ids[i]; } } function checkForDuplicates( address[] memory _tokenAddrs, uint[] memory _tokenIds ) internal pure { address lastAddress; int256 lastTokenId = -1; for (uint i = 0; i < _tokenAddrs.length; i++) { if (_tokenAddrs[i] > lastAddress) { lastTokenId = -1; } if (_tokenAddrs[i] < lastAddress || int(_tokenIds[i]) <= lastTokenId) { revert InvalidArrayOrder(i); } lastAddress = _tokenAddrs[i]; lastTokenId = int(_tokenIds[i]); } } function toSingleValueDoubleArray( uint[] memory _vals ) internal pure returns (uint[][] memory result) { result = new uint[][](_vals.length); for (uint i = 0; i < _vals.length; i++) { result[i] = ArrayUtils.toMemoryArray(_vals[i], 1); } } function toMemoryArray( uint _value, uint _length ) internal pure returns (uint[] memory result) { result = new uint[](_length); for (uint i = 0; i < _length; i++) { result[i] = _value; } } function toMemoryArray( uint[] calldata _value ) internal pure returns (uint[] memory result) { result = new uint[](_value.length); for (uint i = 0; i < _value.length; i++) { result[i] = _value[i]; } } function toMemoryArray( address _address, uint _length ) internal pure returns (address[] memory result) { result = new address[](_length); for (uint i = 0; i < _length; i++) { result[i] = _address; } } function toMemoryArray( address[] calldata _addresses ) internal pure returns (address[] memory result) { result = new address[](_addresses.length); for (uint i = 0; i < _addresses.length; i++) { result[i] = _addresses[i]; } } }
pragma solidity ^0.8.17; // SPDX-License-Identifier: Unlicensed import "../lib/FloatingPointConstants.sol"; uint256 constant MASK_128 = ((1 << 128) - 1); uint128 constant MASK_64 = ((1 << 64) - 1); library Epoch { // Converts a given timestamp to an epoch using the specified duration and offset. // Example for battle timers resetting at noon UTC is: _duration = 1 days; _offset = 12 hours; function toEpochNumber( uint256 _timestamp, uint256 _duration, uint256 _offset ) internal pure returns (uint256) { return (_timestamp + _offset) / _duration; } // Here we assume that _config is a packed _duration (left 64 bits) and _offset (right 64 bits) function toEpochNumber(uint256 _timestamp, uint128 _config) internal pure returns (uint256) { return (_timestamp + (_config & MASK_64)) / ((_config >> 64) & MASK_64); } // Returns a value between 0 and ONE_HUNDRED which is the percentage of "completeness" of the epoch // result variable is reused for memory efficiency function toEpochCompleteness( uint256 _timestamp, uint128 _config ) internal pure returns (uint256 result) { result = (_config >> 64) & MASK_64; result = (ONE_HUNDRED * ((_timestamp + (_config & MASK_64)) % result)) / result; } // Converts a given epoch to a timestamp at the start of the epoch function epochToTimestamp( uint256 _epoch, uint128 _config ) internal pure returns (uint256 result) { result = _epoch * ((_config >> 64) & MASK_64); if (result > 0) { result -= (_config & MASK_64); } } // Create a config for the function above function toConfig(uint64 _duration, uint64 _offset) internal pure returns (uint128) { return (uint128(_duration) << 64) | uint128(_offset); } // Pack the epoch number with the config into a single uint256 for mappings function packEpoch(uint256 _epochNumber, uint128 _config) internal pure returns (uint256) { return (uint256(_config) << 128) | uint128(_epochNumber); } // Convert timestamp to Epoch and pack it with the config into a single uint256 for mappings function packTimestampToEpoch( uint256 _timestamp, uint128 _config ) internal pure returns (uint256) { return packEpoch(toEpochNumber(_timestamp, _config), _config); } // Unpack packedEpoch to epochNumber and config function unpack( uint256 _packedEpoch ) internal pure returns (uint256 epochNumber, uint128 config) { config = uint128(_packedEpoch >> 128); epochNumber = _packedEpoch & MASK_128; } }
pragma solidity ^0.8.17; // SPDX-License-Identifier: MIT import "./Epoch.sol"; import "../Manager/ManagerModifier.sol"; import "./IEpochConfigurable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; contract EpochConfigurable is Pausable, ManagerModifier, IEpochConfigurable { uint128 public EPOCH_CONFIG; constructor( address _manager, uint64 _epochDuration, uint64 _epochOffset ) ManagerModifier(_manager) { EPOCH_CONFIG = Epoch.toConfig(_epochDuration, _epochOffset); } function currentEpoch() public view returns (uint) { return epochAtTimestamp(block.timestamp); } function epochAtTimestamp(uint _timestamp) public view returns (uint) { return Epoch.toEpochNumber(_timestamp, EPOCH_CONFIG); } //======================================= // Admin //======================================= function pause() external onlyAdmin { _pause(); } function unpause() external onlyAdmin { _unpause(); } function updateEpochConfig(uint64 duration, uint64 offset) external onlyAdmin { EPOCH_CONFIG = Epoch.toConfig(duration, offset); } }
pragma solidity ^0.8.17; // SPDX-License-Identifier: MIT interface IEpochConfigurable { function currentEpoch() external view returns (uint); function epochAtTimestamp(uint _timestamp) external view returns (uint); }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_manager","type":"address"},{"internalType":"address","name":"_adventurerData","type":"address"},{"internalType":"address","name":"_tokenSpender","type":"address"},{"internalType":"address","name":"_gateway","type":"address"},{"internalType":"address","name":"_actionPermit","type":"address"},{"internalType":"address","name":"_legacy","type":"address"},{"internalType":"address","name":"_lootBoxDispenser","type":"address"},{"internalType":"address","name":"_aov","type":"address"},{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"_length1","type":"uint256"},{"internalType":"uint256","name":"_length2","type":"uint256"}],"name":"ArrayLengthMismatch","type":"error"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"InvalidArrayOrder","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"adventurerId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"archetypeId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"profession","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cost","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardTokenId","type":"uint256"}],"name":"Transcended","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"ACTION_PERMIT","outputs":[{"internalType":"contract IActionPermit","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ADVENTURER_DATA","outputs":[{"internalType":"contract IBatchAdventurerData","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"AOV_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONFIG","outputs":[{"internalType":"uint256","name":"baseCostMultiplier","type":"uint256"},{"internalType":"uint16","name":"epochsPerLevel","type":"uint16"},{"internalType":"uint16","name":"epochDiscount","type":"uint16"},{"internalType":"uint16","name":"maxCooldownEpochs","type":"uint16"},{"internalType":"uint16","name":"maxCostEpochs","type":"uint16"},{"internalType":"uint16","name":"costPerEpoch","type":"uint16"},{"internalType":"uint16","name":"costPerLevel","type":"uint16"},{"internalType":"uint16","name":"costDiscount","type":"uint16"},{"internalType":"uint16","name":"costDivider","type":"uint16"},{"internalType":"uint16","name":"minTrainingPointsPerTranscendence","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPLOY_TIME","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EPOCH_CONFIG","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GATEWAY","outputs":[{"internalType":"contract IBatchAdventurerGateway","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LEGACY","outputs":[{"internalType":"contract IAovLegacy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LOOT_BOX_DISPENSER","outputs":[{"internalType":"contract ILootBoxDispenser","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER","outputs":[{"internalType":"contract IManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN_SPENDER","outputs":[{"internalType":"contract ITokenSpender","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_rewardTranscendenceLevelCaps","type":"uint256[]"},{"internalType":"uint256[]","name":"_rewardTokenIds","type":"uint256[]"}],"name":"configureRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"epochAtTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxProfession","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_addresses","type":"address[]"},{"internalType":"uint256[]","name":"_adventurerIds","type":"uint256[]"},{"internalType":"bytes32[][]","name":"_proofs","type":"bytes32[][]"},{"internalType":"uint256[]","name":"_archetypeIds","type":"uint256[]"},{"internalType":"bytes32[][]","name":"_archetypeProofs","type":"bytes32[][]"},{"internalType":"uint256[]","name":"_professions","type":"uint256[]"}],"name":"transcend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"duration","type":"uint64"},{"internalType":"uint64","name":"offset","type":"uint64"}],"name":"updateEpochConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"updateMaxProfession","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_value","type":"bytes32"}],"name":"updateMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"baseCostMultiplier","type":"uint256"},{"internalType":"uint16","name":"epochsPerLevel","type":"uint16"},{"internalType":"uint16","name":"epochDiscount","type":"uint16"},{"internalType":"uint16","name":"maxCooldownEpochs","type":"uint16"},{"internalType":"uint16","name":"maxCostEpochs","type":"uint16"},{"internalType":"uint16","name":"costPerEpoch","type":"uint16"},{"internalType":"uint16","name":"costPerLevel","type":"uint16"},{"internalType":"uint16","name":"costDiscount","type":"uint16"},{"internalType":"uint16","name":"costDivider","type":"uint16"},{"internalType":"uint16","name":"minTrainingPointsPerTranscendence","type":"uint16"}],"internalType":"struct TranscendenceConfig","name":"_config","type":"tuple"}],"name":"updateTranscendenceConfig","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6101a06040523480156200001257600080fd5b5060405162002d5d38038062002d5d8339810160408190526200003591620000f4565b600080546001600160a01b039a8b166080526001600160881b0319166b01518000000000000000000017905560018055670de0b6b3a764000060025560038054600165ffffffff000160501b0319166e05002d00000001001e00140001000217815597891660a0529588166101005293871660c05291861660e052851661012052841661014052909216610160526005919091556004554261018052620001a6565b80516001600160a01b0381168114620000ef57600080fd5b919050565b60008060008060008060008060006101208a8c0312156200011457600080fd5b6200011f8a620000d7565b98506200012f60208b01620000d7565b97506200013f60408b01620000d7565b96506200014f60608b01620000d7565b95506200015f60808b01620000d7565b94506200016f60a08b01620000d7565b93506200017f60c08b01620000d7565b92506200018f60e08b01620000d7565b91506101008a015190509295985092959850929598565b60805160a05160c05160e0516101005161012051610140516101605161018051612ac86200029560003960006102f201526000818161031901528181610efe0152611df0015260008181610379015261147e01526000818161020b01526110ce0152600081816101a6015261135c01526000818161024f015261129a0152600081816101e401526109d50152600081816104820152818161087401528181610918015281816113c201526114ea015260008181610162015281816104b9015281816115a20152818161165b0152818161172a015281816117e00152818161188901526119790152612ac86000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c80638456cb59116100c3578063bfbeb44b1161007c578063bfbeb44b14610361578063c7b0dcb314610374578063d92e82e41461039b578063e6c6ff0d14610461578063f29ee04f14610474578063fcac08921461047d57600080fd5b80638456cb59146102d25780638b51bfc6146102da57806390d92e76146102ed578063910f1e00146103145780639a7aea441461033b5780639c7efd3b1461034e57600080fd5b80634446e4a8116101155780634446e4a81461023757806344975d811461024a5780634783f0ef146102715780635c975abb14610284578063766718081461029a578063826229f0146102a257600080fd5b80631b2df8501461015d5780631e485f11146101a15780632eb4a7ab146101c8578063338c5371146101df5780633cdf0248146102065780633f4ba83a1461022d575b600080fd5b6101847f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6101847f000000000000000000000000000000000000000000000000000000000000000081565b6101d160055481565b604051908152602001610198565b6101847f000000000000000000000000000000000000000000000000000000000000000081565b6101847f000000000000000000000000000000000000000000000000000000000000000081565b6102356104a4565b005b61023561024536600461203d565b61055b565b6101847f000000000000000000000000000000000000000000000000000000000000000081565b61023561027f36600461217a565b61158d565b60005460ff166040519015158152602001610198565b6101d1611636565b6000546102ba9061010090046001600160801b031681565b6040516001600160801b039091168152602001610198565b610235611646565b6101d16102e836600461217a565b6116f2565b6101d17f000000000000000000000000000000000000000000000000000000000000000081565b6101847f000000000000000000000000000000000000000000000000000000000000000081565b610235610349366004612193565b611715565b61023561035c36600461217a565b6117cb565b61023561036f3660046121c8565b611874565b6101847f000000000000000000000000000000000000000000000000000000000000000081565b600254600354610407919061ffff80821691620100008104821691640100000000820481169166010000000000008104821691680100000000000000008204811691600160501b8104821691600160601b8204811691600160701b8104821691600160801b909104168a565b604080519a8b5261ffff998a1660208c0152978916978a01979097529487166060890152928616608088015290851660a0870152841660c0860152831660e085015282166101008401521661012082015261014001610198565b61023561046f3660046121fb565b611964565b6101d160045481565b6101847f000000000000000000000000000000000000000000000000000000000000000081565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa158015610508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052c9190612266565b6105515760405162461bcd60e51b815260040161054890612288565b60405180910390fd5b610559611a34565b565b610563611a86565b61056b611adf565b6105778b8a8784611b25565b6105f58c8c80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050508b8b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250611b4992505050565b6106ff604080516103c081018252600061028082018181526102a083018290526102c083018290526102e08301829052610300830182905261032083018290526103408301829052610360830182905261038083018290526103a083018290528252602080830182905282840182905260608084018190526080840181905260a084018390528451808201865281815291820152928301529060c0820190815260200160006001600160a01b0316815260200160008152602001600081526020016060815260200160608152602001606081526020016000815260200160008152602001600081526020016000815260200160001515815260200160008152602001600081525090565b600260405180610140016040529081600082015481526020016001820160009054906101000a900461ffff1661ffff1661ffff1681526020016001820160029054906101000a900461ffff1661ffff1661ffff1681526020016001820160049054906101000a900461ffff1661ffff1661ffff1681526020016001820160069054906101000a900461ffff1661ffff1661ffff1681526020016001820160089054906101000a900461ffff1661ffff1661ffff16815260200160018201600a9054906101000a900461ffff1661ffff1661ffff16815260200160018201600c9054906101000a900461ffff1661ffff1661ffff16815260200160018201600e9054906101000a900461ffff1661ffff1661ffff1681526020016001820160109054906101000a900461ffff1661ffff1661ffff16815250508160000181905250600060019054906101000a90046001600160801b031681602001906001600160801b031690816001600160801b0316815250507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166305692c758e8e8e8e60016040518663ffffffff1660e01b81526004016108c7959493929190612347565b6000604051808303816000875af11580156108e6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261090e91908101906123f0565b81608001819052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166305692c758e8e8e8e60006040518663ffffffff1660e01b815260040161096b959493929190612347565b6000604051808303816000875af115801561098a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109b291908101906123f0565b60608201526109bf611c50565b8160c001819052506004548160400181815250507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e3b161f98e8e8c8c6040518563ffffffff1660e01b8152600401610a259493929190612584565b60006040518083038186803b158015610a3d57600080fd5b505afa158015610a51573d6000803e3d6000fd5b508e925050506001600160401b03811115610a6e57610a6e612381565b604051908082528060200260200182016040528015610a97578160200160208202803683370190505b5061018082015260005b8a811015611297578d8d82818110610abb57610abb6125b6565b9050602002016020810190610ad091906125cc565b6001600160a01b031660e08301528b8b82818110610af057610af06125b6565b602002919091013561010084015250878782818110610b1157610b116125b6565b602002919091013561012084015250898982818110610b3257610b326125b6565b9050602002810190610b4491906125e7565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505050610140830152858582818110610b8d57610b8d6125b6565b9050602002810190610b9f91906125e7565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505050610160830152838382818110610be857610be86125b6565b60200291909101356101a0840152506060820151805182908110610c0e57610c0e6125b6565b60200260200101516000600a8110610c2857610c286125b6565b602002015162ffffff166101c08301526060820151805182908110610c4f57610c4f6125b6565b60200260200101516008600a8110610c6957610c696125b6565b602002015162ffffff166101e08301526101c082015182516060810151610c91929190611cf9565b8261018001518281518110610ca857610ca86125b6565b6020026020010181815250508160400151826101a001511115610d195760405162461bcd60e51b815260206004820152602360248201527f5472616e7363656e64656e63653a2050726f66657373696f6e206e6f742076616044820152621b1a5960ea1b6064820152608401610548565b816101a0015182608001518281518110610d3557610d356125b6565b60200260200101516001600a8110610d4f57610d4f6125b6565b62ffffff909216602092909202015281516101200151610180830151805161ffff9092169183908110610d8457610d846125b6565b602002602001015110610db5578161018001518181518110610da857610da86125b6565b6020026020010151610dc1565b8151610120015161ffff165b82608001518281518110610dd757610dd76125b6565b60200260200101516002600a8110610df157610df16125b6565b60200201818151610e029190612646565b62ffffff16905250815160200151610180830151805161ffff9092169183908110610e2f57610e2f6125b6565b60200260200101511115610e7d5781600001516020015161ffff168261018001518281518110610e6157610e616125b6565b60200260200101818151610e759190612669565b905250610ea3565b60008261018001518281518110610e9657610e966125b6565b6020026020010181815250505b81608001518181518110610eb957610eb96125b6565b60200260200101516000600a8110610ed357610ed36125b6565b602002015162ffffff166102008301819052610120830151146102208301819052801590610f3657507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168260e001516001600160a01b0316145b1561104f576101208201516101e08301516040805160208101939093528201526000906060016040516020818303038152906040528051906020012090506000610f8884610160015160055484611d58565b9050806110075760405162461bcd60e51b815260206004820152604160248201527f5472616e7363656e64656e63653a2056617269616e7420636c61737320646f6560448201527f73206e6f74206d6174636820796f757220416476656e747572657220636c61736064820152607360f81b608482015260a401610548565b83610120015184608001518481518110611023576110236125b6565b60200260200101516000600a811061103d5761103d6125b6565b62ffffff909216602092909202015250505b6110678260e00151836101c001518460000151611d6e565b610240830181905260a08301805161108090839061267c565b90525060e0820151610100830151610200840151610120850151604051630bfefcef60e31b81526001600160a01b0394851660048201526024810193909352604483019190915260648201527f000000000000000000000000000000000000000000000000000000000000000090911690635ff7e77890608401600060405180830381600087803b15801561111457600080fd5b505af1158015611128573d6000803e3d6000fd5b5050505060005b60075461ffff8216108015611169575060078161ffff1681548110611156576111566125b6565b9060005260206000200154836101c00151115b156111a95760068161ffff1681548110611185576111856125b6565b600091825260209091200154610260840152806111a18161268f565b91505061112f565b5061026082015115611206578160c001516020015160018361026001516111d09190612669565b815181106111e0576111e06125b6565b6020026020010180518091906111f5906126b0565b90525060c082015160016040909101525b60e08201516101008301516101208401516101a0850151610240860151610260870151604080516001600160a01b0390971687526020870195909552938501929092526060840152608083015260a08201527f5f39268d809af1162d0436009e336bba15e0a154a035b12f35099850281a6b9f9060c00160405180910390a18061128f816126b0565b915050610aa1565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a16fb8af338f8f8f8f8f8f6103f18a61018001518b602001516040518b63ffffffff1660e01b81526004016113019a999897969594939291906126f9565b600060405180830381600087803b15801561131b57600080fd5b505af115801561132f573d6000803e3d6000fd5b5050505060a08101516040516337ff86c160e21b81523360048201526024810191909152600160448201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063dffe1b0490606401600060405180830381600087803b1580156113a857600080fd5b505af11580156113bc573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166365b8e42d8e8e8e8e60008060016040518863ffffffff1660e01b815260040161141a9796959493929190612781565b600060405180830381600087803b15801561143457600080fd5b505af1158015611448573d6000803e3d6000fd5b505050508060c0015160400151156114e85760c08101518051602090910151604051635846ba5760e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169263b08d74ae926114b592339291906004016127c8565b600060405180830381600087803b1580156114cf57600080fd5b505af11580156114e3573d6000803e3d6000fd5b505050505b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c0c5b3d28e8e8e8e600187608001516040518763ffffffff1660e01b815260040161154396959493929190612808565b600060405180830381600087803b15801561155d57600080fd5b505af1158015611571573d6000803e3d6000fd5b505050505061157f60018055565b505050505050505050505050565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa1580156115f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116159190612266565b6116315760405162461bcd60e51b815260040161054890612288565b600555565b6000611641426116f2565b905090565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa1580156116aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ce9190612266565b6116ea5760405162461bcd60e51b815260040161054890612288565b610559611e43565b6000805461170f90839061010090046001600160801b0316611e80565b92915050565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa158015611779573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179d9190612266565b6117b95760405162461bcd60e51b815260040161054890612288565b8060026117c682826128bd565b505050565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa15801561182f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118539190612266565b61186f5760405162461bcd60e51b815260040161054890612288565b600455565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa1580156118d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118fc9190612266565b6119185760405162461bcd60e51b815260040161054890612288565b6fffffffffffffffff0000000000000000604083901b166001600160401b03821617600060016101000a8154816001600160801b0302191690836001600160801b031602179055505050565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa1580156119c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ec9190612266565b611a085760405162461bcd60e51b815260040161054890612288565b828114611a1457600080fd5b611a2060078585611f9b565b50611a2d60068383611f9b565b5050505050565b611a3c611ea8565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600260015403611ad85760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610548565b6002600155565b60005460ff16156105595760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610548565b611b2f8484611ef1565b611b398483611ef1565b611b438482611ef1565b50505050565b6000600019815b8451811015611a2d57826001600160a01b0316858281518110611b7557611b756125b6565b60200260200101516001600160a01b03161115611b925760001991505b826001600160a01b0316858281518110611bae57611bae6125b6565b60200260200101516001600160a01b03161080611be4575081848281518110611bd957611bd96125b6565b602002602001015113155b15611c0557604051637219f79560e11b815260048101829052602401610548565b848181518110611c1757611c176125b6565b60200260200101519250838181518110611c3357611c336125b6565b602002602001015191508080611c48906126b0565b915050611b50565b604080516060808201835280825260208201526000818301528151600480825260a082019093529091816020016020820280368337505050815260408051600480825260a082019092529060208201608080368337505050602082015260005b6004811015611cf557611cc481600161267c565b8251805183908110611cd857611cd86125b6565b602090810291909101015280611ced816126b0565b915050611cb0565b5090565b6000826020015161ffff1684611d0f9190612a59565b9050826040015161ffff16811015611d2957506000611d51565b6040830151611d3c9061ffff1682612669565b90508161ffff16811115611d51575061ffff81165b9392505050565b600082611d658584611f1f565b14949350505050565b60008160a0015161ffff16611d8884848560800151611cf9565b611d929190612a59565b8260c0015161ffff16611da5919061267c565b9050611db18382612a59565b90508160e0015161ffff168111611dca57506000611d51565b60e0820151611ddd9061ffff1682612669565b8251909150611dec9082612a59565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b031614611d5157610100820151611e3b9061ffff1682612a70565b949350505050565b611e4b611adf565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611a693390565b60006001600160401b03604083901c811690611e9e9084168561267c565b611d519190612a70565b60005460ff166105595760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610548565b808214611f1b57604051631f4bb7c160e31b81526004810183905260248101829052604401610548565b5050565b600081815b8451811015611f6457611f5082868381518110611f4357611f436125b6565b6020026020010151611f6c565b915080611f5c816126b0565b915050611f24565b509392505050565b6000818310611f88576000828152602084905260409020611d51565b6000838152602083905260409020611d51565b828054828255906000526020600020908101928215611fd6579160200282015b82811115611fd6578235825591602001919060010190611fbb565b50611cf59291505b80821115611cf55760008155600101611fde565b60008083601f84011261200457600080fd5b5081356001600160401b0381111561201b57600080fd5b6020830191508360208260051b850101111561203657600080fd5b9250929050565b60008060008060008060008060008060008060c08d8f03121561205f57600080fd5b6001600160401b038d35111561207457600080fd5b6120818e8e358f01611ff2565b909c509a506001600160401b0360208e0135111561209e57600080fd5b6120ae8e60208f01358f01611ff2565b909a5098506001600160401b0360408e013511156120cb57600080fd5b6120db8e60408f01358f01611ff2565b90985096506001600160401b0360608e013511156120f857600080fd5b6121088e60608f01358f01611ff2565b90965094506001600160401b0360808e0135111561212557600080fd5b6121358e60808f01358f01611ff2565b90945092506001600160401b0360a08e0135111561215257600080fd5b6121628e60a08f01358f01611ff2565b81935080925050509295989b509295989b509295989b565b60006020828403121561218c57600080fd5b5035919050565b600061014082840312156121a657600080fd5b50919050565b80356001600160401b03811681146121c357600080fd5b919050565b600080604083850312156121db57600080fd5b6121e4836121ac565b91506121f2602084016121ac565b90509250929050565b6000806000806040858703121561221157600080fd5b84356001600160401b038082111561222857600080fd5b61223488838901611ff2565b9096509450602087013591508082111561224d57600080fd5b5061225a87828801611ff2565b95989497509550505050565b60006020828403121561227857600080fd5b81518015158114611d5157600080fd5b60208082526015908201527426b0b730b3b2b91d102737ba1030b71020b236b4b760591b604082015260600190565b80356001600160a01b03811681146121c357600080fd5b8183526000602080850194508260005b8581101561230a576001600160a01b036122f7836122b7565b16875295820195908201906001016122de565b509495945050505050565b81835260006001600160fb1b0383111561232e57600080fd5b8260051b80836020870137939093016020019392505050565b60608152600061235b6060830187896122ce565b828103602084015261236e818688612315565b9150508260408301529695505050505050565b634e487b7160e01b600052604160045260246000fd5b60405161014081016001600160401b03811182821017156123ba576123ba612381565b60405290565b604051601f8201601f191681016001600160401b03811182821017156123e8576123e8612381565b604052919050565b6000602080838503121561240357600080fd5b82516001600160401b038082111561241a57600080fd5b8185019150601f868184011261242f57600080fd5b82518281111561244157612441612381565b61244f858260051b016123c0565b818152858101935061014091820285018601918983111561246f57600080fd5b948601945b828610156124e257898487011261248b5760008081fd5b612493612397565b808288018c8111156124a55760008081fd5b885b818110156124d057805162ffffff811681146124c35760008081fd5b8452928a01928a016124a7565b50508652509485019493860193612474565b5098975050505050505050565b81835260006020808501808196506005915085821b81018560005b88811015612576578383038a528135601e1989360301811261252b57600080fd5b880186810190356001600160401b0381111561254657600080fd5b80871b360382131561255757600080fd5b612562858284612315565b9b88019b945050509085019060010161250a565b509098975050505050505050565b6040815260006125986040830186886122ce565b82810360208401526125ab8185876124ef565b979650505050505050565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156125de57600080fd5b611d51826122b7565b6000808335601e198436030181126125fe57600080fd5b8301803591506001600160401b0382111561261857600080fd5b6020019150600581901b360382131561203657600080fd5b634e487b7160e01b600052601160045260246000fd5b62ffffff81811683821601908082111561266257612662612630565b5092915050565b8181038181111561170f5761170f612630565b8082018082111561170f5761170f612630565b600061ffff8083168181036126a6576126a6612630565b6001019392505050565b6000600182016126c2576126c2612630565b5060010190565b600081518084526020808501945080840160005b8381101561230a578151875295820195908201906001016126dd565b6001600160a01b038b16815260e06020820181905260009061271e9083018b8d6122ce565b8281036040840152612731818a8c612315565b9050828103606084015261274681888a6124ef565b905085608084015282810360a084015261276081866126c9565b9150506001600160801b03831660c08301529b9a5050505050505050505050565b60a08152600061279560a08301898b6122ce565b82810360208401526127a881888a612315565b604084019690965250506060810192909252608090910152949350505050565b6001600160a01b03841681526060602082018190526000906127ec908301856126c9565b82810360408401526127fe81856126c9565b9695505050505050565b60808152600061281c60808301888a6122ce565b60208382038185015261283082888a612315565b60408501879052848103606086015285518082528287019350908201906000805b8281101561289757855184835b600a81101561288057825162ffffff168252918701919087019060010161285e565b505050948401946101409390930192600101612851565b50919c9b505050505050505050505050565b6000813561ffff8116811461170f57600080fd5b813581556001810161ffff6128d4602085016128a9565b1661ffff198254161781556129086128ee604085016128a9565b825463ffff0000191660109190911b63ffff000016178255565b612935612917606085016128a9565b825465ffff00000000191660209190911b65ffff0000000016178255565b612966612944608085016128a9565b825467ffff000000000000191660309190911b67ffff00000000000016178255565b61299b61297560a085016128a9565b825469ffff0000000000000000191660409190911b69ffff000000000000000016178255565b6129ca6129aa60c085016128a9565b82805461ffff60501b191660509290921b61ffff60501b16919091179055565b6129f96129d960e085016128a9565b82805461ffff60601b191660609290921b61ffff60601b16919091179055565b612a29612a0961010085016128a9565b82805461ffff60701b191660709290921b61ffff60701b16919091179055565b6117c6612a3961012085016128a9565b82805461ffff60801b191660809290921b61ffff60801b16919091179055565b808202811582820484141761170f5761170f612630565b600082612a8d57634e487b7160e01b600052601260045260246000fd5b50049056fea26469706673582212209fda7a068e43ff7b3f7eab8ff9450a0ea23002e8b9689153c11f02dcc05faab264736f6c634300081400330000000000000000000000004e572433a3bfa336b6396d13afc9f69b58252861000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d000000000000000000000000c7d8fe8de91466a0167b191f2576dcfa7311ec43000000000000000000000000c1b4861697f3cba41c6a8744dee86daf62d3c123000000000000000000000000839f0ffee7d4edc9f3b38b2c2b316ff28da67e4a000000000000000000000000cb698daf6b266f03b54ed09ebd9339f6868f278b00000000000000000000000029738a66f6af4be679b65114cd84dd8fbeab3d6a000000000000000000000000747910b74d2651a06563c3182838eae4120f42777e7870d68f1b0fe8be03a49bd2865f886814077ee330d4306b8c4c5f892f5df1
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101585760003560e01c80638456cb59116100c3578063bfbeb44b1161007c578063bfbeb44b14610361578063c7b0dcb314610374578063d92e82e41461039b578063e6c6ff0d14610461578063f29ee04f14610474578063fcac08921461047d57600080fd5b80638456cb59146102d25780638b51bfc6146102da57806390d92e76146102ed578063910f1e00146103145780639a7aea441461033b5780639c7efd3b1461034e57600080fd5b80634446e4a8116101155780634446e4a81461023757806344975d811461024a5780634783f0ef146102715780635c975abb14610284578063766718081461029a578063826229f0146102a257600080fd5b80631b2df8501461015d5780631e485f11146101a15780632eb4a7ab146101c8578063338c5371146101df5780633cdf0248146102065780633f4ba83a1461022d575b600080fd5b6101847f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b5825286181565b6040516001600160a01b0390911681526020015b60405180910390f35b6101847f000000000000000000000000c7d8fe8de91466a0167b191f2576dcfa7311ec4381565b6101d160055481565b604051908152602001610198565b6101847f000000000000000000000000c1b4861697f3cba41c6a8744dee86daf62d3c12381565b6101847f000000000000000000000000cb698daf6b266f03b54ed09ebd9339f6868f278b81565b6102356104a4565b005b61023561024536600461203d565b61055b565b6101847f000000000000000000000000839f0ffee7d4edc9f3b38b2c2b316ff28da67e4a81565b61023561027f36600461217a565b61158d565b60005460ff166040519015158152602001610198565b6101d1611636565b6000546102ba9061010090046001600160801b031681565b6040516001600160801b039091168152602001610198565b610235611646565b6101d16102e836600461217a565b6116f2565b6101d17f00000000000000000000000000000000000000000000000000000000668c30b281565b6101847f000000000000000000000000747910b74d2651a06563c3182838eae4120f427781565b610235610349366004612193565b611715565b61023561035c36600461217a565b6117cb565b61023561036f3660046121c8565b611874565b6101847f00000000000000000000000029738a66f6af4be679b65114cd84dd8fbeab3d6a81565b600254600354610407919061ffff80821691620100008104821691640100000000820481169166010000000000008104821691680100000000000000008204811691600160501b8104821691600160601b8204811691600160701b8104821691600160801b909104168a565b604080519a8b5261ffff998a1660208c0152978916978a01979097529487166060890152928616608088015290851660a0870152841660c0860152831660e085015282166101008401521661012082015261014001610198565b61023561046f3660046121fb565b611964565b6101d160045481565b6101847f000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d81565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa158015610508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052c9190612266565b6105515760405162461bcd60e51b815260040161054890612288565b60405180910390fd5b610559611a34565b565b610563611a86565b61056b611adf565b6105778b8a8784611b25565b6105f58c8c80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050508b8b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250611b4992505050565b6106ff604080516103c081018252600061028082018181526102a083018290526102c083018290526102e08301829052610300830182905261032083018290526103408301829052610360830182905261038083018290526103a083018290528252602080830182905282840182905260608084018190526080840181905260a084018390528451808201865281815291820152928301529060c0820190815260200160006001600160a01b0316815260200160008152602001600081526020016060815260200160608152602001606081526020016000815260200160008152602001600081526020016000815260200160001515815260200160008152602001600081525090565b600260405180610140016040529081600082015481526020016001820160009054906101000a900461ffff1661ffff1661ffff1681526020016001820160029054906101000a900461ffff1661ffff1661ffff1681526020016001820160049054906101000a900461ffff1661ffff1661ffff1681526020016001820160069054906101000a900461ffff1661ffff1661ffff1681526020016001820160089054906101000a900461ffff1661ffff1661ffff16815260200160018201600a9054906101000a900461ffff1661ffff1661ffff16815260200160018201600c9054906101000a900461ffff1661ffff1661ffff16815260200160018201600e9054906101000a900461ffff1661ffff1661ffff1681526020016001820160109054906101000a900461ffff1661ffff1661ffff16815250508160000181905250600060019054906101000a90046001600160801b031681602001906001600160801b031690816001600160801b0316815250507f000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d6001600160a01b03166305692c758e8e8e8e60016040518663ffffffff1660e01b81526004016108c7959493929190612347565b6000604051808303816000875af11580156108e6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261090e91908101906123f0565b81608001819052507f000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d6001600160a01b03166305692c758e8e8e8e60006040518663ffffffff1660e01b815260040161096b959493929190612347565b6000604051808303816000875af115801561098a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109b291908101906123f0565b60608201526109bf611c50565b8160c001819052506004548160400181815250507f000000000000000000000000c1b4861697f3cba41c6a8744dee86daf62d3c1236001600160a01b031663e3b161f98e8e8c8c6040518563ffffffff1660e01b8152600401610a259493929190612584565b60006040518083038186803b158015610a3d57600080fd5b505afa158015610a51573d6000803e3d6000fd5b508e925050506001600160401b03811115610a6e57610a6e612381565b604051908082528060200260200182016040528015610a97578160200160208202803683370190505b5061018082015260005b8a811015611297578d8d82818110610abb57610abb6125b6565b9050602002016020810190610ad091906125cc565b6001600160a01b031660e08301528b8b82818110610af057610af06125b6565b602002919091013561010084015250878782818110610b1157610b116125b6565b602002919091013561012084015250898982818110610b3257610b326125b6565b9050602002810190610b4491906125e7565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505050610140830152858582818110610b8d57610b8d6125b6565b9050602002810190610b9f91906125e7565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505050610160830152838382818110610be857610be86125b6565b60200291909101356101a0840152506060820151805182908110610c0e57610c0e6125b6565b60200260200101516000600a8110610c2857610c286125b6565b602002015162ffffff166101c08301526060820151805182908110610c4f57610c4f6125b6565b60200260200101516008600a8110610c6957610c696125b6565b602002015162ffffff166101e08301526101c082015182516060810151610c91929190611cf9565b8261018001518281518110610ca857610ca86125b6565b6020026020010181815250508160400151826101a001511115610d195760405162461bcd60e51b815260206004820152602360248201527f5472616e7363656e64656e63653a2050726f66657373696f6e206e6f742076616044820152621b1a5960ea1b6064820152608401610548565b816101a0015182608001518281518110610d3557610d356125b6565b60200260200101516001600a8110610d4f57610d4f6125b6565b62ffffff909216602092909202015281516101200151610180830151805161ffff9092169183908110610d8457610d846125b6565b602002602001015110610db5578161018001518181518110610da857610da86125b6565b6020026020010151610dc1565b8151610120015161ffff165b82608001518281518110610dd757610dd76125b6565b60200260200101516002600a8110610df157610df16125b6565b60200201818151610e029190612646565b62ffffff16905250815160200151610180830151805161ffff9092169183908110610e2f57610e2f6125b6565b60200260200101511115610e7d5781600001516020015161ffff168261018001518281518110610e6157610e616125b6565b60200260200101818151610e759190612669565b905250610ea3565b60008261018001518281518110610e9657610e966125b6565b6020026020010181815250505b81608001518181518110610eb957610eb96125b6565b60200260200101516000600a8110610ed357610ed36125b6565b602002015162ffffff166102008301819052610120830151146102208301819052801590610f3657507f000000000000000000000000747910b74d2651a06563c3182838eae4120f42776001600160a01b03168260e001516001600160a01b0316145b1561104f576101208201516101e08301516040805160208101939093528201526000906060016040516020818303038152906040528051906020012090506000610f8884610160015160055484611d58565b9050806110075760405162461bcd60e51b815260206004820152604160248201527f5472616e7363656e64656e63653a2056617269616e7420636c61737320646f6560448201527f73206e6f74206d6174636820796f757220416476656e747572657220636c61736064820152607360f81b608482015260a401610548565b83610120015184608001518481518110611023576110236125b6565b60200260200101516000600a811061103d5761103d6125b6565b62ffffff909216602092909202015250505b6110678260e00151836101c001518460000151611d6e565b610240830181905260a08301805161108090839061267c565b90525060e0820151610100830151610200840151610120850151604051630bfefcef60e31b81526001600160a01b0394851660048201526024810193909352604483019190915260648201527f000000000000000000000000cb698daf6b266f03b54ed09ebd9339f6868f278b90911690635ff7e77890608401600060405180830381600087803b15801561111457600080fd5b505af1158015611128573d6000803e3d6000fd5b5050505060005b60075461ffff8216108015611169575060078161ffff1681548110611156576111566125b6565b9060005260206000200154836101c00151115b156111a95760068161ffff1681548110611185576111856125b6565b600091825260209091200154610260840152806111a18161268f565b91505061112f565b5061026082015115611206578160c001516020015160018361026001516111d09190612669565b815181106111e0576111e06125b6565b6020026020010180518091906111f5906126b0565b90525060c082015160016040909101525b60e08201516101008301516101208401516101a0850151610240860151610260870151604080516001600160a01b0390971687526020870195909552938501929092526060840152608083015260a08201527f5f39268d809af1162d0436009e336bba15e0a154a035b12f35099850281a6b9f9060c00160405180910390a18061128f816126b0565b915050610aa1565b507f000000000000000000000000839f0ffee7d4edc9f3b38b2c2b316ff28da67e4a6001600160a01b031663a16fb8af338f8f8f8f8f8f6103f18a61018001518b602001516040518b63ffffffff1660e01b81526004016113019a999897969594939291906126f9565b600060405180830381600087803b15801561131b57600080fd5b505af115801561132f573d6000803e3d6000fd5b5050505060a08101516040516337ff86c160e21b81523360048201526024810191909152600160448201527f000000000000000000000000c7d8fe8de91466a0167b191f2576dcfa7311ec436001600160a01b03169063dffe1b0490606401600060405180830381600087803b1580156113a857600080fd5b505af11580156113bc573d6000803e3d6000fd5b505050507f000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d6001600160a01b03166365b8e42d8e8e8e8e60008060016040518863ffffffff1660e01b815260040161141a9796959493929190612781565b600060405180830381600087803b15801561143457600080fd5b505af1158015611448573d6000803e3d6000fd5b505050508060c0015160400151156114e85760c08101518051602090910151604051635846ba5760e11b81526001600160a01b037f00000000000000000000000029738a66f6af4be679b65114cd84dd8fbeab3d6a169263b08d74ae926114b592339291906004016127c8565b600060405180830381600087803b1580156114cf57600080fd5b505af11580156114e3573d6000803e3d6000fd5b505050505b7f000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d6001600160a01b031663c0c5b3d28e8e8e8e600187608001516040518763ffffffff1660e01b815260040161154396959493929190612808565b600060405180830381600087803b15801561155d57600080fd5b505af1158015611571573d6000803e3d6000fd5b505050505061157f60018055565b505050505050505050505050565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa1580156115f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116159190612266565b6116315760405162461bcd60e51b815260040161054890612288565b600555565b6000611641426116f2565b905090565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa1580156116aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ce9190612266565b6116ea5760405162461bcd60e51b815260040161054890612288565b610559611e43565b6000805461170f90839061010090046001600160801b0316611e80565b92915050565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa158015611779573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179d9190612266565b6117b95760405162461bcd60e51b815260040161054890612288565b8060026117c682826128bd565b505050565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa15801561182f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118539190612266565b61186f5760405162461bcd60e51b815260040161054890612288565b600455565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa1580156118d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118fc9190612266565b6119185760405162461bcd60e51b815260040161054890612288565b6fffffffffffffffff0000000000000000604083901b166001600160401b03821617600060016101000a8154816001600160801b0302191690836001600160801b031602179055505050565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa1580156119c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ec9190612266565b611a085760405162461bcd60e51b815260040161054890612288565b828114611a1457600080fd5b611a2060078585611f9b565b50611a2d60068383611f9b565b5050505050565b611a3c611ea8565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600260015403611ad85760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610548565b6002600155565b60005460ff16156105595760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610548565b611b2f8484611ef1565b611b398483611ef1565b611b438482611ef1565b50505050565b6000600019815b8451811015611a2d57826001600160a01b0316858281518110611b7557611b756125b6565b60200260200101516001600160a01b03161115611b925760001991505b826001600160a01b0316858281518110611bae57611bae6125b6565b60200260200101516001600160a01b03161080611be4575081848281518110611bd957611bd96125b6565b602002602001015113155b15611c0557604051637219f79560e11b815260048101829052602401610548565b848181518110611c1757611c176125b6565b60200260200101519250838181518110611c3357611c336125b6565b602002602001015191508080611c48906126b0565b915050611b50565b604080516060808201835280825260208201526000818301528151600480825260a082019093529091816020016020820280368337505050815260408051600480825260a082019092529060208201608080368337505050602082015260005b6004811015611cf557611cc481600161267c565b8251805183908110611cd857611cd86125b6565b602090810291909101015280611ced816126b0565b915050611cb0565b5090565b6000826020015161ffff1684611d0f9190612a59565b9050826040015161ffff16811015611d2957506000611d51565b6040830151611d3c9061ffff1682612669565b90508161ffff16811115611d51575061ffff81165b9392505050565b600082611d658584611f1f565b14949350505050565b60008160a0015161ffff16611d8884848560800151611cf9565b611d929190612a59565b8260c0015161ffff16611da5919061267c565b9050611db18382612a59565b90508160e0015161ffff168111611dca57506000611d51565b60e0820151611ddd9061ffff1682612669565b8251909150611dec9082612a59565b90507f000000000000000000000000747910b74d2651a06563c3182838eae4120f42776001600160a01b0316846001600160a01b031614611d5157610100820151611e3b9061ffff1682612a70565b949350505050565b611e4b611adf565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611a693390565b60006001600160401b03604083901c811690611e9e9084168561267c565b611d519190612a70565b60005460ff166105595760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610548565b808214611f1b57604051631f4bb7c160e31b81526004810183905260248101829052604401610548565b5050565b600081815b8451811015611f6457611f5082868381518110611f4357611f436125b6565b6020026020010151611f6c565b915080611f5c816126b0565b915050611f24565b509392505050565b6000818310611f88576000828152602084905260409020611d51565b6000838152602083905260409020611d51565b828054828255906000526020600020908101928215611fd6579160200282015b82811115611fd6578235825591602001919060010190611fbb565b50611cf59291505b80821115611cf55760008155600101611fde565b60008083601f84011261200457600080fd5b5081356001600160401b0381111561201b57600080fd5b6020830191508360208260051b850101111561203657600080fd5b9250929050565b60008060008060008060008060008060008060c08d8f03121561205f57600080fd5b6001600160401b038d35111561207457600080fd5b6120818e8e358f01611ff2565b909c509a506001600160401b0360208e0135111561209e57600080fd5b6120ae8e60208f01358f01611ff2565b909a5098506001600160401b0360408e013511156120cb57600080fd5b6120db8e60408f01358f01611ff2565b90985096506001600160401b0360608e013511156120f857600080fd5b6121088e60608f01358f01611ff2565b90965094506001600160401b0360808e0135111561212557600080fd5b6121358e60808f01358f01611ff2565b90945092506001600160401b0360a08e0135111561215257600080fd5b6121628e60a08f01358f01611ff2565b81935080925050509295989b509295989b509295989b565b60006020828403121561218c57600080fd5b5035919050565b600061014082840312156121a657600080fd5b50919050565b80356001600160401b03811681146121c357600080fd5b919050565b600080604083850312156121db57600080fd5b6121e4836121ac565b91506121f2602084016121ac565b90509250929050565b6000806000806040858703121561221157600080fd5b84356001600160401b038082111561222857600080fd5b61223488838901611ff2565b9096509450602087013591508082111561224d57600080fd5b5061225a87828801611ff2565b95989497509550505050565b60006020828403121561227857600080fd5b81518015158114611d5157600080fd5b60208082526015908201527426b0b730b3b2b91d102737ba1030b71020b236b4b760591b604082015260600190565b80356001600160a01b03811681146121c357600080fd5b8183526000602080850194508260005b8581101561230a576001600160a01b036122f7836122b7565b16875295820195908201906001016122de565b509495945050505050565b81835260006001600160fb1b0383111561232e57600080fd5b8260051b80836020870137939093016020019392505050565b60608152600061235b6060830187896122ce565b828103602084015261236e818688612315565b9150508260408301529695505050505050565b634e487b7160e01b600052604160045260246000fd5b60405161014081016001600160401b03811182821017156123ba576123ba612381565b60405290565b604051601f8201601f191681016001600160401b03811182821017156123e8576123e8612381565b604052919050565b6000602080838503121561240357600080fd5b82516001600160401b038082111561241a57600080fd5b8185019150601f868184011261242f57600080fd5b82518281111561244157612441612381565b61244f858260051b016123c0565b818152858101935061014091820285018601918983111561246f57600080fd5b948601945b828610156124e257898487011261248b5760008081fd5b612493612397565b808288018c8111156124a55760008081fd5b885b818110156124d057805162ffffff811681146124c35760008081fd5b8452928a01928a016124a7565b50508652509485019493860193612474565b5098975050505050505050565b81835260006020808501808196506005915085821b81018560005b88811015612576578383038a528135601e1989360301811261252b57600080fd5b880186810190356001600160401b0381111561254657600080fd5b80871b360382131561255757600080fd5b612562858284612315565b9b88019b945050509085019060010161250a565b509098975050505050505050565b6040815260006125986040830186886122ce565b82810360208401526125ab8185876124ef565b979650505050505050565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156125de57600080fd5b611d51826122b7565b6000808335601e198436030181126125fe57600080fd5b8301803591506001600160401b0382111561261857600080fd5b6020019150600581901b360382131561203657600080fd5b634e487b7160e01b600052601160045260246000fd5b62ffffff81811683821601908082111561266257612662612630565b5092915050565b8181038181111561170f5761170f612630565b8082018082111561170f5761170f612630565b600061ffff8083168181036126a6576126a6612630565b6001019392505050565b6000600182016126c2576126c2612630565b5060010190565b600081518084526020808501945080840160005b8381101561230a578151875295820195908201906001016126dd565b6001600160a01b038b16815260e06020820181905260009061271e9083018b8d6122ce565b8281036040840152612731818a8c612315565b9050828103606084015261274681888a6124ef565b905085608084015282810360a084015261276081866126c9565b9150506001600160801b03831660c08301529b9a5050505050505050505050565b60a08152600061279560a08301898b6122ce565b82810360208401526127a881888a612315565b604084019690965250506060810192909252608090910152949350505050565b6001600160a01b03841681526060602082018190526000906127ec908301856126c9565b82810360408401526127fe81856126c9565b9695505050505050565b60808152600061281c60808301888a6122ce565b60208382038185015261283082888a612315565b60408501879052848103606086015285518082528287019350908201906000805b8281101561289757855184835b600a81101561288057825162ffffff168252918701919087019060010161285e565b505050948401946101409390930192600101612851565b50919c9b505050505050505050505050565b6000813561ffff8116811461170f57600080fd5b813581556001810161ffff6128d4602085016128a9565b1661ffff198254161781556129086128ee604085016128a9565b825463ffff0000191660109190911b63ffff000016178255565b612935612917606085016128a9565b825465ffff00000000191660209190911b65ffff0000000016178255565b612966612944608085016128a9565b825467ffff000000000000191660309190911b67ffff00000000000016178255565b61299b61297560a085016128a9565b825469ffff0000000000000000191660409190911b69ffff000000000000000016178255565b6129ca6129aa60c085016128a9565b82805461ffff60501b191660509290921b61ffff60501b16919091179055565b6129f96129d960e085016128a9565b82805461ffff60601b191660609290921b61ffff60601b16919091179055565b612a29612a0961010085016128a9565b82805461ffff60701b191660709290921b61ffff60701b16919091179055565b6117c6612a3961012085016128a9565b82805461ffff60801b191660809290921b61ffff60801b16919091179055565b808202811582820484141761170f5761170f612630565b600082612a8d57634e487b7160e01b600052601260045260246000fd5b50049056fea26469706673582212209fda7a068e43ff7b3f7eab8ff9450a0ea23002e8b9689153c11f02dcc05faab264736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000004e572433a3bfa336b6396d13afc9f69b58252861000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d000000000000000000000000c7d8fe8de91466a0167b191f2576dcfa7311ec43000000000000000000000000c1b4861697f3cba41c6a8744dee86daf62d3c123000000000000000000000000839f0ffee7d4edc9f3b38b2c2b316ff28da67e4a000000000000000000000000cb698daf6b266f03b54ed09ebd9339f6868f278b00000000000000000000000029738a66f6af4be679b65114cd84dd8fbeab3d6a000000000000000000000000747910b74d2651a06563c3182838eae4120f42777e7870d68f1b0fe8be03a49bd2865f886814077ee330d4306b8c4c5f892f5df1
-----Decoded View---------------
Arg [0] : _manager (address): 0x4E572433A3Bfa336b6396D13AfC9F69b58252861
Arg [1] : _adventurerData (address): 0xaEC1D99ea44b01071Befc08c4ECC9B4f1780678D
Arg [2] : _tokenSpender (address): 0xC7D8FE8DE91466a0167b191f2576DcfA7311Ec43
Arg [3] : _gateway (address): 0xC1b4861697F3Cba41C6A8744deE86DaF62d3C123
Arg [4] : _actionPermit (address): 0x839f0FFee7D4EDc9f3B38b2C2B316fF28DA67e4a
Arg [5] : _legacy (address): 0xCb698DaF6B266F03B54ED09ebd9339F6868F278B
Arg [6] : _lootBoxDispenser (address): 0x29738a66F6aF4BE679B65114Cd84Dd8FBEab3D6a
Arg [7] : _aov (address): 0x747910B74D2651A06563C3182838EAE4120F4277
Arg [8] : _merkleRoot (bytes32): 0x7e7870d68f1b0fe8be03a49bd2865f886814077ee330d4306b8c4c5f892f5df1
-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 0000000000000000000000004e572433a3bfa336b6396d13afc9f69b58252861
Arg [1] : 000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d
Arg [2] : 000000000000000000000000c7d8fe8de91466a0167b191f2576dcfa7311ec43
Arg [3] : 000000000000000000000000c1b4861697f3cba41c6a8744dee86daf62d3c123
Arg [4] : 000000000000000000000000839f0ffee7d4edc9f3b38b2c2b316ff28da67e4a
Arg [5] : 000000000000000000000000cb698daf6b266f03b54ed09ebd9339f6868f278b
Arg [6] : 00000000000000000000000029738a66f6af4be679b65114cd84dd8fbeab3d6a
Arg [7] : 000000000000000000000000747910b74d2651a06563c3182838eae4120f4277
Arg [8] : 7e7870d68f1b0fe8be03a49bd2865f886814077ee330d4306b8c4c5f892f5df1
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.